Skip to content

Commit 7b99690

Browse files
committed
fix issue #22756
1 parent eedb60e commit 7b99690

80 files changed

Lines changed: 948 additions & 474 deletions

File tree

Some content is hidden

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
8686
value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}]){{/swagger1AnnotationLibrary}}
8787
@RequestMapping(
8888
method = [RequestMethod.{{httpMethod}}],
89-
value = [PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}} /* "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}" */]{{#singleContentTypes}}{{#hasProduces}},
89+
// "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}"
90+
value = [PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}}]{{#singleContentTypes}}{{#hasProduces}},
9091
produces = [{{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
9192
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
9293
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ interface {{classname}} {
101101
){{/swagger1AnnotationLibrary}}
102102
@RequestMapping(
103103
method = [RequestMethod.{{httpMethod}}],
104-
value = [PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}} /* "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}" */]{{#singleContentTypes}}{{#hasProduces}},
104+
// "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}"
105+
value = [PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}}]{{#singleContentTypes}}{{#hasProduces}},
105106
produces = [{{#vendorExtensions.x-accepts}}"{{{.}}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-accepts}}]{{/hasProduces}}{{#hasConsumes}},
106107
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
107108
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},

modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/apiInterface.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ interface {{classname}} {
6060
}}{{^useResponseEntity}} @ResponseStatus({{#springHttpStatus}}{{#responses.0}}{{{code}}}{{/responses.0}}{{/springHttpStatus}})
6161
{{/useResponseEntity}}{{!
6262
}}{{#httpMethod}} @HttpExchange(
63-
url = PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}} /* "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}" */,
63+
// "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}"
64+
url = PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}},
6465
method = "{{httpMethod}}"
6566
)
6667
{{/httpMethod}}{{!

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,20 +1221,23 @@ public void generateHttpInterfaceReactiveWithReactorResponseEntity() throws Exce
12211221
"import reactor.core.publisher.Flux\n"
12221222
+ "import reactor.core.publisher.Mono",
12231223
" @HttpExchange(\n"
1224-
+ " url = PATH_GET_INVENTORY /* \"/store/inventory\" */,\n"
1224+
+ " // \"/store/inventory\"\n"
1225+
+ " url = PATH_GET_INVENTORY,\n"
12251226
+ " method = \"GET\"\n"
12261227
+ " )\n"
12271228
+ " fun getInventory(\n"
12281229
+ " ): Mono<ResponseEntity<Map<String, kotlin.Int>>>",
12291230
" @HttpExchange(\n"
1230-
+ " url = PATH_DELETE_ORDER /* \"/store/order/{orderId}\" */,\n"
1231+
+ " // \"/store/order/{orderId}\"\n"
1232+
+ " url = PATH_DELETE_ORDER,\n"
12311233
+ " method = \"DELETE\"\n"
12321234
+ " )\n"
12331235
+ " fun deleteOrder(\n"
12341236
+ " @Parameter(description = \"ID of the order that needs to be deleted\", required = true) @PathVariable(\"orderId\") orderId: kotlin.String\n"
12351237
+ " ): Mono<ResponseEntity<Unit>>",
12361238
" @HttpExchange(\n"
1237-
+ " url = PATH_PLACE_ORDER /* \"/store/order\" */,\n"
1239+
+ " // \"/store/order\"\n"
1240+
+ " url = PATH_PLACE_ORDER,\n"
12381241
+ " method = \"POST\"\n"
12391242
+ " )\n"
12401243
+ " fun placeOrder(\n"

samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/api/PetApi.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ interface PetApi {
3535

3636
@RequestMapping(
3737
method = [RequestMethod.POST],
38-
value = [PATH_ADD_PET /* "/pet" */],
38+
// "/pet"
39+
value = [PATH_ADD_PET],
3940
produces = ["application/xml", "application/json"],
4041
consumes = ["application/json", "application/xml"]
4142
)
@@ -48,7 +49,8 @@ interface PetApi {
4849

4950
@RequestMapping(
5051
method = [RequestMethod.DELETE],
51-
value = [PATH_DELETE_PET /* "/pet/{petId}" */]
52+
// "/pet/{petId}"
53+
value = [PATH_DELETE_PET]
5254
)
5355
fun deletePet(
5456
@PathVariable("petId") petId: kotlin.Long,
@@ -60,7 +62,8 @@ interface PetApi {
6062

6163
@RequestMapping(
6264
method = [RequestMethod.GET],
63-
value = [PATH_FIND_PETS_BY_STATUS /* "/pet/findByStatus" */],
65+
// "/pet/findByStatus"
66+
value = [PATH_FIND_PETS_BY_STATUS],
6467
produces = ["application/xml", "application/json"]
6568
)
6669
fun findPetsByStatus(
@@ -72,7 +75,8 @@ interface PetApi {
7275

7376
@RequestMapping(
7477
method = [RequestMethod.GET],
75-
value = [PATH_FIND_PETS_BY_TAGS /* "/pet/findByTags" */],
78+
// "/pet/findByTags"
79+
value = [PATH_FIND_PETS_BY_TAGS],
7680
produces = ["application/xml", "application/json"]
7781
)
7882
fun findPetsByTags(
@@ -84,7 +88,8 @@ interface PetApi {
8488

8589
@RequestMapping(
8690
method = [RequestMethod.GET],
87-
value = [PATH_GET_PET_BY_ID /* "/pet/{petId}" */],
91+
// "/pet/{petId}"
92+
value = [PATH_GET_PET_BY_ID],
8893
produces = ["application/xml", "application/json"]
8994
)
9095
fun getPetById(
@@ -96,7 +101,8 @@ interface PetApi {
96101

97102
@RequestMapping(
98103
method = [RequestMethod.PUT],
99-
value = [PATH_UPDATE_PET /* "/pet" */],
104+
// "/pet"
105+
value = [PATH_UPDATE_PET],
100106
produces = ["application/xml", "application/json"],
101107
consumes = ["application/json", "application/xml"]
102108
)
@@ -109,7 +115,8 @@ interface PetApi {
109115

110116
@RequestMapping(
111117
method = [RequestMethod.POST],
112-
value = [PATH_UPDATE_PET_WITH_FORM /* "/pet/{petId}" */],
118+
// "/pet/{petId}"
119+
value = [PATH_UPDATE_PET_WITH_FORM],
113120
consumes = ["application/x-www-form-urlencoded"]
114121
)
115122
fun updatePetWithForm(
@@ -123,7 +130,8 @@ interface PetApi {
123130

124131
@RequestMapping(
125132
method = [RequestMethod.POST],
126-
value = [PATH_UPLOAD_FILE /* "/pet/{petId}/uploadImage" */],
133+
// "/pet/{petId}/uploadImage"
134+
value = [PATH_UPLOAD_FILE],
127135
produces = ["application/json"],
128136
consumes = ["multipart/form-data"]
129137
)

samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/api/StoreApi.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ interface StoreApi {
3434

3535
@RequestMapping(
3636
method = [RequestMethod.DELETE],
37-
value = [PATH_DELETE_ORDER /* "/store/order/{orderId}" */]
37+
// "/store/order/{orderId}"
38+
value = [PATH_DELETE_ORDER]
3839
)
3940
fun deleteOrder(
4041
@PathVariable("orderId") orderId: kotlin.String
@@ -45,7 +46,8 @@ interface StoreApi {
4546

4647
@RequestMapping(
4748
method = [RequestMethod.GET],
48-
value = [PATH_GET_INVENTORY /* "/store/inventory" */],
49+
// "/store/inventory"
50+
value = [PATH_GET_INVENTORY],
4951
produces = ["application/json"]
5052
)
5153
fun getInventory(): ResponseEntity<Map<String, kotlin.Int>> {
@@ -55,7 +57,8 @@ interface StoreApi {
5557

5658
@RequestMapping(
5759
method = [RequestMethod.GET],
58-
value = [PATH_GET_ORDER_BY_ID /* "/store/order/{orderId}" */],
60+
// "/store/order/{orderId}"
61+
value = [PATH_GET_ORDER_BY_ID],
5962
produces = ["application/xml", "application/json"]
6063
)
6164
fun getOrderById(
@@ -67,7 +70,8 @@ interface StoreApi {
6770

6871
@RequestMapping(
6972
method = [RequestMethod.POST],
70-
value = [PATH_PLACE_ORDER /* "/store/order" */],
73+
// "/store/order"
74+
value = [PATH_PLACE_ORDER],
7175
produces = ["application/xml", "application/json"],
7276
consumes = ["application/json"]
7377
)

samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/api/UserApi.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ interface UserApi {
3434

3535
@RequestMapping(
3636
method = [RequestMethod.POST],
37-
value = [PATH_CREATE_USER /* "/user" */],
37+
// "/user"
38+
value = [PATH_CREATE_USER],
3839
consumes = ["application/json"]
3940
)
4041
fun createUser(
@@ -46,7 +47,8 @@ interface UserApi {
4647

4748
@RequestMapping(
4849
method = [RequestMethod.POST],
49-
value = [PATH_CREATE_USERS_WITH_ARRAY_INPUT /* "/user/createWithArray" */],
50+
// "/user/createWithArray"
51+
value = [PATH_CREATE_USERS_WITH_ARRAY_INPUT],
5052
consumes = ["application/json"]
5153
)
5254
fun createUsersWithArrayInput(
@@ -58,7 +60,8 @@ interface UserApi {
5860

5961
@RequestMapping(
6062
method = [RequestMethod.POST],
61-
value = [PATH_CREATE_USERS_WITH_LIST_INPUT /* "/user/createWithList" */],
63+
// "/user/createWithList"
64+
value = [PATH_CREATE_USERS_WITH_LIST_INPUT],
6265
consumes = ["application/json"]
6366
)
6467
fun createUsersWithListInput(
@@ -70,7 +73,8 @@ interface UserApi {
7073

7174
@RequestMapping(
7275
method = [RequestMethod.DELETE],
73-
value = [PATH_DELETE_USER /* "/user/{username}" */]
76+
// "/user/{username}"
77+
value = [PATH_DELETE_USER]
7478
)
7579
fun deleteUser(
7680
@PathVariable("username") username: kotlin.String
@@ -81,7 +85,8 @@ interface UserApi {
8185

8286
@RequestMapping(
8387
method = [RequestMethod.GET],
84-
value = [PATH_GET_USER_BY_NAME /* "/user/{username}" */],
88+
// "/user/{username}"
89+
value = [PATH_GET_USER_BY_NAME],
8590
produces = ["application/xml", "application/json"]
8691
)
8792
fun getUserByName(
@@ -93,7 +98,8 @@ interface UserApi {
9398

9499
@RequestMapping(
95100
method = [RequestMethod.GET],
96-
value = [PATH_LOGIN_USER /* "/user/login" */],
101+
// "/user/login"
102+
value = [PATH_LOGIN_USER],
97103
produces = ["application/xml", "application/json"]
98104
)
99105
fun loginUser(
@@ -106,7 +112,8 @@ interface UserApi {
106112

107113
@RequestMapping(
108114
method = [RequestMethod.GET],
109-
value = [PATH_LOGOUT_USER /* "/user/logout" */]
115+
// "/user/logout"
116+
value = [PATH_LOGOUT_USER]
110117
)
111118
fun logoutUser(): ResponseEntity<Unit> {
112119
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
@@ -115,7 +122,8 @@ interface UserApi {
115122

116123
@RequestMapping(
117124
method = [RequestMethod.PUT],
118-
value = [PATH_UPDATE_USER /* "/user/{username}" */],
125+
// "/user/{username}"
126+
value = [PATH_UPDATE_USER],
119127
consumes = ["application/json"]
120128
)
121129
fun updateUser(

samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/api/PetApiClient.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ interface PetApi {
3030

3131
@ResponseStatus(HttpStatus.OK)
3232
@HttpExchange(
33-
url = PATH_ADD_PET /* "/pet" */,
33+
// "/pet"
34+
url = PATH_ADD_PET,
3435
method = "POST"
3536
)
3637
suspend fun addPet(
@@ -39,7 +40,8 @@ interface PetApi {
3940

4041
@ResponseStatus(HttpStatus.BAD_REQUEST)
4142
@HttpExchange(
42-
url = PATH_DELETE_PET /* "/pet/{petId}" */,
43+
// "/pet/{petId}"
44+
url = PATH_DELETE_PET,
4345
method = "DELETE"
4446
)
4547
suspend fun deletePet(
@@ -49,7 +51,8 @@ interface PetApi {
4951

5052
@ResponseStatus(HttpStatus.OK)
5153
@HttpExchange(
52-
url = PATH_FIND_PETS_BY_STATUS /* "/pet/findByStatus" */,
54+
// "/pet/findByStatus"
55+
url = PATH_FIND_PETS_BY_STATUS,
5356
method = "GET"
5457
)
5558
suspend fun findPetsByStatus(
@@ -59,7 +62,8 @@ interface PetApi {
5962

6063
@ResponseStatus(HttpStatus.OK)
6164
@HttpExchange(
62-
url = PATH_FIND_PETS_BY_TAGS /* "/pet/findByTags" */,
65+
// "/pet/findByTags"
66+
url = PATH_FIND_PETS_BY_TAGS,
6367
method = "GET"
6468
)
6569
suspend fun findPetsByTags(
@@ -69,7 +73,8 @@ interface PetApi {
6973

7074
@ResponseStatus(HttpStatus.OK)
7175
@HttpExchange(
72-
url = PATH_GET_PET_BY_ID /* "/pet/{petId}" */,
76+
// "/pet/{petId}"
77+
url = PATH_GET_PET_BY_ID,
7378
method = "GET"
7479
)
7580
suspend fun getPetById(
@@ -78,7 +83,8 @@ interface PetApi {
7883

7984
@ResponseStatus(HttpStatus.OK)
8085
@HttpExchange(
81-
url = PATH_UPDATE_PET /* "/pet" */,
86+
// "/pet"
87+
url = PATH_UPDATE_PET,
8288
method = "PUT"
8389
)
8490
suspend fun updatePet(
@@ -87,7 +93,8 @@ interface PetApi {
8793

8894
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
8995
@HttpExchange(
90-
url = PATH_UPDATE_PET_WITH_FORM /* "/pet/{petId}" */,
96+
// "/pet/{petId}"
97+
url = PATH_UPDATE_PET_WITH_FORM,
9198
method = "POST"
9299
)
93100
suspend fun updatePetWithForm(
@@ -98,7 +105,8 @@ interface PetApi {
98105

99106
@ResponseStatus(HttpStatus.OK)
100107
@HttpExchange(
101-
url = PATH_UPLOAD_FILE /* "/pet/{petId}/uploadImage" */,
108+
// "/pet/{petId}/uploadImage"
109+
url = PATH_UPLOAD_FILE,
102110
method = "POST"
103111
)
104112
suspend fun uploadFile(

samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/api/StoreApiClient.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ interface StoreApi {
2929

3030
@ResponseStatus(HttpStatus.BAD_REQUEST)
3131
@HttpExchange(
32-
url = PATH_DELETE_ORDER /* "/store/order/{orderId}" */,
32+
// "/store/order/{orderId}"
33+
url = PATH_DELETE_ORDER,
3334
method = "DELETE"
3435
)
3536
suspend fun deleteOrder(
@@ -38,7 +39,8 @@ interface StoreApi {
3839

3940
@ResponseStatus(HttpStatus.OK)
4041
@HttpExchange(
41-
url = PATH_GET_INVENTORY /* "/store/inventory" */,
42+
// "/store/inventory"
43+
url = PATH_GET_INVENTORY,
4244
method = "GET"
4345
)
4446
suspend fun getInventory(
@@ -47,7 +49,8 @@ interface StoreApi {
4749

4850
@ResponseStatus(HttpStatus.OK)
4951
@HttpExchange(
50-
url = PATH_GET_ORDER_BY_ID /* "/store/order/{orderId}" */,
52+
// "/store/order/{orderId}"
53+
url = PATH_GET_ORDER_BY_ID,
5154
method = "GET"
5255
)
5356
suspend fun getOrderById(
@@ -56,7 +59,8 @@ interface StoreApi {
5659

5760
@ResponseStatus(HttpStatus.OK)
5861
@HttpExchange(
59-
url = PATH_PLACE_ORDER /* "/store/order" */,
62+
// "/store/order"
63+
url = PATH_PLACE_ORDER,
6064
method = "POST"
6165
)
6266
suspend fun placeOrder(

0 commit comments

Comments
 (0)