Skip to content

Commit f631d54

Browse files
authored
Decommission springfox from kotlin-spring generator (#23283)
* decommission springfox from kotlin-spring generator * update doc * update test
1 parent 343b174 commit f631d54

43 files changed

Lines changed: 6 additions & 3228 deletions

Some content is hidden

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

.github/workflows/samples-kotlin-server.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
- samples/server/petstore/kotlin-springboot-reactive-without-flow
4040
- samples/server/petstore/kotlin-springboot-source-swagger1
4141
- samples/server/petstore/kotlin-springboot-source-swagger2
42-
- samples/server/petstore/kotlin-springboot-springfox
4342
- samples/server/petstore/kotlin-springboot-x-kotlin-implements
4443
- samples/server/petstore/kotlin-springboot-include-http-request-context-delegate
4544
- samples/server/petstore/kotlin-server/ktor2

bin/configs/kotlin-spring-boot-springfox.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/generators/kotlin-spring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3131
|configPackage|configuration package for generated code| |org.openapitools.configuration|
3232
|declarativeInterfaceReactiveMode|What type of reactive style to use in Spring Http declarative interface|<dl><dt>**coroutines**</dt><dd>Use kotlin-idiomatic 'suspend' functions</dd><dt>**reactor**</dt><dd>Use reactor return wrappers 'Mono' and 'Flux'</dd></dl>|coroutines|
3333
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
34-
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springfox**</dt><dd>Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
34+
|documentationProvider|Select the OpenAPI documentation provider.|<dl><dt>**none**</dt><dd>Do not publish an OpenAPI specification.</dd><dt>**source**</dt><dd>Publish the original input OpenAPI specification.</dd><dt>**springdoc**</dt><dd>Generate an OpenAPI 3 specification using SpringDoc.</dd></dl>|springdoc|
3535
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |original|
3636
|exceptionHandler|generate default global exception handlers (not compatible with reactive. enabling reactive will disable exceptionHandler )| |true|
3737
|gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ public List<DocumentationProvider> supportedDocumentationProvider() {
348348
return Arrays.asList(
349349
DocumentationProvider.NONE,
350350
DocumentationProvider.SOURCE,
351-
DocumentationProvider.SPRINGFOX,
352351
DocumentationProvider.SPRINGDOC
353352
);
354353
}
@@ -369,8 +368,7 @@ public List<AnnotationLibrary> supportedAnnotationLibraries() {
369368
* @return true if the selected DocumentationProvider requires us to bootstrap swagger-ui.
370369
*/
371370
private boolean selectedDocumentationProviderRequiresSwaggerUiBootstrap() {
372-
return getDocumentationProvider().equals(DocumentationProvider.SPRINGFOX) ||
373-
getDocumentationProvider().equals(DocumentationProvider.SOURCE);
371+
return getDocumentationProvider().equals(DocumentationProvider.SOURCE);
374372
}
375373

376374
public boolean getExceptionHandler() {
@@ -433,10 +431,6 @@ public void processOpts() {
433431

434432
super.processOpts();
435433

436-
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
437-
LOGGER.warn("The springfox documentation provider is deprecated for removal. Use the springdoc provider instead.");
438-
}
439-
440434
if (null != defaultDocumentationProvider()) {
441435
documentationProvider = DocumentationProvider.ofCliOption(
442436
(String) additionalProperties.getOrDefault(DOCUMENTATION_PROVIDER,
@@ -514,7 +508,6 @@ public void processOpts() {
514508
}
515509

516510
// Spring-specific import mappings for x-spring-paginated support
517-
importMapping.put("ApiIgnore", "springfox.documentation.annotations.ApiIgnore");
518511
importMapping.put("ParameterObject", "org.springdoc.api.annotations.ParameterObject");
519512
importMapping.put("PageableAsQueryParam", "org.springdoc.core.converters.models.PageableAsQueryParam");
520513
if (useSpringBoot3) {
@@ -725,9 +718,6 @@ public void processOpts() {
725718
}
726719

727720
if (isUseSpringBoot3() || isUseSpringBoot4()) {
728-
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
729-
throw new IllegalArgumentException(DocumentationProvider.SPRINGFOX.getPropertyName() + " is not supported with Spring Boot > 3.x");
730-
}
731721
if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {
732722
throw new IllegalArgumentException(AnnotationLibrary.SWAGGER1.getPropertyName() + " is not supported with Spring Boot > 3.x");
733723
}
@@ -899,11 +889,7 @@ public void processOpts() {
899889
}
900890

901891
if (!reactive && !(library.equals(SPRING_CLOUD_LIBRARY) || library.equals(SPRING_DECLARATIVE_HTTP_INTERFACE_LIBRARY))) {
902-
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
903-
supportingFiles.add(new SupportingFile("springfoxDocumentationConfig.mustache",
904-
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
905-
"SpringFoxConfiguration.kt"));
906-
} else if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) {
892+
if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) {
907893
supportingFiles.add(new SupportingFile("springdocDocumentationConfig.mustache",
908894
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator),
909895
"SpringDocConfiguration.kt"));
@@ -970,7 +956,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
970956
* When x-spring-paginated is set to true on an operation, this method:
971957
* - Adds org.springframework.data.domain.Pageable parameter to the method signature
972958
* - Removes the default Spring Data Web pagination query parameters (page, size, sort)
973-
* - Adds appropriate imports (Pageable, ApiIgnore for springfox, ParameterObject for springdoc)
959+
* - Adds appropriate imports (Pageable, ParameterObject for springdoc)
974960
*
975961
* Auto-detection (when autoXSpringPaginated is enabled):
976962
* - Automatically detects operations with 'page', 'size', and 'sort' query parameters (case-sensitive)
@@ -1037,9 +1023,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
10371023
// add org.springframework.data.domain.Pageable import when needed (server libraries only)
10381024
if (operation.getExtensions() != null && Boolean.TRUE.equals(operation.getExtensions().get("x-spring-paginated"))) {
10391025
codegenOperation.imports.add("Pageable");
1040-
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
1041-
codegenOperation.imports.add("ApiIgnore");
1042-
}
10431026
if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) {
10441027
codegenOperation.imports.add("PageableAsQueryParam");
10451028
// Prepend @PageableAsQueryParam to existing x-operation-extra-annotation if present

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/features/DocumentationProviderFeatures.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ enum DocumentationProvider {
7474
SWAGGER2("swagger2DocumentationProvider", "Generate an OpenAPI 3 specification using Swagger-Core 2.x.",
7575
AnnotationLibrary.SWAGGER2, AnnotationLibrary.SWAGGER2),
7676

77-
SPRINGFOX("springFoxDocumentationProvider", "Generate an OpenAPI 2 (fka Swagger RESTful API Documentation Specification) specification using SpringFox 2.x. Deprecated (for removal); use springdoc instead.",
78-
AnnotationLibrary.SWAGGER1, AnnotationLibrary.SWAGGER1),
79-
8077
SPRINGDOC("springDocDocumentationProvider", "Generate an OpenAPI 3 specification using SpringDoc.",
8178
AnnotationLibrary.SWAGGER2, AnnotationLibrary.SWAGGER2);
8279

modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ public void useTargetOnInterfaceAnnotationsWithSwagger1() throws IOException {
761761
KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
762762
codegen.setOutputDir(output.getAbsolutePath());
763763
codegen.additionalProperties().put(ANNOTATION_LIBRARY, AnnotationLibrary.SWAGGER1.toCliOptValue());
764-
codegen.additionalProperties().put(DOCUMENTATION_PROVIDER, DocumentationProvider.SPRINGFOX.toCliOptValue());
764+
codegen.additionalProperties().put(DOCUMENTATION_PROVIDER, DocumentationProvider.NONE.toCliOptValue());
765+
765766

766767
new DefaultGenerator().opts(new ClientOptInput()
767768
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue3596-use-correct-get-annotation-target.yaml"))
@@ -3260,20 +3261,6 @@ public Object[][] issue17997DocumentationProviders() {
32603261
"allowableValues = [\"sleeping\", \"awake\"]", "@PathVariable",
32613262
"@PathVariable"
32623263
)
3263-
},
3264-
{ DocumentationProviderFeatures.DocumentationProvider.SPRINGFOX.name(),
3265-
(Consumer<Path>) outputPath ->
3266-
assertFileContains(
3267-
outputPath,
3268-
"allowableValues = \"0, 1\", defaultValue = \"0\"",
3269-
"@PathVariable"
3270-
),
3271-
(Consumer<Path>) outputPath ->
3272-
assertFileContains(
3273-
outputPath,
3274-
"allowableValues = \"sleeping, awake\"", "@PathVariable",
3275-
"@PathVariable"
3276-
)
32773264
}
32783265
};
32793266
}
@@ -3701,23 +3688,6 @@ public void springPaginatedWithSpringDocAndSpringBoot3() throws Exception {
37013688
assertFileContains(petApi.toPath(), "pageable: Pageable");
37023689
}
37033690

3704-
@Test
3705-
public void springPaginatedWithSpringFox() throws Exception {
3706-
Map<String, Object> additionalProperties = new HashMap<>();
3707-
additionalProperties.put(USE_TAGS, "true");
3708-
additionalProperties.put(DOCUMENTATION_PROVIDER, "springfox");
3709-
additionalProperties.put(INTERFACE_ONLY, "true");
3710-
additionalProperties.put(SKIP_DEFAULT_INTERFACE, "true");
3711-
3712-
Map<String, File> files = generateFromContract("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml", additionalProperties);
3713-
3714-
File petApi = files.get("PetApi.kt");
3715-
assertFileContains(petApi.toPath(), "import org.springframework.data.domain.Pageable");
3716-
assertFileContains(petApi.toPath(), "import springfox.documentation.annotations.ApiIgnore");
3717-
assertFileContains(petApi.toPath(), "pageable: Pageable");
3718-
assertFileContains(petApi.toPath(), "@ApiParam(hidden = true) pageable: Pageable");
3719-
}
3720-
37213691
@Test
37223692
public void springPaginatedQueryParamsRemoved() throws Exception {
37233693
Map<String, Object> additionalProperties = new HashMap<>();
@@ -3845,24 +3815,6 @@ public void springPaginatedWithNoDocumentationProvider() throws Exception {
38453815
assertFileNotContains(petApi.toPath(), "@ParameterObject pageable");
38463816
}
38473817

3848-
@Test
3849-
public void springPaginatedWithSwagger1AnnotationLibrary() throws Exception {
3850-
Map<String, Object> additionalProperties = new HashMap<>();
3851-
additionalProperties.put(USE_TAGS, "true");
3852-
additionalProperties.put(DOCUMENTATION_PROVIDER, "springfox");
3853-
additionalProperties.put(ANNOTATION_LIBRARY, "swagger1");
3854-
additionalProperties.put(INTERFACE_ONLY, "true");
3855-
additionalProperties.put(SKIP_DEFAULT_INTERFACE, "true");
3856-
3857-
Map<String, File> files = generateFromContract("src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml", additionalProperties);
3858-
3859-
// Test with swagger1 annotations
3860-
File petApi = files.get("PetApi.kt");
3861-
assertFileContains(petApi.toPath(), "import org.springframework.data.domain.Pageable");
3862-
assertFileContains(petApi.toPath(), "import springfox.documentation.annotations.ApiIgnore");
3863-
assertFileContains(petApi.toPath(), "@ApiParam(hidden = true) pageable: Pageable");
3864-
}
3865-
38663818
@Test
38673819
public void springPaginatedWithSpringDocUsesPageableAsQueryParam() throws Exception {
38683820
Map<String, Object> additionalProperties = new HashMap<>();

samples/server/petstore/kotlin-springboot-springfox/.openapi-generator-ignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

samples/server/petstore/kotlin-springboot-springfox/.openapi-generator/FILES

Lines changed: 0 additions & 31 deletions
This file was deleted.

samples/server/petstore/kotlin-springboot-springfox/.openapi-generator/VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

samples/server/petstore/kotlin-springboot-springfox/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)