diff --git a/.github/workflows/samples-kotlin-server.yaml b/.github/workflows/samples-kotlin-server.yaml index 8550a29ac419..5b6f3f0a0884 100644 --- a/.github/workflows/samples-kotlin-server.yaml +++ b/.github/workflows/samples-kotlin-server.yaml @@ -39,6 +39,7 @@ jobs: - samples/server/petstore/kotlin-springboot-source-swagger2 - samples/server/petstore/kotlin-springboot-springfox - samples/server/petstore/kotlin-springboot-x-kotlin-implements + - samples/server/petstore/kotlin-springboot-include-http-request-context-delegate - samples/server/petstore/kotlin-server/ktor - samples/server/petstore/kotlin-server/ktor2 - samples/server/petstore/kotlin-server/jaxrs-spec diff --git a/bin/configs/kotlin-spring-boot-include-http-request-context-delegate.yaml b/bin/configs/kotlin-spring-boot-include-http-request-context-delegate.yaml new file mode 100644 index 000000000000..e8b7eabf1c1c --- /dev/null +++ b/bin/configs/kotlin-spring-boot-include-http-request-context-delegate.yaml @@ -0,0 +1,17 @@ +generatorName: kotlin-spring +outputDir: samples/server/petstore/kotlin-springboot-include-http-request-context-delegate +library: spring-boot +inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml +templateDir: modules/openapi-generator/src/main/resources/kotlin-spring +additionalProperties: + documentationProvider: none + annotationLibrary: swagger1 + useSwaggerUI: false + serviceImplementation: false + skipDefaultInterface: true + interfaceOnly: false + serializableModel: true + beanValidations: true + includeHttpRequestContext: true + reactive: true + delegatePattern: true diff --git a/bin/configs/kotlin-spring-boot-x-kotlin-implements.yaml b/bin/configs/kotlin-spring-boot-x-kotlin-implements.yaml index c4068770d55d..1d1218b58452 100644 --- a/bin/configs/kotlin-spring-boot-x-kotlin-implements.yaml +++ b/bin/configs/kotlin-spring-boot-x-kotlin-implements.yaml @@ -5,10 +5,11 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/petstore-with templateDir: modules/openapi-generator/src/main/resources/kotlin-spring additionalProperties: documentationProvider: none - annotationLibrary: none - useSwaggerUI: "false" - serviceImplementation: "false" - skipDefaultInterface: "true" - interfaceOnly: "true" - serializableModel: "true" - beanValidations: "true" + annotationLibrary: swagger1 + useSwaggerUI: false + serviceImplementation: false + skipDefaultInterface: true + interfaceOnly: true + serializableModel: true + beanValidations: true + includeHttpRequestContext: true diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index e79fdd782b70..3bf00ed266e8 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -33,6 +33,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |exceptionHandler|generate default global exception handlers (not compatible with reactive. enabling reactive will disable exceptionHandler )| |true| |gradleBuildFile|generate a gradle build file using the Kotlin DSL| |true| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| +|includeHttpRequestContext|Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.| |false| |interfaceOnly|Whether to generate only API interface stubs without the server files.| |false| |library|library template (sub-template)|
**spring-boot**
Spring-boot Server application.
**spring-cloud**
Spring-Cloud-Feign client with Spring-Boot auto-configured settings.
|spring-boot| |modelMutable|Create mutable models| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index 821726610733..8a4752f8d1ed 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -86,6 +86,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen public static final String BEAN_QUALIFIERS = "beanQualifiers"; public static final String USE_SPRING_BOOT3 = "useSpringBoot3"; + public static final String INCLUDE_HTTP_REQUEST_CONTEXT = "includeHttpRequestContext"; public static final String USE_FLOW_FOR_ARRAY_RETURN_TYPE = "useFlowForArrayReturnType"; public static final String REQUEST_MAPPING_OPTION = "requestMappingMode"; public static final String USE_REQUEST_MAPPING_ON_CONTROLLER = "useRequestMappingOnController"; @@ -127,6 +128,7 @@ public String getDescription() { @Setter private boolean serviceImplementation = false; @Getter @Setter private boolean reactive = false; + @Setter private boolean includeHttpRequestContext = false; @Getter @Setter private boolean useFlowForArrayReturnType = true; @Setter private boolean interfaceOnly = false; @@ -220,6 +222,7 @@ public KotlinSpringServerCodegen() { " (contexts) added to single project.", beanQualifiers); addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3); addSwitch(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType); + addSwitch(INCLUDE_HTTP_REQUEST_CONTEXT, "Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.", includeHttpRequestContext); supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application."); supportedLibraries.put(SPRING_CLOUD_LIBRARY, "Spring-Cloud-Feign client with Spring-Boot auto-configured settings."); @@ -564,6 +567,9 @@ public void processOpts() { if (additionalProperties.containsKey(USE_SPRING_BOOT3)) { this.setUseSpringBoot3(convertPropertyToBoolean(USE_SPRING_BOOT3)); } + if (additionalProperties.containsKey(INCLUDE_HTTP_REQUEST_CONTEXT)) { + this.setIncludeHttpRequestContext(convertPropertyToBoolean(INCLUDE_HTTP_REQUEST_CONTEXT)); + } if (isUseSpringBoot3()) { if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) { throw new IllegalArgumentException(DocumentationProvider.SPRINGFOX.getPropertyName() + " is not supported with Spring Boot > 3.x"); diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache index 22ca85de6f94..5a371f6309c6 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache @@ -89,7 +89,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} ) - {{#reactive}}{{^isArray}}suspend {{/isArray}}{{#isArray}}{{^useFlowForArrayReturnType}}suspend {{/useFlowForArrayReturnType}}{{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { + {{#reactive}}{{^isArray}}suspend {{/isArray}}{{#isArray}}{{^useFlowForArrayReturnType}}suspend {{/useFlowForArrayReturnType}}{{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, {{/hasParams}}{{#swagger1AnnotationLibrary}}@ApiParam(hidden = true) {{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true) {{/swagger2AnnotationLibrary}}{{#reactive}}exchange: org.springframework.web.server.ServerWebExchange{{/reactive}}{{^reactive}}request: {{javaxPackage}}.servlet.http.HttpServletRequest{{/reactive}}{{/includeHttpRequestContext}}): ResponseEntity<{{>returnTypes}}> { return {{>returnValue}} } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache index cb76cbcc7dda..403f55f33c67 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiDelegate.mustache @@ -34,7 +34,8 @@ interface {{classname}}Delegate { * @see {{classname}}#{{operationId}} */ {{#reactive}}{{^isArray}}suspend {{/isArray}}{{#isArray}}{{^useFlowForArrayReturnType}}suspend {{/useFlowForArrayReturnType}}{{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}{{#isBodyParam}}Flow<{{{baseType}}}>{{/isBodyParam}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{/isArray}}{{/reactive}}{{^-last}}, - {{/-last}}{{/allParams}}): {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}}{{^skipDefaultDelegateInterface}} { + {{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, + {{/hasParams}}{{#reactive}}exchange: org.springframework.web.server.ServerWebExchange{{/reactive}}{{^reactive}}request: {{javaxPackage}}.servlet.http.HttpServletRequest{{/reactive}}{{/includeHttpRequestContext}}): {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}}{{^skipDefaultDelegateInterface}} { {{>methodBody}}{{! prevent indent}} }{{/skipDefaultDelegateInterface}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache index c41d8c4b9a05..386a41479b5b 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache @@ -102,12 +102,12 @@ interface {{classname}} { produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}}, consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}} ) - {{#reactive}}{{^isArray}}suspend {{/isArray}}{{#isArray}}{{^useFlowForArrayReturnType}}suspend {{/useFlowForArrayReturnType}}{{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultApiInterface}} { + {{#reactive}}{{^isArray}}suspend {{/isArray}}{{#isArray}}{{^useFlowForArrayReturnType}}suspend {{/useFlowForArrayReturnType}}{{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, {{/hasParams}}{{#swagger1AnnotationLibrary}}@ApiParam(hidden = true) {{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true) {{/swagger2AnnotationLibrary}}{{#reactive}}exchange: org.springframework.web.server.ServerWebExchange{{/reactive}}{{^reactive}}request: {{javaxPackage}}.servlet.http.HttpServletRequest{{/reactive}}{{/includeHttpRequestContext}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultApiInterface}} { {{^isDelegate}} return {{>returnValue}} {{/isDelegate}} {{#isDelegate}} - return getDelegate().{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}) + return getDelegate().{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, {{/hasParams}}{{#reactive}}exchange{{/reactive}}{{^reactive}}request{{/reactive}}{{/includeHttpRequestContext}}) {{/isDelegate}} }{{/skipDefaultApiInterface}} {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/api_test.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/api_test.mustache index bf35157acc97..32b1134d7e46 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api_test.mustache @@ -29,7 +29,8 @@ class {{classname}}Test { {{#allParams}} val {{{paramName}}}: {{>optionalDataType}} = TODO() {{/allParams}} - val response: ResponseEntity<{{>returnTypes}}> = api.{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}) + {{#includeHttpRequestContext}}val {{#reactive}}exchange: org.springframework.web.server.ServerWebExchange{{/reactive}}{{^reactive}}request: {{javaxPackage}}.servlet.http.HttpServletRequest{{/reactive}} = TODO(){{/includeHttpRequestContext}} + val response: ResponseEntity<{{>returnTypes}}> = api.{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, {{/hasParams}}{{#reactive}}exchange{{/reactive}}{{^reactive}}request{{/reactive}}{{/includeHttpRequestContext}}) // TODO: test validations } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java index 9f11b2fce037..b0b0396a2ab9 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/TestUtils.java @@ -173,7 +173,7 @@ public static void assertFileContains(Path path, String... lines) { String file = linearize(generatedFile); assertNotNull(file); for (String line : lines) - assertTrue(file.contains(linearize(line)), "File does not contain line [" + line + "]"); + assertTrue(file.contains(linearize(line)), "File '" + path + "' does not contain line [" + line + "]"); } catch (IOException e) { fail("Unable to evaluate file " + path); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index 4835aa65e8ec..5fc8f8800fd4 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -6,9 +6,6 @@ import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.parser.core.models.ParseOptions; -import java.util.HashMap; -import java.util.function.Consumer; -import java.util.stream.Stream; import org.apache.commons.io.FileUtils; import org.assertj.core.api.Assertions; import org.jetbrains.annotations.NotNull; @@ -34,10 +31,13 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static org.openapitools.codegen.TestUtils.assertFileContains; @@ -372,7 +372,6 @@ public void delegateReactiveWithTags() throws Exception { "ApiUtil"); } - @Test public void testNullableMultipartFile() throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -440,7 +439,6 @@ public void arrayItemsCanBeNullable() throws IOException { assertFileContains(Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/ArrayWithNullableItemsModel.kt"), "List"); } - @Test public void doNotGenerateRequestParamForObjectQueryParam() throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -693,12 +691,12 @@ private static void testMultiLineOperationDescription(final boolean isInterfaceO Paths.get( outputPath + "/src/main/kotlin/org/openapitools/api/" + pingApiFileName), "description = \"\"\"# Multi-line descriptions\n" - + "\n" - + "This is an example of a multi-line description.\n" - + "\n" - + "It:\n" - + "- has multiple lines\n" - + "- uses Markdown (CommonMark) for rich text representation\"\"\"" + + "\n" + + "This is an example of a multi-line description.\n" + + "\n" + + "It:\n" + + "- has multiple lines\n" + + "- uses Markdown (CommonMark) for rich text representation\"\"\"" ); } @@ -817,10 +815,10 @@ public void contractWithEnumContainsEnumConverter() throws IOException { @Test public void contractWithResolvedInnerEnumContainsEnumConverter() throws IOException { Map files = generateFromContract( - "src/test/resources/3_0/inner_enum.yaml", - new HashMap<>(), - new HashMap<>(), - configurator -> configurator.addInlineSchemaOption("RESOLVE_INLINE_ENUMS", "true") + "src/test/resources/3_0/inner_enum.yaml", + new HashMap<>(), + new HashMap<>(), + configurator -> configurator.addInlineSchemaOption("RESOLVE_INLINE_ENUMS", "true") ); File enumConverterFile = files.get("EnumConverterConfiguration.kt"); @@ -864,7 +862,6 @@ public void givenMultipartFormArray_whenGenerateDelegateAndService_thenParameter Path controllerFile = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PetApi.kt"); assertFileContains(controllerFile, "images: Array"); - Path serviceFile = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PetApiService.kt"); assertFileContains(serviceFile, "images: Array"); } @@ -994,6 +991,7 @@ public void generateSerializableModel() throws Exception { "private const val serialVersionUID: kotlin.Long = 1" ); } + @Test public void generateSerializableModelWithXimplements() throws Exception { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -1064,6 +1062,1051 @@ public void generateNonSerializableModelWithXimplements() throws Exception { ); } + private Path generateApiSources( + Map additionalProperties, + Map generatorPropertyDefaults + ) throws Exception { + File outputDir = Files.createTempDirectory("test").toFile().getCanonicalFile(); + outputDir.deleteOnExit(); + String outputPath = outputDir.getAbsolutePath().replace('\\', '/'); + + KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen(); + codegen.setOutputDir(outputDir.getAbsolutePath()); + codegen.additionalProperties().putAll(additionalProperties); + + ClientOptInput input = new ClientOptInput() + .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore.yaml")) + .config(codegen); + + DefaultGenerator generator = new DefaultGenerator(); + for (var entry : generatorPropertyDefaults.entrySet()) { + generator.setGeneratorPropertyDefault(entry.getKey(), entry.getValue()); + } + generator.opts(input).generate(); + + return Paths.get(outputPath); + } + + private void verifyGeneratedFilesContain(Map> expectedSnippetsByPathsToFiles) { + for (var expectedSnippetsByPathToFile : expectedSnippetsByPathsToFiles.entrySet()) { + assertFileContains(expectedSnippetsByPathToFile.getKey(), expectedSnippetsByPathToFile.getValue().toArray(new String[0])); + } + + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationSwaggerNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(@Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange)") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationSwagger1NoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithoutHttpRequestContextControllerImplAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationSwaggerNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(@Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationSwagger1NoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithoutHttpRequestContextControllerImplAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationSwaggerNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationSwagger1NoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithoutHttpRequestContextInterfaceOnlyAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationSwaggerNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationSwagger1NoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationNoneNoDelegateWithApiTests() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.API_TESTS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/test/kotlin/org/openapitools/api/PetApiTest.kt"), List.of( + "val request: javax.servlet.http.HttpServletRequest = TODO()", + "api.deletePet(petId, apiKey, request)"), + root.resolve("src/test/kotlin/org/openapitools/api/UserApiTest.kt"), List.of( + "val request: javax.servlet.http.HttpServletRequest = TODO()", + "api.logoutUser(request)") + ) + ); + } + + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationNoneNoDelegateWithApiTests() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.API_TESTS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApiController.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiController.kt"), List.of( + "logoutUser(exchange: org.springframework.web.server.ServerWebExchange)"), + root.resolve("src/test/kotlin/org/openapitools/api/PetApiTest.kt"), List.of( + "val exchange: org.springframework.web.server.ServerWebExchange = TODO()", + "api.deletePet(petId, apiKey, exchange)"), + root.resolve("src/test/kotlin/org/openapitools/api/UserApiTest.kt"), List.of( + "val exchange: org.springframework.web.server.ServerWebExchange = TODO()", + "api.logoutUser(exchange)") + ) + ); + } + + @Test + public void nonReactiveWithoutHttpRequestContextInterfaceOnlyAnnotationNoneNoDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, false + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationSwaggerDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationSwagger1Delegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextControllerImplAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithoutHttpRequestContextControllerImplAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "apiKey: kotlin.String?): ResponseEntity", + "petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "(): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationSwaggerDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationSwagger1Delegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextControllerImplAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithoutHttpRequestContextControllerImplAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, false, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "apiKey: kotlin.String?): ResponseEntity", + "petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "(): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationSwaggerDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationSwagger1Delegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithHttpRequestContextInterfaceOnlyAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity", + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity") + ) + ); + } + + @Test + public void reactiveWithoutHttpRequestContextInterfaceOnlyAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, true, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "apiKey: kotlin.String?): ResponseEntity", + "petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "(): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationSwaggerDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger2", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@Parameter(description = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@Parameter(description = \"\", `in` = ParameterIn.HEADER) @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@Parameter(description = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@Parameter(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationSwagger1Delegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "swagger1", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet(@ApiParam(value = \"Pet id to delete\", required = true) @PathVariable(\"petId\") petId: kotlin.Long,@ApiParam(value = \"\") @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById(@ApiParam(value = \"ID of pet to return\", required = true) @PathVariable(\"petId\") petId: kotlin.Long, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithHttpRequestContextInterfaceOnlyAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, true, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?, request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long, request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity", + "request: javax.servlet.http.HttpServletRequest): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "request: javax.servlet.http.HttpServletRequest): ResponseEntity") + ) + ); + } + + @Test + public void nonReactiveWithoutHttpRequestContextInterfaceOnlyAnnotationNoneDelegate() throws Exception { + Path root = generateApiSources(Map.of( + KotlinSpringServerCodegen.INCLUDE_HTTP_REQUEST_CONTEXT, false, + KotlinSpringServerCodegen.REACTIVE, false, + KotlinSpringServerCodegen.DOCUMENTATION_PROVIDER, "none", + KotlinSpringServerCodegen.ANNOTATION_LIBRARY, "none", + KotlinSpringServerCodegen.INTERFACE_ONLY, true, + KotlinSpringServerCodegen.DELEGATE_PATTERN, true + ), Map.of( + CodegenConstants.MODELS, "false", + CodegenConstants.MODEL_TESTS, "false", + CodegenConstants.MODEL_DOCS, "false", + CodegenConstants.APIS, "true", + CodegenConstants.SUPPORTING_FILES, "false" + )); + verifyGeneratedFilesContain( + Map.of( + root.resolve("src/main/kotlin/org/openapitools/api/PetApi.kt"), List.of( + "deletePet( @PathVariable(\"petId\") petId: kotlin.Long, @RequestHeader(value = \"api_key\", required = false) apiKey: kotlin.String?): ResponseEntity", + "getPetById( @PathVariable(\"petId\") petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApi.kt"), List.of( + "logoutUser(): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/PetApiDelegate.kt"), List.of( + "apiKey: kotlin.String?): ResponseEntity", + "petId: kotlin.Long): ResponseEntity"), + root.resolve("src/main/kotlin/org/openapitools/api/UserApiDelegate.kt"), List.of( + "(): ResponseEntity") + ) + ); + } + @Test public void reactiveWithoutFlow() throws Exception { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); @@ -1346,43 +2389,43 @@ public void testValidationsInQueryParams_issue21238_Api_Delegate() throws IOExce @DataProvider public Object[][] issue17997DocumentationProviders() { - return new Object[][]{ - {DocumentationProviderFeatures.DocumentationProvider.SPRINGDOC.name(), - (Consumer) outputPath -> - assertFileContains( - outputPath, - "allowableValues = [\"0\", \"1\"], defaultValue = \"0\"", - "@PathVariable" - ), - (Consumer) outputPath -> - assertFileContains( - outputPath, - "allowableValues = [\"sleeping\", \"awake\"]", "@PathVariable", - "@PathVariable" - ) - }, - {DocumentationProviderFeatures.DocumentationProvider.SPRINGFOX.name(), - (Consumer) outputPath -> - assertFileContains( - outputPath, - "allowableValues = \"0, 1\", defaultValue = \"0\"", - "@PathVariable" - ), - (Consumer) outputPath -> - assertFileContains( - outputPath, - "allowableValues = \"sleeping, awake\"", "@PathVariable", - "@PathVariable" - ) - } + return new Object[][] { + { DocumentationProviderFeatures.DocumentationProvider.SPRINGDOC.name(), + (Consumer) outputPath -> + assertFileContains( + outputPath, + "allowableValues = [\"0\", \"1\"], defaultValue = \"0\"", + "@PathVariable" + ), + (Consumer) outputPath -> + assertFileContains( + outputPath, + "allowableValues = [\"sleeping\", \"awake\"]", "@PathVariable", + "@PathVariable" + ) + }, + { DocumentationProviderFeatures.DocumentationProvider.SPRINGFOX.name(), + (Consumer) outputPath -> + assertFileContains( + outputPath, + "allowableValues = \"0, 1\", defaultValue = \"0\"", + "@PathVariable" + ), + (Consumer) outputPath -> + assertFileContains( + outputPath, + "allowableValues = \"sleeping, awake\"", "@PathVariable", + "@PathVariable" + ) + } }; } @Test(dataProvider = "issue17997DocumentationProviders") public void testDocumentationAnnotationInPathParams_Issue17997( - String documentProvider, - Consumer intEnumAssertFunction, - Consumer stringEnumAssertFunction + String documentProvider, + Consumer intEnumAssertFunction, + Consumer stringEnumAssertFunction ) throws IOException { Map additionalProperties = new HashMap<>(); additionalProperties.put(DOCUMENTATION_PROVIDER, documentProvider); @@ -1393,14 +2436,14 @@ public void testDocumentationAnnotationInPathParams_Issue17997( generatorPropertyDefaults.put(CodegenConstants.APIS, "true"); Map files = generateFromContract( - "src/test/resources/3_0/issue_6762.yaml", - additionalProperties, - generatorPropertyDefaults + "src/test/resources/3_0/issue_6762.yaml", + additionalProperties, + generatorPropertyDefaults ); Stream.of( - "ZebrasApiController.kt", - "GiraffesApiController.kt" + "ZebrasApiController.kt", + "GiraffesApiController.kt" ).forEach(filename -> { File file = files.get(filename); assertThat(file).isNotNull(); @@ -1408,8 +2451,8 @@ public void testDocumentationAnnotationInPathParams_Issue17997( }); Stream.of( - "BearsApiController.kt", - "CamelsApiController.kt" + "BearsApiController.kt", + "CamelsApiController.kt" ).forEach(filename -> { File file = files.get(filename); assertThat(file).isNotNull(); @@ -1708,13 +2751,13 @@ public void testXMinimumMessageAndXMaximumMessage_long() throws IOException { .assertParameter("number") .assertParameterAnnotation("Min") .hasAttributes(ImmutableMap.of( - "value", "1L", + "value", "1L", "message", "\"Must be positive\"" )) .toParameter() .assertParameterAnnotation("Max") .hasAttributes(ImmutableMap.of( - "value", "99L", + "value", "99L", "message", "\"Must be less than 100\"" )) .toParameter() @@ -1722,13 +2765,13 @@ public void testXMinimumMessageAndXMaximumMessage_long() throws IOException { .assertParameter("token") .assertParameterAnnotation("Min") .hasAttributes(ImmutableMap.of( - "value", "1L", + "value", "1L", "message", "\"Must be positive\"" )) .toParameter() .assertParameterAnnotation("Max") .hasAttributes(ImmutableMap.of( - "value", "99L", + "value", "99L", "message", "\"Must be less than 100\"" )) .toParameter() @@ -1736,13 +2779,13 @@ public void testXMinimumMessageAndXMaximumMessage_long() throws IOException { .assertParameter("clientNumber") .assertParameterAnnotation("Min") .hasAttributes(ImmutableMap.of( - "value", "1L", + "value", "1L", "message", "\"Must be positive\"" )) .toParameter() .assertParameterAnnotation("Max") .hasAttributes(ImmutableMap.of( - "value", "99L", + "value", "99L", "message", "\"Must be less than 100\"" )); KotlinFileAssert.assertThat(files.get("LongTest.kt")) @@ -1750,13 +2793,13 @@ public void testXMinimumMessageAndXMaximumMessage_long() throws IOException { .assertPrimaryConstructorParameter("field1") .assertParameterAnnotation("Min", "get") .hasAttributes(ImmutableMap.of( - "value", "1L", + "value", "1L", "message", "\"Must be positive\"" )) .toPrimaryConstructorParameter() .assertParameterAnnotation("Max", "get") .hasAttributes(ImmutableMap.of( - "value", "99L", + "value", "99L", "message", "\"Must be less than 100\"" )) .toPrimaryConstructorParameter() @@ -1778,9 +2821,9 @@ private Map generateFromContract(String url, Map a } private Map generateFromContract( - String url, - Map additionalProperties, - Map generatorPropertyDefaults + String url, + Map additionalProperties, + Map generatorPropertyDefaults ) throws IOException { return generateFromContract(url, additionalProperties, generatorPropertyDefaults, codegen -> { }); @@ -1792,22 +2835,22 @@ private Map generateFromContract( * use CodegenConfigurator instead of CodegenConfig for easier configuration like in JavaClientCodeGenTest */ private Map generateFromContract( - String url, - Map additionalProperties, - Map generatorPropertyDefaults, - Consumer consumer + String url, + Map additionalProperties, + Map generatorPropertyDefaults, + Consumer consumer ) throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); output.deleteOnExit(); final CodegenConfigurator configurator = new CodegenConfigurator() - .setGeneratorName("kotlin-spring") - .setAdditionalProperties(additionalProperties) - .setValidateSpec(false) - .setInputSpec(url) - .setLibrary(SPRING_BOOT) - .setOutputDir(output.getAbsolutePath()); + .setGeneratorName("kotlin-spring") + .setAdditionalProperties(additionalProperties) + .setValidateSpec(false) + .setInputSpec(url) + .setLibrary(SPRING_BOOT) + .setOutputDir(output.getAbsolutePath()); consumer.accept(configurator); @@ -1817,6 +2860,6 @@ private Map generateFromContract( generatorPropertyDefaults.forEach(generator::setGeneratorPropertyDefault); return generator.opts(input).generate().stream() - .collect(Collectors.toMap(File::getName, Function.identity())); + .collect(Collectors.toMap(File::getName, Function.identity())); } } diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator-ignore b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/FILES b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/FILES new file mode 100644 index 000000000000..8b73d6497e4f --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/FILES @@ -0,0 +1,30 @@ +README.md +build.gradle.kts +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/kotlin/org/openapitools/Application.kt +src/main/kotlin/org/openapitools/api/ApiUtil.kt +src/main/kotlin/org/openapitools/api/PetApi.kt +src/main/kotlin/org/openapitools/api/PetApiController.kt +src/main/kotlin/org/openapitools/api/PetApiDelegate.kt +src/main/kotlin/org/openapitools/api/StoreApi.kt +src/main/kotlin/org/openapitools/api/StoreApiController.kt +src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt +src/main/kotlin/org/openapitools/api/UserApi.kt +src/main/kotlin/org/openapitools/api/UserApiController.kt +src/main/kotlin/org/openapitools/api/UserApiDelegate.kt +src/main/kotlin/org/openapitools/configuration/EnumConverterConfiguration.kt +src/main/kotlin/org/openapitools/model/Cat.kt +src/main/kotlin/org/openapitools/model/Category.kt +src/main/kotlin/org/openapitools/model/Color.kt +src/main/kotlin/org/openapitools/model/Dog.kt +src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +src/main/kotlin/org/openapitools/model/Order.kt +src/main/kotlin/org/openapitools/model/Pet.kt +src/main/kotlin/org/openapitools/model/Tag.kt +src/main/kotlin/org/openapitools/model/User.kt +src/main/resources/application.yaml diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/VERSION b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/VERSION new file mode 100644 index 000000000000..2fb556b60635 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.18.0-SNAPSHOT diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/README.md b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/README.md new file mode 100644 index 000000000000..b6865a081135 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/README.md @@ -0,0 +1,21 @@ +# openAPIPetstore + +This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator). + +## Getting Started + +This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in. + +By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl). + +To build the project using maven, run: +```bash +mvn package && java -jar target/openapi-spring-1.0.0.jar +``` + +To build the project using gradle, run: +```bash +gradle build && java -jar build/libs/openapi-spring-1.0.0.jar +``` + +If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/) diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts new file mode 100644 index 000000000000..e78a961d4091 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts @@ -0,0 +1,53 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.7") + } +} + +group = "org.openapitools" +version = "1.0.0" + +repositories { + mavenCentral() +} + +tasks.withType { + kotlinOptions.jvmTarget = "11" +} + +plugins { + val kotlinVersion = "1.9.25" + id("org.jetbrains.kotlin.jvm") version kotlinVersion + id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion + id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion + id("org.springframework.boot") version "2.6.7" + id("io.spring.dependency-management") version "1.0.11.RELEASE" +} + +dependencies { + val kotlinxCoroutinesVersion = "1.6.1" + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.springframework.boot:spring-boot-starter-webflux") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion") + implementation("io.swagger:swagger-annotations:1.6.6") + + implementation("com.google.code.findbugs:jsr305:3.0.2") + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") + testImplementation("org.springframework.boot:spring-boot-starter-test") { + exclude(module = "junit") + } + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion") +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.jar b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..e6441136f3d4 Binary files /dev/null and b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.properties b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..80187ac30432 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew new file mode 100644 index 000000000000..9d0ce634cb11 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew.bat b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew.bat new file mode 100644 index 000000000000..25da30dbdeee --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml new file mode 100644 index 000000000000..1e85d34a2f9e --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml @@ -0,0 +1,148 @@ + + 4.0.0 + org.openapitools + openapi-spring + jar + openapi-spring + 1.0.0 + + 1.6.1 + 1.6.6 + 3.0.2 + 1.3.2 + 1.6.21 + + 1.6.21 + UTF-8 + + + org.springframework.boot + spring-boot-starter-parent + 2.7.15 + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + spring + + 11 + + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.springframework.boot + spring-boot-starter-webflux + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + ${kotlinx-coroutines.version} + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + ${kotlinx-coroutines.version} + + + + + io.swagger + swagger-annotations + ${swagger-annotations.version} + + + + + com.google.code.findbugs + jsr305 + ${findbugs-jsr305.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + javax.validation + validation-api + + + javax.annotation + javax.annotation-api + ${javax-annotation.version} + provided + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin-test-junit5.version} + test + + + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/settings.gradle b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/settings.gradle new file mode 100644 index 000000000000..14844905cd40 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/settings.gradle @@ -0,0 +1,15 @@ +pluginManagement { + repositories { + maven { url = uri("https://repo.spring.io/snapshot") } + maven { url = uri("https://repo.spring.io/milestone") } + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "org.springframework.boot") { + useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}") + } + } + } +} +rootProject.name = "openapi-spring" diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Fetchable.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Fetchable.kt new file mode 100644 index 000000000000..b8680298a112 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Fetchable.kt @@ -0,0 +1,6 @@ +package com.some.pack + +interface Fetchable { + + val likesFetch: Boolean +} \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Named.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Named.kt new file mode 100644 index 000000000000..2107a8487406 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/Named.kt @@ -0,0 +1,6 @@ +package com.some.pack + +interface Named { + + val name: String +} \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithCategory.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithCategory.kt new file mode 100644 index 000000000000..6689da898885 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithCategory.kt @@ -0,0 +1,6 @@ +package com.some.pack + +interface WithCategory { + + val category: org.openapitools.model.Category? +} \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithDefaultMethods.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithDefaultMethods.kt new file mode 100644 index 000000000000..34acc9513573 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/com/some/pack/WithDefaultMethods.kt @@ -0,0 +1,12 @@ +package com.some.pack + +interface WithDefaultMethods { + + fun defaultMethodOne(): String { + return "defaultOne" + } + + fun defaultMethodTwo(): Int { + return 2 + } +} \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt new file mode 100644 index 000000000000..2fe6de62479e --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -0,0 +1,13 @@ +package org.openapitools + +import org.springframework.boot.runApplication +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan + +@SpringBootApplication +@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) +class Application + +fun main(args: Array) { + runApplication(*args) +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/ApiUtil.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/ApiUtil.kt new file mode 100644 index 000000000000..7c275cbf30ed --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/ApiUtil.kt @@ -0,0 +1,5 @@ +package org.openapitools.api + + +object ApiUtil { +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt new file mode 100644 index 000000000000..a5484ab149dd --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -0,0 +1,188 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.18.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.ModelApiResponse +import org.openapitools.model.Pet +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid + +import kotlinx.coroutines.flow.Flow +import kotlin.collections.List +import kotlin.collections.Map + +@RestController +@Validated +@Api(value = "pet", description = "The pet API") +interface PetApi { + + fun getDelegate(): PetApiDelegate + + + @ApiOperation( + value = "Add a new pet to the store", + nickname = "addPet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 405, message = "Invalid input")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet"], + consumes = ["application/json"] + ) + suspend fun addPet(@ApiParam(value = "", required = true) @Valid @RequestBody pet: Pet, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().addPet(pet, exchange) + } + + + @ApiOperation( + value = "Deletes a pet", + nickname = "deletePet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid pet value")]) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/pet/{petId}"] + ) + suspend fun deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().deletePet(petId, apiKey, exchange) + } + + + @ApiOperation( + value = "Finds Pets by status", + nickname = "findPetsByStatus", + notes = "Multiple status values can be provided with comma separated strings", + response = Pet::class, + responseContainer = "List", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"), ApiResponse(code = 400, message = "Invalid status value")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/findByStatus"], + produces = ["application/json"] + ) + fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> { + return getDelegate().findPetsByStatus(status, exchange) + } + + + @ApiOperation( + value = "Finds Pets by tags", + nickname = "findPetsByTags", + notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + response = Pet::class, + responseContainer = "List", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"), ApiResponse(code = 400, message = "Invalid tag value")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/findByTags"], + produces = ["application/json"] + ) + fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> { + return getDelegate().findPetsByTags(tags, exchange) + } + + + @ApiOperation( + value = "Find pet by ID", + nickname = "getPetById", + notes = "Returns a single pet", + response = Pet::class, + authorizations = [Authorization(value = "api_key")]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class), ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Pet not found")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/pet/{petId}"], + produces = ["application/json"] + ) + suspend fun getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().getPetById(petId, exchange) + } + + + @ApiOperation( + value = "Update an existing pet", + nickname = "updatePet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Pet not found"), ApiResponse(code = 405, message = "Validation exception")]) + @RequestMapping( + method = [RequestMethod.PUT], + value = ["/pet"], + consumes = ["application/json"] + ) + suspend fun updatePet(@ApiParam(value = "", required = true) @Valid @RequestBody pet: Pet, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().updatePet(pet, exchange) + } + + + @ApiOperation( + value = "Updates a pet in the store with form data", + nickname = "updatePetWithForm", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 405, message = "Invalid input")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet/{petId}"], + consumes = ["application/x-www-form-urlencoded"] + ) + suspend fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) name: kotlin.String? ,@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) status: kotlin.String? , @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().updatePetWithForm(petId, name, status, exchange) + } + + + @ApiOperation( + value = "Uploads an image", + nickname = "uploadFile", + notes = "", + response = ModelApiResponse::class, + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/pet/{petId}/uploadImage"], + produces = ["application/json"], + consumes = ["multipart/form-data"] + ) + suspend fun uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "") @Valid @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@ApiParam(value = "file detail") @Valid @RequestPart("file", required = false) file: org.springframework.web.multipart.MultipartFile, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().uploadFile(petId, additionalMetadata, file, exchange) + } +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiController.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiController.kt new file mode 100644 index 000000000000..c4f47748e1c3 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiController.kt @@ -0,0 +1,15 @@ +package org.openapitools.api + +import org.springframework.stereotype.Controller +import org.springframework.web.bind.annotation.RequestMapping +import java.util.Optional + +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +@Controller +@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}") +class PetApiController( + private val delegate: PetApiDelegate +) : PetApi { + + override fun getDelegate(): PetApiDelegate = delegate +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt new file mode 100644 index 000000000000..c9d93bde1fe8 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/PetApiDelegate.kt @@ -0,0 +1,82 @@ +package org.openapitools.api + +import org.openapitools.model.ModelApiResponse +import org.openapitools.model.Pet +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.web.context.request.NativeWebRequest +import kotlinx.coroutines.flow.Flow + +import java.util.Optional + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +interface PetApiDelegate { + + fun getRequest(): Optional = Optional.empty() + + /** + * @see PetApi#addPet + */ + suspend fun addPet(pet: Pet, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see PetApi#deletePet + */ + suspend fun deletePet(petId: kotlin.Long, + apiKey: kotlin.String?, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see PetApi#findPetsByStatus + */ + fun findPetsByStatus(status: kotlin.collections.List, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> + + + /** + * @see PetApi#findPetsByTags + */ + fun findPetsByTags(tags: kotlin.collections.List, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> + + + /** + * @see PetApi#getPetById + */ + suspend fun getPetById(petId: kotlin.Long, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see PetApi#updatePet + */ + suspend fun updatePet(pet: Pet, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see PetApi#updatePetWithForm + */ + suspend fun updatePetWithForm(petId: kotlin.Long, + name: kotlin.String?, + status: kotlin.String?, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see PetApi#uploadFile + */ + suspend fun uploadFile(petId: kotlin.Long, + additionalMetadata: kotlin.String?, + file: org.springframework.web.multipart.MultipartFile, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt new file mode 100644 index 000000000000..8b42f54741f0 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -0,0 +1,114 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.18.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.Order +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid + +import kotlinx.coroutines.flow.Flow +import kotlin.collections.List +import kotlin.collections.Map + +@RestController +@Validated +@Api(value = "store", description = "The store API") +interface StoreApi { + + fun getDelegate(): StoreApiDelegate + + + @ApiOperation( + value = "Delete purchase order by ID", + nickname = "deleteOrder", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Order not found")]) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/store/order/{orderId}"] + ) + suspend fun deleteOrder(@ApiParam(value = "", required = true) @PathVariable("orderId") orderId: kotlin.String, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().deleteOrder(orderId, exchange) + } + + + @ApiOperation( + value = "Returns pet inventories by status", + nickname = "getInventory", + notes = "", + response = kotlin.Int::class, + responseContainer = "Map", + authorizations = [Authorization(value = "api_key")]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/store/inventory"], + produces = ["application/json"] + ) + suspend fun getInventory(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> { + return getDelegate().getInventory(exchange) + } + + + @ApiOperation( + value = "Find purchase order by ID", + nickname = "getOrderById", + notes = "", + response = Order::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Order::class), ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Order not found")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/store/order/{orderId}"], + produces = ["application/json"] + ) + suspend fun getOrderById(@Min(value=1) @Max(value=5) @ApiParam(value = "", required = true) @PathVariable("orderId") orderId: kotlin.Int, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().getOrderById(orderId, exchange) + } + + + @ApiOperation( + value = "Place an order for a pet", + nickname = "placeOrder", + notes = "", + response = Order::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Order::class), ApiResponse(code = 400, message = "Invalid Order")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/store/order"], + produces = ["application/json"], + consumes = ["application/json"] + ) + suspend fun placeOrder(@ApiParam(value = "", required = true) @Valid @RequestBody order: Order, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().placeOrder(order, exchange) + } +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiController.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiController.kt new file mode 100644 index 000000000000..316f31b0355f --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiController.kt @@ -0,0 +1,15 @@ +package org.openapitools.api + +import org.springframework.stereotype.Controller +import org.springframework.web.bind.annotation.RequestMapping +import java.util.Optional + +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +@Controller +@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}") +class StoreApiController( + private val delegate: StoreApiDelegate +) : StoreApi { + + override fun getDelegate(): StoreApiDelegate = delegate +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt new file mode 100644 index 000000000000..5064c218471f --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/StoreApiDelegate.kt @@ -0,0 +1,47 @@ +package org.openapitools.api + +import org.openapitools.model.Order +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.web.context.request.NativeWebRequest +import kotlinx.coroutines.flow.Flow + +import java.util.Optional + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +interface StoreApiDelegate { + + fun getRequest(): Optional = Optional.empty() + + /** + * @see StoreApi#deleteOrder + */ + suspend fun deleteOrder(orderId: kotlin.String, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see StoreApi#getInventory + */ + suspend fun getInventory(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity> + + + /** + * @see StoreApi#getOrderById + */ + suspend fun getOrderById(orderId: kotlin.Int, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see StoreApi#placeOrder + */ + suspend fun placeOrder(order: Order, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt new file mode 100644 index 000000000000..8cddc539266b --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -0,0 +1,173 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.18.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.User +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid + +import kotlinx.coroutines.flow.Flow +import kotlin.collections.List +import kotlin.collections.Map + +@RestController +@Validated +@Api(value = "user", description = "The user API") +interface UserApi { + + fun getDelegate(): UserApiDelegate + + + @ApiOperation( + value = "Create user", + nickname = "createUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user"], + consumes = ["application/json"] + ) + suspend fun createUser(@ApiParam(value = "", required = true) @Valid @RequestBody user: User, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().createUser(user, exchange) + } + + + @ApiOperation( + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user/createWithArray"], + consumes = ["application/json"] + ) + suspend fun createUsersWithArrayInput(@ApiParam(value = "", required = true) @Valid @RequestBody user: Flow, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().createUsersWithArrayInput(user, exchange) + } + + + @ApiOperation( + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) + @RequestMapping( + method = [RequestMethod.POST], + value = ["/user/createWithList"], + consumes = ["application/json"] + ) + suspend fun createUsersWithListInput(@ApiParam(value = "", required = true) @Valid @RequestBody user: Flow, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().createUsersWithListInput(user, exchange) + } + + + @ApiOperation( + value = "Delete user", + nickname = "deleteUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid username supplied"), ApiResponse(code = 404, message = "User not found")]) + @RequestMapping( + method = [RequestMethod.DELETE], + value = ["/user/{username}"] + ) + suspend fun deleteUser(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().deleteUser(username, exchange) + } + + + @ApiOperation( + value = "Get user by user name", + nickname = "getUserByName", + notes = "", + response = User::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = User::class), ApiResponse(code = 400, message = "Invalid username supplied"), ApiResponse(code = 404, message = "User not found")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/{username}"], + produces = ["application/json"] + ) + suspend fun getUserByName(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().getUserByName(username, exchange) + } + + + @ApiOperation( + value = "Logs user into the system", + nickname = "loginUser", + notes = "", + response = kotlin.String::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.String::class), ApiResponse(code = 400, message = "Invalid username/password supplied")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/login"], + produces = ["application/json"] + ) + suspend fun loginUser(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().loginUser(username, password, exchange) + } + + + @ApiOperation( + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) + @RequestMapping( + method = [RequestMethod.GET], + value = ["/user/logout"] + ) + suspend fun logoutUser(@ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().logoutUser(exchange) + } + + + @ApiOperation( + value = "Updated user", + nickname = "updateUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid user supplied"), ApiResponse(code = 404, message = "User not found")]) + @RequestMapping( + method = [RequestMethod.PUT], + value = ["/user/{username}"], + consumes = ["application/json"] + ) + suspend fun updateUser(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String,@ApiParam(value = "", required = true) @Valid @RequestBody user: User, @ApiParam(hidden = true) exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity { + return getDelegate().updateUser(username, user, exchange) + } +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiController.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiController.kt new file mode 100644 index 000000000000..39b95316c830 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiController.kt @@ -0,0 +1,15 @@ +package org.openapitools.api + +import org.springframework.stereotype.Controller +import org.springframework.web.bind.annotation.RequestMapping +import java.util.Optional + +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +@Controller +@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}") +class UserApiController( + private val delegate: UserApiDelegate +) : UserApi { + + override fun getDelegate(): UserApiDelegate = delegate +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt new file mode 100644 index 000000000000..2a88c82d8d3c --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/api/UserApiDelegate.kt @@ -0,0 +1,77 @@ +package org.openapitools.api + +import org.openapitools.model.User +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.web.context.request.NativeWebRequest +import kotlinx.coroutines.flow.Flow + +import java.util.Optional + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.18.0-SNAPSHOT") +interface UserApiDelegate { + + fun getRequest(): Optional = Optional.empty() + + /** + * @see UserApi#createUser + */ + suspend fun createUser(user: User, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#createUsersWithArrayInput + */ + suspend fun createUsersWithArrayInput(user: Flow, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#createUsersWithListInput + */ + suspend fun createUsersWithListInput(user: Flow, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#deleteUser + */ + suspend fun deleteUser(username: kotlin.String, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#getUserByName + */ + suspend fun getUserByName(username: kotlin.String, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#loginUser + */ + suspend fun loginUser(username: kotlin.String, + password: kotlin.String, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#logoutUser + */ + suspend fun logoutUser(exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + + + /** + * @see UserApi#updateUser + */ + suspend fun updateUser(username: kotlin.String, + user: User, + exchange: org.springframework.web.server.ServerWebExchange): ResponseEntity + +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/configuration/EnumConverterConfiguration.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/configuration/EnumConverterConfiguration.kt new file mode 100644 index 000000000000..20229410386f --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/configuration/EnumConverterConfiguration.kt @@ -0,0 +1,26 @@ +package org.openapitools.configuration + +import org.openapitools.model.Color + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.core.convert.converter.Converter + +/** + * This class provides Spring Converter beans for the enum models in the OpenAPI specification. + * + * By default, Spring only converts primitive types to enums using Enum::valueOf, which can prevent + * correct conversion if the OpenAPI specification is using an `enumPropertyNaming` other than + * `original` or the specification has an integer enum. + */ +@Configuration(value = "org.openapitools.configuration.enumConverterConfiguration") +class EnumConverterConfiguration { + + @Bean(name = ["org.openapitools.configuration.EnumConverterConfiguration.colorConverter"]) + fun colorConverter(): Converter { + return object: Converter { + override fun convert(source: kotlin.String): Color = Color.forValue(source) + } + } + +} diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt new file mode 100644 index 000000000000..ae9af1b803df --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt @@ -0,0 +1,66 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import org.openapitools.model.Category +import org.openapitools.model.Color +import org.openapitools.model.Pet +import org.openapitools.model.Tag +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param hunts + * @param age + */ +data class Cat( + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("name", required = true) override val name: kotlin.String, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("photoUrls", required = true) override val photoUrls: kotlin.collections.List, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("petType", required = true) override val petType: kotlin.String, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("hunts") val hunts: kotlin.Boolean? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("age") val age: kotlin.Int? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") override val id: kotlin.Long? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("category") override val category: Category? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("color") override val color: Color? = null +) : Pet, Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt new file mode 100644 index 000000000000..840851411bef --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt @@ -0,0 +1,36 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param id + * @param name + */ +data class Category( + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("name") val name: kotlin.String? = null +) : Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Color.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Color.kt new file mode 100644 index 000000000000..8be96cf72e17 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Color.kt @@ -0,0 +1,41 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** +* +* Values: black,white,brown,yellow,violet +*/ +enum class Color(@get:JsonValue val value: kotlin.String) : com.some.pack.WithDefaultMethods { + + black("black"), + white("white"), + brown("brown"), + yellow("yellow"), + violet("violet"); + + companion object { + @JvmStatic + @JsonCreator + fun forValue(value: kotlin.String): Color { + return values().firstOrNull{it -> it.value == value} + ?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Color'") + } + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt new file mode 100644 index 000000000000..cce5e8da3c12 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt @@ -0,0 +1,91 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import org.openapitools.model.Category +import org.openapitools.model.Color +import org.openapitools.model.Pet +import org.openapitools.model.Tag +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param bark + * @param breed + * @param likesFetch Whether the dog enjoys fetching + */ +data class Dog( + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("bark", required = true) val bark: kotlin.Boolean, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("breed", required = true) val breed: Dog.Breed, + + @ApiModelProperty(example = "null", required = true, value = "Whether the dog enjoys fetching") + @get:JsonProperty("likesFetch", required = true) override val likesFetch: kotlin.Boolean, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("name", required = true) override val name: kotlin.String, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("photoUrls", required = true) override val photoUrls: kotlin.collections.List, + + @ApiModelProperty(example = "null", required = true, value = "") + @get:JsonProperty("petType", required = true) override val petType: kotlin.String, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") override val id: kotlin.Long? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("category") override val category: Category? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, + + @field:Valid + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("color") override val color: Color? = null +) : Pet, Serializable, com.some.pack.Fetchable { + + /** + * + * Values: Dingo,Husky,Retriever,Shepherd + */ + enum class Breed(@get:JsonValue val value: kotlin.String) { + + Dingo("Dingo"), + Husky("Husky"), + Retriever("Retriever"), + Shepherd("Shepherd"); + + companion object { + @JvmStatic + @JsonCreator + fun forValue(value: kotlin.String): Breed { + return values().firstOrNull{it -> it.value == value} + ?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Dog'") + } + } + } + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt new file mode 100644 index 000000000000..adb4e8fb2fc1 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -0,0 +1,40 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param code + * @param type + * @param message + */ +data class ModelApiResponse( + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("code") val code: kotlin.Int? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("type") val type: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("message") val message: kotlin.String? = null +) : Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt new file mode 100644 index 000000000000..b6ddad1d9c75 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt @@ -0,0 +1,74 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param id + * @param petId + * @param quantity + * @param shipDate + * @param status + * @param complete + */ +data class Order( + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("petId") val petId: kotlin.Long? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("status") val status: Order.Status? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("complete") val complete: kotlin.Boolean? = false +) : Serializable { + + /** + * + * Values: placed,approved,delivered + */ + enum class Status(@get:JsonValue val value: kotlin.String) { + + placed("placed"), + approved("approved"), + delivered("delivered"); + + companion object { + @JvmStatic + @JsonCreator + fun forValue(value: kotlin.String): Status { + return values().firstOrNull{it -> it.value == value} + ?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Order'") + } + } + } + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt new file mode 100644 index 000000000000..a6a17770db12 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt @@ -0,0 +1,80 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSubTypes +import com.fasterxml.jackson.annotation.JsonTypeInfo +import com.fasterxml.jackson.annotation.JsonValue +import org.openapitools.model.Category +import org.openapitools.model.Color +import org.openapitools.model.Tag +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param name + * @param photoUrls + * @param petType + * @param id + * @param category + * @param tags + * @param color + */ +@JsonIgnoreProperties( + value = ["petType"], // ignore manually set petType, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the petType to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "petType", visible = true) +@JsonSubTypes( + JsonSubTypes.Type(value = Cat::class, name = "Cat"), + JsonSubTypes.Type(value = Dog::class, name = "Dog") +) + +interface Pet : Serializable, com.some.pack.Named, com.some.pack.WithCategory, com.some.pack.WithDefaultMethods { + + @get:ApiModelProperty(example = "null", required = true, value = "") + override val name: kotlin.String + + + @get:ApiModelProperty(example = "null", required = true, value = "") + val photoUrls: kotlin.collections.List + + + @get:ApiModelProperty(example = "null", required = true, value = "") + val petType: kotlin.String + + + @get:ApiModelProperty(example = "null", value = "") + val id: kotlin.Long? + + + @get:ApiModelProperty(example = "null", value = "") + override val category: Category? + + + @get:ApiModelProperty(example = "null", value = "") + val tags: kotlin.collections.List? + + + @get:ApiModelProperty(example = "null", value = "") + val color: Color? + + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt new file mode 100644 index 000000000000..23d0f3191596 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt @@ -0,0 +1,36 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param id + * @param name + */ +data class Tag( + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("name") val name: kotlin.String? = null +) : Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt new file mode 100644 index 000000000000..9399e70b2527 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt @@ -0,0 +1,60 @@ +package org.openapitools.model + +import java.util.Locale +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.Serializable +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.Email +import javax.validation.constraints.Max +import javax.validation.constraints.Min +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty + +/** + * + * @param id + * @param username + * @param firstName + * @param lastName + * @param email + * @param password + * @param phone + * @param userStatus + */ +data class User( + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("id") val id: kotlin.Long? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("username") val username: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("email") val email: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("password") val password: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("phone") val phone: kotlin.String? = null, + + @ApiModelProperty(example = "null", value = "") + @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null +) : Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/resources/application.yaml b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/resources/application.yaml new file mode 100644 index 000000000000..8e2ebcde976d --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/resources/application.yaml @@ -0,0 +1,10 @@ +spring: + application: + name: openAPIPetstore + + jackson: + serialization: + WRITE_DATES_AS_TIMESTAMPS: false + +server: + port: 8080 diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts index f0cd582d7879..10a80f14f0ff 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts @@ -37,6 +37,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.springframework.boot:spring-boot-starter-web") + implementation("io.swagger:swagger-annotations:1.6.6") implementation("com.google.code.findbugs:jsr305:3.0.2") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml index 54f4f6767beb..067cb2bbd025 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml @@ -6,6 +6,7 @@ openapi-spring 1.0.0 + 1.6.6 3.0.2 1.3.2 1.6.21 @@ -87,6 +88,11 @@ + + io.swagger + swagger-annotations + ${swagger-annotations.version} + diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt index e83175693b7c..e40570844574 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -7,6 +7,13 @@ package org.openapitools.api import org.openapitools.model.ModelApiResponse import org.openapitools.model.Pet +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -31,69 +38,132 @@ import kotlin.collections.Map @RestController @Validated +@Api(value = "pet", description = "The pet API") interface PetApi { + @ApiOperation( + value = "Add a new pet to the store", + nickname = "addPet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 405, message = "Invalid input")]) @RequestMapping( method = [RequestMethod.POST], value = ["/pet"], consumes = ["application/json"] ) - fun addPet( @Valid @RequestBody pet: Pet): ResponseEntity + fun addPet(@ApiParam(value = "", required = true) @Valid @RequestBody pet: Pet, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Deletes a pet", + nickname = "deletePet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid pet value")]) @RequestMapping( method = [RequestMethod.DELETE], value = ["/pet/{petId}"] ) - fun deletePet( @PathVariable("petId") petId: kotlin.Long, @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?): ResponseEntity - - + fun deletePet(@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + + + @ApiOperation( + value = "Finds Pets by status", + nickname = "findPetsByStatus", + notes = "Multiple status values can be provided with comma separated strings", + response = Pet::class, + responseContainer = "List", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"), ApiResponse(code = 400, message = "Invalid status value")]) @RequestMapping( method = [RequestMethod.GET], value = ["/pet/findByStatus"], produces = ["application/json"] ) - fun findPetsByStatus(@NotNull @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List): ResponseEntity> - - + fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity> + + + @ApiOperation( + value = "Finds Pets by tags", + nickname = "findPetsByTags", + notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + response = Pet::class, + responseContainer = "List", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"), ApiResponse(code = 400, message = "Invalid tag value")]) @RequestMapping( method = [RequestMethod.GET], value = ["/pet/findByTags"], produces = ["application/json"] ) - fun findPetsByTags(@NotNull @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List): ResponseEntity> + fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity> + @ApiOperation( + value = "Find pet by ID", + nickname = "getPetById", + notes = "Returns a single pet", + response = Pet::class, + authorizations = [Authorization(value = "api_key")]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class), ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Pet not found")]) @RequestMapping( method = [RequestMethod.GET], value = ["/pet/{petId}"], produces = ["application/json"] ) - fun getPetById( @PathVariable("petId") petId: kotlin.Long): ResponseEntity + fun getPetById(@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Update an existing pet", + nickname = "updatePet", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Pet not found"), ApiResponse(code = 405, message = "Validation exception")]) @RequestMapping( method = [RequestMethod.PUT], value = ["/pet"], consumes = ["application/json"] ) - fun updatePet( @Valid @RequestBody pet: Pet): ResponseEntity + fun updatePet(@ApiParam(value = "", required = true) @Valid @RequestBody pet: Pet, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Updates a pet in the store with form data", + nickname = "updatePetWithForm", + notes = "", + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 405, message = "Invalid input")]) @RequestMapping( method = [RequestMethod.POST], value = ["/pet/{petId}"], consumes = ["application/x-www-form-urlencoded"] ) - fun updatePetWithForm( @PathVariable("petId") petId: kotlin.Long, @Valid @RequestParam(value = "name", required = false) name: kotlin.String? , @Valid @RequestParam(value = "status", required = false) status: kotlin.String? ): ResponseEntity + fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) name: kotlin.String? ,@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) status: kotlin.String? , @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Uploads an image", + nickname = "uploadFile", + notes = "", + response = ModelApiResponse::class, + authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)]) @RequestMapping( method = [RequestMethod.POST], value = ["/pet/{petId}/uploadImage"], produces = ["application/json"], consumes = ["multipart/form-data"] ) - fun uploadFile( @PathVariable("petId") petId: kotlin.Long, @Valid @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? , @Valid @RequestPart("file", required = false) file: org.springframework.web.multipart.MultipartFile): ResponseEntity + fun uploadFile(@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@ApiParam(value = "") @Valid @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@ApiParam(value = "file detail") @Valid @RequestPart("file", required = false) file: org.springframework.web.multipart.MultipartFile, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity } diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/StoreApi.kt index a0c2538d1ae9..69b2aa749a65 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -6,6 +6,13 @@ package org.openapitools.api import org.openapitools.model.Order +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -30,37 +37,67 @@ import kotlin.collections.Map @RestController @Validated +@Api(value = "store", description = "The store API") interface StoreApi { + @ApiOperation( + value = "Delete purchase order by ID", + nickname = "deleteOrder", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Order not found")]) @RequestMapping( method = [RequestMethod.DELETE], value = ["/store/order/{orderId}"] ) - fun deleteOrder( @PathVariable("orderId") orderId: kotlin.String): ResponseEntity + fun deleteOrder(@ApiParam(value = "", required = true) @PathVariable("orderId") orderId: kotlin.String, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Returns pet inventories by status", + nickname = "getInventory", + notes = "", + response = kotlin.Int::class, + responseContainer = "Map", + authorizations = [Authorization(value = "api_key")]) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")]) @RequestMapping( method = [RequestMethod.GET], value = ["/store/inventory"], produces = ["application/json"] ) - fun getInventory(): ResponseEntity> + fun getInventory(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity> + @ApiOperation( + value = "Find purchase order by ID", + nickname = "getOrderById", + notes = "", + response = Order::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Order::class), ApiResponse(code = 400, message = "Invalid ID supplied"), ApiResponse(code = 404, message = "Order not found")]) @RequestMapping( method = [RequestMethod.GET], value = ["/store/order/{orderId}"], produces = ["application/json"] ) - fun getOrderById(@Min(value=1) @Max(value=5) @PathVariable("orderId") orderId: kotlin.Int): ResponseEntity + fun getOrderById(@Min(value=1) @Max(value=5) @ApiParam(value = "", required = true) @PathVariable("orderId") orderId: kotlin.Int, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Place an order for a pet", + nickname = "placeOrder", + notes = "", + response = Order::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = Order::class), ApiResponse(code = 400, message = "Invalid Order")]) @RequestMapping( method = [RequestMethod.POST], value = ["/store/order"], produces = ["application/json"], consumes = ["application/json"] ) - fun placeOrder( @Valid @RequestBody order: Order): ResponseEntity + fun placeOrder(@ApiParam(value = "", required = true) @Valid @RequestBody order: Order, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity } diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/UserApi.kt index 89daa4814147..acf9134e4931 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -6,6 +6,13 @@ package org.openapitools.api import org.openapitools.model.User +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses +import io.swagger.annotations.Authorization +import io.swagger.annotations.AuthorizationScope import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -30,67 +37,118 @@ import kotlin.collections.Map @RestController @Validated +@Api(value = "user", description = "The user API") interface UserApi { + @ApiOperation( + value = "Create user", + nickname = "createUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) @RequestMapping( method = [RequestMethod.POST], value = ["/user"], consumes = ["application/json"] ) - fun createUser( @Valid @RequestBody user: User): ResponseEntity + fun createUser(@ApiParam(value = "", required = true) @Valid @RequestBody user: User, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Creates list of users with given input array", + nickname = "createUsersWithArrayInput", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) @RequestMapping( method = [RequestMethod.POST], value = ["/user/createWithArray"], consumes = ["application/json"] ) - fun createUsersWithArrayInput( @Valid @RequestBody user: kotlin.collections.List): ResponseEntity + fun createUsersWithArrayInput(@ApiParam(value = "", required = true) @Valid @RequestBody user: kotlin.collections.List, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Creates list of users with given input array", + nickname = "createUsersWithListInput", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) @RequestMapping( method = [RequestMethod.POST], value = ["/user/createWithList"], consumes = ["application/json"] ) - fun createUsersWithListInput( @Valid @RequestBody user: kotlin.collections.List): ResponseEntity + fun createUsersWithListInput(@ApiParam(value = "", required = true) @Valid @RequestBody user: kotlin.collections.List, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Delete user", + nickname = "deleteUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid username supplied"), ApiResponse(code = 404, message = "User not found")]) @RequestMapping( method = [RequestMethod.DELETE], value = ["/user/{username}"] ) - fun deleteUser( @PathVariable("username") username: kotlin.String): ResponseEntity + fun deleteUser(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Get user by user name", + nickname = "getUserByName", + notes = "", + response = User::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = User::class), ApiResponse(code = 400, message = "Invalid username supplied"), ApiResponse(code = 404, message = "User not found")]) @RequestMapping( method = [RequestMethod.GET], value = ["/user/{username}"], produces = ["application/json"] ) - fun getUserByName( @PathVariable("username") username: kotlin.String): ResponseEntity + fun getUserByName(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Logs user into the system", + nickname = "loginUser", + notes = "", + response = kotlin.String::class) + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.String::class), ApiResponse(code = 400, message = "Invalid username/password supplied")]) @RequestMapping( method = [RequestMethod.GET], value = ["/user/login"], produces = ["application/json"] ) - fun loginUser(@NotNull @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Valid @RequestParam(value = "password", required = true) password: kotlin.String): ResponseEntity + fun loginUser(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Logs out current logged in user session", + nickname = "logoutUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 200, message = "successful operation")]) @RequestMapping( method = [RequestMethod.GET], value = ["/user/logout"] ) - fun logoutUser(): ResponseEntity + fun logoutUser(@ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity + @ApiOperation( + value = "Updated user", + nickname = "updateUser", + notes = "") + @ApiResponses( + value = [ApiResponse(code = 400, message = "Invalid user supplied"), ApiResponse(code = 404, message = "User not found")]) @RequestMapping( method = [RequestMethod.PUT], value = ["/user/{username}"], consumes = ["application/json"] ) - fun updateUser( @PathVariable("username") username: kotlin.String, @Valid @RequestBody user: User): ResponseEntity + fun updateUser(@ApiParam(value = "", required = true) @PathVariable("username") username: kotlin.String,@ApiParam(value = "", required = true) @Valid @RequestBody user: User, @ApiParam(hidden = true) request: javax.servlet.http.HttpServletRequest): ResponseEntity } diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt index 147ed4ff31a4..ae9af1b803df 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt @@ -19,6 +19,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -27,25 +28,34 @@ import javax.validation.Valid */ data class Cat( + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("name", required = true) override val name: kotlin.String, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("photoUrls", required = true) override val photoUrls: kotlin.collections.List, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("petType", required = true) override val petType: kotlin.String, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("hunts") val hunts: kotlin.Boolean? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("age") val age: kotlin.Int? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("category") override val category: Category? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("color") override val color: Color? = null ) : Pet, Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt index f98ea616ec26..840851411bef 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt @@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -21,8 +22,10 @@ import javax.validation.Valid */ data class Category( + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") val id: kotlin.Long? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("name") val name: kotlin.String? = null ) : Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Color.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Color.kt index d46c704e991c..8be96cf72e17 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Color.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Color.kt @@ -15,6 +15,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt index 789cb452e748..cce5e8da3c12 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt @@ -19,6 +19,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -28,27 +29,37 @@ import javax.validation.Valid */ data class Dog( + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("bark", required = true) val bark: kotlin.Boolean, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("breed", required = true) val breed: Dog.Breed, + @ApiModelProperty(example = "null", required = true, value = "Whether the dog enjoys fetching") @get:JsonProperty("likesFetch", required = true) override val likesFetch: kotlin.Boolean, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("name", required = true) override val name: kotlin.String, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("photoUrls", required = true) override val photoUrls: kotlin.collections.List, + @ApiModelProperty(example = "null", required = true, value = "") @get:JsonProperty("petType", required = true) override val petType: kotlin.String, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("category") override val category: Category? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("color") override val color: Color? = null ) : Pet, Serializable, com.some.pack.Fetchable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index d5f1bfed6348..adb4e8fb2fc1 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -22,10 +23,13 @@ import javax.validation.Valid */ data class ModelApiResponse( + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("code") val code: kotlin.Int? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("type") val type: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("message") val message: kotlin.String? = null ) : Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt index b9cf389785aa..b6ddad1d9c75 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt @@ -15,6 +15,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -27,16 +28,22 @@ import javax.validation.Valid */ data class Order( + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") val id: kotlin.Long? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("status") val status: Order.Status? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt index a3dbd5258a11..a6a17770db12 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt @@ -21,6 +21,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -44,24 +45,31 @@ import javax.validation.Valid interface Pet : Serializable, com.some.pack.Named, com.some.pack.WithCategory, com.some.pack.WithDefaultMethods { + @get:ApiModelProperty(example = "null", required = true, value = "") override val name: kotlin.String + @get:ApiModelProperty(example = "null", required = true, value = "") val photoUrls: kotlin.collections.List + @get:ApiModelProperty(example = "null", required = true, value = "") val petType: kotlin.String + @get:ApiModelProperty(example = "null", value = "") val id: kotlin.Long? + @get:ApiModelProperty(example = "null", value = "") override val category: Category? + @get:ApiModelProperty(example = "null", value = "") val tags: kotlin.collections.List? + @get:ApiModelProperty(example = "null", value = "") val color: Color? diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt index cce8583e6d59..23d0f3191596 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt @@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -21,8 +22,10 @@ import javax.validation.Valid */ data class Tag( + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") val id: kotlin.Long? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("name") val name: kotlin.String? = null ) : Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt index f24ba91ffb73..9399e70b2527 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt @@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern import javax.validation.constraints.Size import javax.validation.Valid +import io.swagger.annotations.ApiModelProperty /** * @@ -27,20 +28,28 @@ import javax.validation.Valid */ data class User( + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("id") val id: kotlin.Long? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("username") val username: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("email") val email: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("password") val password: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("phone") val phone: kotlin.String? = null, + @ApiModelProperty(example = "null", value = "") @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : Serializable {