Skip to content

Commit c912bae

Browse files
[Spring] Fix bean name collisions (#14092) (fix #14094)
* Use correct Pascal case for java enum * Uniquely name @bean annotations * Use existing mustache var instead, run generate files * rebase, re-run generators * try to undo botched rebase/merge * Attempt to manually undo whatever is going on w/ build, oops * Attempt to manually undo whatever is going on w/ build, oops
1 parent 9f50293 commit c912bae

File tree

55 files changed

+305
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+305
-123
lines changed

modules/openapi-generator/src/main/resources/JavaSpring/converter.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class EnumConverterConfiguration {
1818
{{#models}}
1919
{{#model}}
2020
{{#isEnum}}
21-
@Bean
21+
@Bean(name = "{{configPackage}}.EnumConverterConfiguration.{{classVarName}}Converter")
2222
Converter<{{{dataType}}}, {{classname}}> {{classVarName}}Converter() {
2323
return new Converter<{{{dataType}}}, {{classname}}>() {
2424
@Override

modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/openapi2SpringBoot.mustache

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ import org.springframework.boot.SpringApplication;
88
import org.springframework.boot.autoconfigure.SpringBootApplication;
99
import org.springframework.context.annotation.Bean;
1010
import org.springframework.context.annotation.ComponentScan;
11+
import org.springframework.context.annotation.FilterType;
12+
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
1113

12-
@SpringBootApplication
13-
@ComponentScan(basePackages = {"{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"})
14+
@SpringBootApplication(
15+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
16+
)
17+
@ComponentScan(
18+
basePackages = {"{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"},
19+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
20+
)
1421
public class OpenApiGeneratorApplication {
1522
1623
public static void main(String[] args) {
1724
SpringApplication.run(OpenApiGeneratorApplication.class, args);
1825
}
1926

2027
{{#openApiNullable}}
21-
@Bean
28+
@Bean(name = "{{basePackage}}.OpenApiGeneratorApplication.jsonNullableModule")
2229
public Module jsonNullableModule() {
2330
return new JsonNullableModule();
2431
}

modules/openapi-generator/src/main/resources/JavaSpring/springdocDocumentationConfig.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import io.swagger.v3.oas.models.security.SecurityScheme;
1313
@Configuration
1414
public class SpringDocConfiguration {
1515
16-
@Bean
16+
@Bean(name = "{{configPackage}}.SpringDocConfiguration.apiInfo")
1717
OpenAPI apiInfo() {
1818
return new OpenAPI()
1919
.info(

samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/OpenApiGeneratorApplication.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import org.springframework.boot.autoconfigure.SpringBootApplication;
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.ComponentScan;
9+
import org.springframework.context.annotation.FilterType;
10+
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
911

10-
@SpringBootApplication
11-
@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"})
12+
@SpringBootApplication(
13+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
14+
)
15+
@ComponentScan(
16+
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
17+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
18+
)
1219
public class OpenApiGeneratorApplication {
1320

1421
public static void main(String[] args) {
1522
SpringApplication.run(OpenApiGeneratorApplication.class, args);
1623
}
1724

18-
@Bean
25+
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
1926
public Module jsonNullableModule() {
2027
return new JsonNullableModule();
2128
}

samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/configuration/SpringDocConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@Configuration
1414
public class SpringDocConfiguration {
1515

16-
@Bean
16+
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
1717
OpenAPI apiInfo() {
1818
return new OpenAPI()
1919
.info(

samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/OpenApiGeneratorApplication.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import org.springframework.boot.autoconfigure.SpringBootApplication;
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.ComponentScan;
9+
import org.springframework.context.annotation.FilterType;
10+
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
911

10-
@SpringBootApplication
11-
@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"})
12+
@SpringBootApplication(
13+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
14+
)
15+
@ComponentScan(
16+
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
17+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
18+
)
1219
public class OpenApiGeneratorApplication {
1320

1421
public static void main(String[] args) {
1522
SpringApplication.run(OpenApiGeneratorApplication.class, args);
1623
}
1724

18-
@Bean
25+
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
1926
public Module jsonNullableModule() {
2027
return new JsonNullableModule();
2128
}

samples/openapi3/server/petstore/spring-boot-springdoc/src/main/java/org/openapitools/configuration/SpringDocConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@Configuration
1414
public class SpringDocConfiguration {
1515

16-
@Bean
16+
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
1717
OpenAPI apiInfo() {
1818
return new OpenAPI()
1919
.info(

samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/OpenApiGeneratorApplication.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import org.springframework.boot.autoconfigure.SpringBootApplication;
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.ComponentScan;
9+
import org.springframework.context.annotation.FilterType;
10+
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
911

10-
@SpringBootApplication
11-
@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"})
12+
@SpringBootApplication(
13+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
14+
)
15+
@ComponentScan(
16+
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
17+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
18+
)
1219
public class OpenApiGeneratorApplication {
1320

1421
public static void main(String[] args) {
1522
SpringApplication.run(OpenApiGeneratorApplication.class, args);
1623
}
1724

18-
@Bean
25+
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
1926
public Module jsonNullableModule() {
2027
return new JsonNullableModule();
2128
}

samples/openapi3/server/petstore/springboot-3/src/main/java/org/openapitools/configuration/SpringDocConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@Configuration
1414
public class SpringDocConfiguration {
1515

16-
@Bean
16+
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
1717
OpenAPI apiInfo() {
1818
return new OpenAPI()
1919
.info(

samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/OpenApiGeneratorApplication.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.context.annotation.Bean;
66
import org.springframework.context.annotation.ComponentScan;
7+
import org.springframework.context.annotation.FilterType;
8+
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
79

8-
@SpringBootApplication
9-
@ComponentScan(basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"})
10+
@SpringBootApplication(
11+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
12+
)
13+
@ComponentScan(
14+
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
15+
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
16+
)
1017
public class OpenApiGeneratorApplication {
1118

1219
public static void main(String[] args) {

0 commit comments

Comments
 (0)