From 6ed365a84d1910a75b26477cbde045658be95c4d Mon Sep 17 00:00:00 2001 From: Lezenford Date: Thu, 10 Aug 2023 17:22:30 +0400 Subject: [PATCH 1/3] issues/16295 fix arrays response api after generation --- .../src/main/resources/kotlin-spring/api.mustache | 2 +- .../src/main/resources/kotlin-spring/apiInterface.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 78dd8f8743c9..3d547ad13820 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache @@ -67,7 +67,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v operationId = "{{{operationId}}}", description = """{{{unescapedNotes}}}""", responses = [{{#responses}} - ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content(schema = Schema(implementation = {{{baseType}}}::class))]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}}, + ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}}, security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}} ){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}} @ApiOperation( 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 bc4a32f53d7c..be1a5d800e09 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache @@ -77,7 +77,7 @@ interface {{classname}} { operationId = "{{{operationId}}}", description = """{{{unescapedNotes}}}""", responses = [{{#responses}} - ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content(schema = Schema(implementation = {{{baseType}}}::class))]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} + ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}}, security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}} ){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}} From 4f6e0dd880eaa23404e1054dda67da77f2b31f6c Mon Sep 17 00:00:00 2001 From: Lezenford Date: Fri, 11 Aug 2023 11:38:04 +0400 Subject: [PATCH 2/3] fix samples --- .../src/main/kotlin/org/openapitools/api/PetApiController.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/api/PetApiController.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/api/PetApiController.kt index 32b885c7ffdc..8c62773506bf 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/api/PetApiController.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/api/PetApiController.kt @@ -74,7 +74,7 @@ class PetApiController() { operationId = "findPetsByStatus", description = """Multiple status values can be provided with comma separated strings""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid status value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ] ) @@ -92,7 +92,7 @@ class PetApiController() { operationId = "findPetsByTags", description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid tag value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ] ) From 8f72803a4507a3c93b3ebb224c0cd298579d5403 Mon Sep 17 00:00:00 2001 From: Lezenford Date: Wed, 16 Aug 2023 12:00:29 +0400 Subject: [PATCH 3/3] fix samples --- .../src/main/kotlin/org/openapitools/api/PetApi.kt | 4 ++-- .../src/main/kotlin/org/openapitools/api/PetApiController.kt | 4 ++-- .../src/main/kotlin/org/openapitools/api/PetApiController.kt | 4 ++-- .../src/main/kotlin/org/openapitools/api/PetApiController.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt index 7ef1423b9dac..9e61db28ad33 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -82,7 +82,7 @@ interface PetApi { operationId = "findPetsByStatus", description = """Multiple status values can be provided with comma separated strings""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid status value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ] @@ -101,7 +101,7 @@ interface PetApi { operationId = "findPetsByTags", description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid tag value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ] diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/PetApiController.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/PetApiController.kt index 0cf82b64c04e..898f02a0e15e 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/PetApiController.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/PetApiController.kt @@ -72,7 +72,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByStatus", description = """Multiple status values can be provided with comma separated strings""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid status value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] ) @@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByTags", description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid tag value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] ) diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt index 047e4caafe9f..0046eff8dbe0 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt @@ -73,7 +73,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByStatus", description = """Multiple status values can be provided with comma separated strings""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid status value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] ) @@ -91,7 +91,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByTags", description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid tag value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] ) diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/api/PetApiController.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/api/PetApiController.kt index 0cf82b64c04e..898f02a0e15e 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/api/PetApiController.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/api/PetApiController.kt @@ -72,7 +72,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByStatus", description = """Multiple status values can be provided with comma separated strings""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid status value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] ) @@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) { operationId = "findPetsByTags", description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""", responses = [ - ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]), + ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]), ApiResponse(responseCode = "400", description = "Invalid tag value") ], security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ] )