Skip to content

Commit 3e95001

Browse files
LezenfordLezenford
andauthored
[Kotlin-Spring] fix arrays response api after generation (#16296)
* issues/16295 fix arrays response api after generation * fix samples * fix samples --------- Co-authored-by: Lezenford <alex.v.plekhanov@gmail.com>
1 parent 00de163 commit 3e95001

7 files changed

Lines changed: 12 additions & 12 deletions

File tree

modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
6767
operationId = "{{{operationId}}}",
6868
description = """{{{unescapedNotes}}}""",
6969
responses = [{{#responses}}
70-
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content(schema = Schema(implementation = {{{baseType}}}::class))]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}},
70+
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}},
7171
security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}}
7272
){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
7373
@ApiOperation(

modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ interface {{classname}} {
7777
operationId = "{{{operationId}}}",
7878
description = """{{{unescapedNotes}}}""",
7979
responses = [{{#responses}}
80-
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content(schema = Schema(implementation = {{{baseType}}}::class))]{{/baseType}}){{^-last}},{{/-last}}{{/responses}}
80+
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}}
8181
]{{#hasAuthMethods}},
8282
security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}}
8383
){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}

samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/api/PetApiController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class PetApiController() {
7474
operationId = "findPetsByStatus",
7575
description = """Multiple status values can be provided with comma separated strings""",
7676
responses = [
77-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
77+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
7878
ApiResponse(responseCode = "400", description = "Invalid status value") ],
7979
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]
8080
)
@@ -92,7 +92,7 @@ class PetApiController() {
9292
operationId = "findPetsByTags",
9393
description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""",
9494
responses = [
95-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
95+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
9696
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
9797
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]
9898
)

samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/api/PetApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ interface PetApi {
8282
operationId = "findPetsByStatus",
8383
description = """Multiple status values can be provided with comma separated strings""",
8484
responses = [
85-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
85+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
8686
ApiResponse(responseCode = "400", description = "Invalid status value")
8787
],
8888
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]
@@ -101,7 +101,7 @@ interface PetApi {
101101
operationId = "findPetsByTags",
102102
description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""",
103103
responses = [
104-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
104+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
105105
ApiResponse(responseCode = "400", description = "Invalid tag value")
106106
],
107107
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "read:pets" ]) ]

samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/api/PetApiController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
7272
operationId = "findPetsByStatus",
7373
description = """Multiple status values can be provided with comma separated strings""",
7474
responses = [
75-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
75+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
7676
ApiResponse(responseCode = "400", description = "Invalid status value") ],
7777
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
7878
)
@@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
9090
operationId = "findPetsByTags",
9191
description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""",
9292
responses = [
93-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
93+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
9494
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
9595
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
9696
)

samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/api/PetApiController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
7373
operationId = "findPetsByStatus",
7474
description = """Multiple status values can be provided with comma separated strings""",
7575
responses = [
76-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
76+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
7777
ApiResponse(responseCode = "400", description = "Invalid status value") ],
7878
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
7979
)
@@ -91,7 +91,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
9191
operationId = "findPetsByTags",
9292
description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""",
9393
responses = [
94-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
94+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
9595
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
9696
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
9797
)

samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/api/PetApiController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
7272
operationId = "findPetsByStatus",
7373
description = """Multiple status values can be provided with comma separated strings""",
7474
responses = [
75-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
75+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
7676
ApiResponse(responseCode = "400", description = "Invalid status value") ],
7777
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
7878
)
@@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
9090
operationId = "findPetsByTags",
9191
description = """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""",
9292
responses = [
93-
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
93+
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(array = ArraySchema(schema = Schema(implementation = Pet::class)))]),
9494
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
9595
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
9696
)

0 commit comments

Comments
 (0)