-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing @Schema's defaultValue generation and SwaggerDocumentationConfig #796
Conversation
{{^useOas2}} | ||
{{^springBootV2}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to change but there is an issue since springdoc-openapi-ui
dependency is introduced but the version is conditional on {{springBootV2}}
, fixing that as well.
@@ -53,7 +50,7 @@ public class SwaggerDocumentationConfig { | |||
{{/useOptional}} | |||
.apiInfo(apiInfo()); | |||
} | |||
{{#useOas2}} | |||
|
|||
ApiInfo apiInfo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like ApiInfo is needed even for OAS 3.x, adding that
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}){{/useOas2}}{{^useOas2}}@Parameter(in = ParameterIn.QUERY, description = "{{{description}}}" {{#required}},required=true{{/required}},schema=@Schema({{#allowableValues}}{{> allowableValues }}{{/allowableValues}}{{#defaultValue}}{{#allowableValues}},{{/allowableValues}} defaultValue="{{{defaultValue}}}"{{/defaultValue}})){{/useOas2}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now generates correctly:
@Parameter(in = ParameterIn.QUERY, description = "", schema = @Schema(defaultValue = "*"))
@Parameter(in = ParameterIn.HEADER, description = "status",
schema = @Schema(allowableValues = {"AVAILABLE", "PENDING"}, defaultValue = "AVAILABLE") )
Hi @reta can i help you testing? Deploy the snapshot version od 1.0.24-SNAPSHOT and i can test it. Best, |
@SlavchoArsovski yeah, that would be much appreciated. I do not have merge permissions on the repository, so the way to test it is still simple:
Please let me know if you need any help, thanks! |
Hi @reta, I have tested, i did tested by copying your templates from this PR. For instance now inheritance and composition are not well described. There are descriptions like: @Schema(subTypes = {Cat.class, Dog.class}, discriminatorProperty = "petType", discriminatorMapping = { @ApiResponse(responseCode = "200", description = "Get Payment Details", content = @content(schema = @Schema(oneOf = { Which are not used. In other words, generated code is fine. But Annotation description is missing in such cases. Now with this version my swagger ui documentation is not complete. Best, |
Hi @SlavchoArsovski , The OAS 3.x is very rich indeed, not all features are supported by generators yet however it could be certainly improved. It just takes more time unfortunately since the changes in how generator model is built might be needed. Do you use |
@reta, it is a big API from my project, i just tried to add example to see how inheritance and composition will play out with new swagger ui springfox 3.0. |
Got it @SlavchoArsovski , would you mind please to submit an issue with examples of OAS 3.x API definitions and expected generation outcomes, so we could work it through, thank you. |
@reta sure, but i will need some time, but in my opinion this PR should be merged |
@HugoMario , sorry, mind taking a look please? |
@reta |
thanks @reta !! |
Thanks @HugoMario |
@HugoMario fixes #795