#18058 Fix the Java generator to generate valid @RequestMappings where the produce field takes list of string parameters instead of a single comma-separated string (#18092)

* #18058 Fix AbstractJavaCodegen.getAccepts() so it returns a String array instead of a comma-separated string, and fixed api.mustache so the @RequestMapping annotation generated produces for x-accepts as a parameter list instead of a (single) string.

* #18058 Updated test case to accept a string array instead of a comma-separated list.

* #18058 Reverted changes on imported compared to the main branch.

* #18058 getAccepts() is now hybrid, and can return both a single String or a String[].

* #18058 Rolled back the hybrid getAccepts(), so it only returns a String array.

* #18058 Updated mustache files to cope with vendorExtensions.x-accepts being a string array instead of a comma-separated string.

* #18058 Generated new sample files with by running `./bin/generate-samples.sh ./bin/configs/*.yaml`

* #18058 Optimization of getAccepts()

* #18058 Regenerated scripts that got broken after resolving conflicts on GitHub

* #18058 Fixed introduced issue with api.mustache causing a redundant accept with @HttpExchange with the PetApi.java, StoreApi.java, and UserApi.java.
This commit is contained in:
Flemming Nørnberg Larsen
2024-03-21 10:53:18 +01:00
committed by GitHub
parent c7e9bd2f29
commit a4508f6817
160 changed files with 6261 additions and 3105 deletions

View File

@@ -50,7 +50,8 @@ paths:
schema:
$ref: '#/components/schemas/_foo_get_default_response'
description: response
x-accepts: application/json
x-accepts:
- application/json
/pet:
post:
description: ""
@@ -69,7 +70,8 @@ paths:
tags:
- pet
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
put:
description: ""
operationId: updatePet
@@ -91,7 +93,8 @@ paths:
tags:
- pet
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
servers:
- url: http://petstore.swagger.io/v2
- url: http://path-server-test.petstore.local/v2
@@ -140,7 +143,9 @@ paths:
summary: Finds Pets by status
tags:
- pet
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
/pet/findByTags:
get:
deprecated: true
@@ -182,7 +187,9 @@ paths:
summary: Finds Pets by tags
tags:
- pet
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
/pet/{petId}:
delete:
description: ""
@@ -214,7 +221,8 @@ paths:
summary: Deletes a pet
tags:
- pet
x-accepts: application/json
x-accepts:
- application/json
get:
description: Returns a single pet
operationId: getPetById
@@ -247,7 +255,9 @@ paths:
summary: Find pet by ID
tags:
- pet
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
post:
description: ""
operationId: updatePetWithForm
@@ -277,7 +287,8 @@ paths:
tags:
- pet
x-content-type: application/x-www-form-urlencoded
x-accepts: application/json
x-accepts:
- application/json
/pet/{petId}/uploadImage:
post:
description: ""
@@ -312,7 +323,8 @@ paths:
tags:
- pet
x-content-type: multipart/form-data
x-accepts: application/json
x-accepts:
- application/json
/store/inventory:
get:
description: Returns a map of status codes to quantities
@@ -332,7 +344,8 @@ paths:
summary: Returns pet inventories by status
tags:
- store
x-accepts: application/json
x-accepts:
- application/json
/store/order:
post:
description: ""
@@ -360,7 +373,9 @@ paths:
tags:
- store
x-content-type: application/json
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything
@@ -383,7 +398,8 @@ paths:
summary: Delete purchase order by ID
tags:
- store
x-accepts: application/json
x-accepts:
- application/json
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generate exceptions
@@ -417,7 +433,9 @@ paths:
summary: Find purchase order by ID
tags:
- store
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
/user:
post:
description: This can only be done by the logged in user.
@@ -436,7 +454,8 @@ paths:
tags:
- user
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/user/createWithArray:
post:
description: ""
@@ -450,7 +469,8 @@ paths:
tags:
- user
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/user/createWithList:
post:
description: ""
@@ -464,7 +484,8 @@ paths:
tags:
- user
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/user/login:
get:
description: ""
@@ -516,7 +537,9 @@ paths:
summary: Logs user into the system
tags:
- user
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
/user/logout:
get:
description: ""
@@ -527,7 +550,8 @@ paths:
summary: Logs out current logged in user session
tags:
- user
x-accepts: application/json
x-accepts:
- application/json
/user/{username}:
delete:
description: This can only be done by the logged in user.
@@ -549,7 +573,8 @@ paths:
summary: Delete user
tags:
- user
x-accepts: application/json
x-accepts:
- application/json
get:
description: ""
operationId: getUserByName
@@ -579,7 +604,9 @@ paths:
summary: Get user by user name
tags:
- user
x-accepts: "application/json,application/xml"
x-accepts:
- application/json
- application/xml
put:
description: This can only be done by the logged in user.
operationId: updateUser
@@ -608,7 +635,8 @@ paths:
tags:
- user
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake_classname_test:
patch:
description: To test class name in snake case
@@ -628,7 +656,8 @@ paths:
tags:
- fake_classname_tags 123#$%^
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake:
delete:
description: Fake endpoint to test group parameters (optional)
@@ -693,7 +722,8 @@ paths:
tags:
- fake
x-group-parameters: true
x-accepts: application/json
x-accepts:
- application/json
get:
description: To test enum parameters
operationId: testEnumParameters
@@ -790,7 +820,8 @@ paths:
tags:
- fake
x-content-type: application/x-www-form-urlencoded
x-accepts: application/json
x-accepts:
- application/json
patch:
description: To test "client" model
operationId: testClientModel
@@ -807,7 +838,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
post:
description: |
Fake endpoint for testing various parameters
@@ -835,7 +867,8 @@ paths:
tags:
- fake
x-content-type: application/x-www-form-urlencoded
x-accepts: application/json
x-accepts:
- application/json
/fake/outer/number:
post:
description: Test serialization of outer number types
@@ -856,7 +889,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: '*/*'
x-accepts:
- '*/*'
/fake/outer/string:
post:
description: Test serialization of outer string types
@@ -877,7 +911,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: '*/*'
x-accepts:
- '*/*'
/fake/outer/boolean:
post:
description: Test serialization of outer boolean types
@@ -898,7 +933,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: '*/*'
x-accepts:
- '*/*'
/fake/outer/composite:
post:
description: Test serialization of object with outer number type
@@ -919,7 +955,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: '*/*'
x-accepts:
- '*/*'
/fake/BigDecimalMap:
get:
description: "for Java apache and Java native, test toUrlQueryString for maps\
@@ -934,7 +971,8 @@ paths:
description: successful operation
tags:
- fake
x-accepts: '*/*'
x-accepts:
- '*/*'
/fake/jsonFormData:
get:
description: ""
@@ -951,7 +989,8 @@ paths:
tags:
- fake
x-content-type: application/x-www-form-urlencoded
x-accepts: application/json
x-accepts:
- application/json
/fake/additionalProperties-reference:
post:
description: ""
@@ -970,7 +1009,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/stringMap-reference:
post:
description: ""
@@ -989,7 +1029,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/inline-additionalProperties:
post:
description: ""
@@ -1010,7 +1051,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/inline-freeform-additionalProperties:
post:
description: ""
@@ -1029,7 +1071,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/body-with-query-params:
put:
operationId: testBodyWithQueryParams
@@ -1053,7 +1096,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/another-fake/dummy:
patch:
description: To test special tags and operation ID starting with number
@@ -1071,7 +1115,8 @@ paths:
tags:
- $another-fake?
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/body-with-file-schema:
put:
description: "For this test, the body for this request much reference a schema\
@@ -1089,7 +1134,8 @@ paths:
tags:
- fake
x-content-type: application/json
x-accepts: application/json
x-accepts:
- application/json
/fake/test-query-parameters:
put:
description: To test the collection format in query parameters
@@ -1145,7 +1191,8 @@ paths:
description: Success
tags:
- fake
x-accepts: application/json
x-accepts:
- application/json
/fake/{petId}/uploadImageWithRequiredFile:
post:
description: ""
@@ -1180,7 +1227,8 @@ paths:
tags:
- pet
x-content-type: multipart/form-data
x-accepts: application/json
x-accepts:
- application/json
/fake/health:
get:
responses:
@@ -1193,7 +1241,8 @@ paths:
summary: Health check endpoint
tags:
- fake
x-accepts: application/json
x-accepts:
- application/json
/fake/array-of-enums:
get:
operationId: getArrayOfEnums
@@ -1207,7 +1256,8 @@ paths:
summary: Array of Enums
tags:
- fake
x-accepts: application/json
x-accepts:
- application/json
/fake/application_json_utf8:
get:
operationId: get_application_json_utf8
@@ -1221,7 +1271,8 @@ paths:
summary: application/json UTF8
tags:
- fake
x-accepts: application/json;charset=utf-8
x-accepts:
- application/json;charset=utf-8
components:
requestBodies:
UserArray: