Skip to content

Commit

Permalink
clean up kotlin spring samples (#20445)
Browse files Browse the repository at this point in the history
* clean up samples

* use 3.0 petstore test spec

* update samples

* better code format
  • Loading branch information
wing328 authored Jan 11, 2025
1 parent 358e8af commit a6cfef5
Show file tree
Hide file tree
Showing 51 changed files with 250 additions and 3,113 deletions.
1 change: 0 additions & 1 deletion .github/workflows/samples-kotlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
- samples/server/petstore/kotlin-springboot-delegate
- samples/server/petstore/kotlin-springboot-modelMutable
- samples/server/petstore/kotlin-springboot-reactive
- samples/server/petstore/kotlin-springboot-reactive-with-flow
- samples/server/petstore/kotlin-springboot-reactive-without-flow
- samples/server/petstore/kotlin-springboot-source-swagger1
- samples/server/petstore/kotlin-springboot-source-swagger2
Expand Down
13 changes: 0 additions & 13 deletions bin/configs/kotlin-spring-boot-reactive-with-flow.yaml

This file was deleted.

4 changes: 3 additions & 1 deletion bin/configs/kotlin-spring-boot-reactive.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generatorName: kotlin-spring
outputDir: samples/server/petstore/kotlin-springboot-reactive
library: spring-boot
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
additionalProperties:
documentationProvider: springdoc
Expand All @@ -10,3 +10,5 @@ additionalProperties:
serviceImplementation: "true"
reactive: "true"
beanValidations: "true"
# the following option is set to true by default
#useFlowForArrayReturnType: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,34 @@ public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanVa
public static final String DEFAULT_LIBRARY = Constants.KTOR;
private final Logger LOGGER = LoggerFactory.getLogger(KotlinServerCodegen.class);

@Getter @Setter
@Getter
@Setter
private Boolean autoHeadFeatureEnabled = true;
@Getter @Setter
@Getter
@Setter
private Boolean conditionalHeadersFeatureEnabled = false;
@Getter @Setter
@Getter
@Setter
private Boolean hstsFeatureEnabled = true;
@Getter @Setter
@Getter
@Setter
private Boolean corsFeatureEnabled = false;
@Getter @Setter
@Getter
@Setter
private Boolean compressionFeatureEnabled = true;
@Getter @Setter
@Getter
@Setter
private Boolean resourcesFeatureEnabled = true;
@Getter @Setter
@Getter
@Setter
private Boolean metricsFeatureEnabled = true;
private boolean interfaceOnly = false;
private boolean useBeanValidation = false;
private boolean useCoroutines = false;
private boolean useMutiny = false;
private boolean returnResponse = false;
@Setter private boolean omitGradleWrapper = false;
@Setter
private boolean omitGradleWrapper = false;

// This is here to potentially warn the user when an option is not supported by the target framework.
private Map<String, List<String>> optionsSupportedPerFramework = new ImmutableMap.Builder<String, List<String>>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,12 @@ public void reactiveWithoutFlow() throws Exception {
codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true);

List<File> files = new DefaultGenerator()
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();

Assertions.assertThat(files).contains(
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
Expand Down Expand Up @@ -969,12 +969,12 @@ public void reactiveWithFlow() throws Exception {
codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true);

List<File> files = new DefaultGenerator()
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();

Assertions.assertThat(files).contains(
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
Expand Down Expand Up @@ -1015,12 +1015,12 @@ public void reactiveWithDefaultValueFlow() throws Exception {
codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true);

List<File> files = new DefaultGenerator()
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();

Assertions.assertThat(files).contains(
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
Expand Down Expand Up @@ -1060,12 +1060,12 @@ public void nonReactiveWithoutFlow() throws Exception {
codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true);

List<File> files = new DefaultGenerator()
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();

Assertions.assertThat(files).contains(
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
Expand Down Expand Up @@ -1105,12 +1105,12 @@ public void nonReactiveWithFlow() throws Exception {
codegen.additionalProperties().put(KotlinSpringServerCodegen.DELEGATE_PATTERN, true);

List<File> files = new DefaultGenerator()
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();
.opts(
new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue16130-add-useFlowForArrayReturnType-param.yaml"))
.config(codegen)
)
.generate();

Assertions.assertThat(files).contains(
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Loading

0 comments on commit a6cfef5

Please sign in to comment.