mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
[Java][Spring] fix optional query params missing in generated swagger (#7607)
* Added genericModelSubstitutes if using Optional As per https://github.com/springfox/springfox/issues/1848 Doesn't seem to fix the problem, but is what springfox recommends so might be aprt of it. * Added config package to scans If you have defined apiPackage and basepackage (e.g. as com.example.api) but not defined configPackage then config is still in io.swagger.config and is not included in the component scan. This means the config is not used when generating the swagger definition from the code. Fixed by including configPackage also in the scan. * Ran spring-all-pestore.sh update script * Converted tabs to spaces * Ran spring-all-pestore.sh update script
This commit is contained in:
parent
e5001a0c8d
commit
ff1178ad7e
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" })
|
||||
@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,9 @@ import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
{{#useOptional}}
|
||||
import java.util.Optional;
|
||||
{{/useOptional}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
@Configuration
|
||||
@ -44,6 +47,9 @@ public class SwaggerDocumentationConfig {
|
||||
.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
|
||||
.directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
|
||||
{{/threetenbp}}
|
||||
{{#useOptional}}
|
||||
.genericModelSubstitutes(Optional.class)
|
||||
{{/useOptional}}
|
||||
.apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@Configuration
|
||||
@ -34,6 +35,7 @@ public class SwaggerDocumentationConfig {
|
||||
.build()
|
||||
.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
|
||||
.directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
|
||||
.genericModelSubstitutes(Optional.class)
|
||||
.apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" })
|
||||
@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"})
|
||||
public class Swagger2SpringBoot implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user