Skip to content

Commit 28e2254

Browse files
authored
[JAXRS] Partial revert changing path generation if interface, fixes #22279 (#22316)
* Partial revert changing path generation if interface This reverts commit 65703ff. * update samples and docs
1 parent 69da1ea commit 28e2254

File tree

28 files changed

+71
-94
lines changed

28 files changed

+71
-94
lines changed

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/api.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ import {{javaxPackage}}.validation.Valid;{{/useBeanValidation}}
2929
/**
3030
* Represents a collection of functions to interact with the API endpoints.
3131
*/
32-
{{^interfaceOnly}}
33-
@Path("{{commonPath}}")
34-
{{/interfaceOnly}}
35-
{{#useSwaggerAnnotations}}
32+
@Path("{{commonPath}}"){{#useSwaggerAnnotations}}
3633
@Api(description = "the {{{baseName}}} API"){{/useSwaggerAnnotations}}{{#useSwaggerV3Annotations}}
3734
@Tag(name = "{{{baseName}}}"){{/useSwaggerV3Annotations}}{{#hasConsumes}}
3835
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}

modules/openapi-generator/src/main/resources/JavaJaxRS/spec/apiInterface.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @return {{{message}}}
99
{{/responses}}
1010
*/
11-
@{{httpMethod}}
12-
@Path("{{commonPath}}{{{path}}}"){{#hasConsumes}}
11+
@{{httpMethod}}{{#subresourceOperation}}
12+
@Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}}
1313
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
1414
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#useSwaggerAnnotations}}
1515
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}"{{#hasAuthMethods}}, authorizations = {

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/AnotherFakeApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* Represents a collection of functions to interact with the API endpoints.
1919
*/
20+
@Path("/another-fake/dummy")
2021
@Api(description = "the another-fake API")
2122
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2223
public interface AnotherFakeApi {
@@ -29,7 +30,6 @@ public interface AnotherFakeApi {
2930
* @return successful operation
3031
*/
3132
@PATCH
32-
@Path("/another-fake/dummy")
3333
@Consumes({ "application/json" })
3434
@Produces({ "application/json" })
3535
@ApiOperation(value = "To test special tags", notes = "To test special tags and operation ID starting with number", tags={ "$another-fake?" })

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/FakeApi.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/**
2727
* Represents a collection of functions to interact with the API endpoints.
2828
*/
29+
@Path("/fake")
2930
@Api(description = "the fake API")
3031
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
3132
public interface FakeApi {
@@ -37,7 +38,7 @@ public interface FakeApi {
3738
* @return successful operation
3839
*/
3940
@POST
40-
@Path("/fake/create_xml_item")
41+
@Path("/create_xml_item")
4142
@Consumes({ "application/xml", "application/xml; charset=utf-8", "application/xml; charset=utf-16", "text/xml", "text/xml; charset=utf-8", "text/xml; charset=utf-16" })
4243
@ApiOperation(value = "creates an XmlItem", notes = "this route creates an XmlItem", tags={ "fake" })
4344
@ApiResponses(value = {
@@ -52,7 +53,7 @@ public interface FakeApi {
5253
* @return Output boolean
5354
*/
5455
@POST
55-
@Path("/fake/outer/boolean")
56+
@Path("/outer/boolean")
5657
@Produces({ "*/*" })
5758
@ApiOperation(value = "", notes = "Test serialization of outer boolean types", tags={ "fake" })
5859
@ApiResponses(value = {
@@ -67,7 +68,7 @@ public interface FakeApi {
6768
* @return Output composite
6869
*/
6970
@POST
70-
@Path("/fake/outer/composite")
71+
@Path("/outer/composite")
7172
@Produces({ "*/*" })
7273
@ApiOperation(value = "", notes = "Test serialization of object with outer number type", tags={ "fake" })
7374
@ApiResponses(value = {
@@ -82,7 +83,7 @@ public interface FakeApi {
8283
* @return Output number
8384
*/
8485
@POST
85-
@Path("/fake/outer/number")
86+
@Path("/outer/number")
8687
@Produces({ "*/*" })
8788
@ApiOperation(value = "", notes = "Test serialization of outer number types", tags={ "fake" })
8889
@ApiResponses(value = {
@@ -97,7 +98,7 @@ public interface FakeApi {
9798
* @return Output string
9899
*/
99100
@POST
100-
@Path("/fake/outer/string")
101+
@Path("/outer/string")
101102
@Produces({ "*/*" })
102103
@ApiOperation(value = "", notes = "Test serialization of outer string types", tags={ "fake" })
103104
@ApiResponses(value = {
@@ -112,7 +113,7 @@ public interface FakeApi {
112113
* @return Success
113114
*/
114115
@PUT
115-
@Path("/fake/body-with-file-schema")
116+
@Path("/body-with-file-schema")
116117
@Consumes({ "application/json" })
117118
@ApiOperation(value = "", notes = "For this test, the body for this request much reference a schema named `File`.", tags={ "fake" })
118119
@ApiResponses(value = {
@@ -128,7 +129,7 @@ public interface FakeApi {
128129
* @return Success
129130
*/
130131
@PUT
131-
@Path("/fake/body-with-query-params")
132+
@Path("/body-with-query-params")
132133
@Consumes({ "application/json" })
133134
@ApiOperation(value = "", notes = "", tags={ "fake" })
134135
@ApiResponses(value = {
@@ -143,7 +144,6 @@ public interface FakeApi {
143144
* @return successful operation
144145
*/
145146
@PATCH
146-
@Path("/fake")
147147
@Consumes({ "application/json" })
148148
@Produces({ "application/json" })
149149
@ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", tags={ "fake" })
@@ -173,7 +173,6 @@ public interface FakeApi {
173173
* @return User not found
174174
*/
175175
@POST
176-
@Path("/fake")
177176
@Consumes({ "application/x-www-form-urlencoded" })
178177
@ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트", authorizations = {
179178

@@ -200,7 +199,6 @@ public interface FakeApi {
200199
* @return Not found
201200
*/
202201
@GET
203-
@Path("/fake")
204202
@Consumes({ "application/x-www-form-urlencoded" })
205203
@ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", tags={ "fake" })
206204
@ApiResponses(value = {
@@ -221,7 +219,6 @@ public interface FakeApi {
221219
* @return Something wrong
222220
*/
223221
@DELETE
224-
@Path("/fake")
225222
@ApiOperation(value = "Fake endpoint to test group parameters (optional)", notes = "Fake endpoint to test group parameters (optional)", tags={ "fake" })
226223
@ApiResponses(value = {
227224
@ApiResponse(code = 400, message = "Something wrong", response = Void.class) })
@@ -235,7 +232,7 @@ public interface FakeApi {
235232
* @return successful operation
236233
*/
237234
@POST
238-
@Path("/fake/inline-additionalProperties")
235+
@Path("/inline-additionalProperties")
239236
@Consumes({ "application/json" })
240237
@ApiOperation(value = "test inline additionalProperties", notes = "", tags={ "fake" })
241238
@ApiResponses(value = {
@@ -251,7 +248,7 @@ public interface FakeApi {
251248
* @return successful operation
252249
*/
253250
@GET
254-
@Path("/fake/jsonFormData")
251+
@Path("/jsonFormData")
255252
@Consumes({ "application/x-www-form-urlencoded" })
256253
@ApiOperation(value = "test json serialization of form data", notes = "", tags={ "fake" })
257254
@ApiResponses(value = {
@@ -270,7 +267,7 @@ public interface FakeApi {
270267
* @return Success
271268
*/
272269
@PUT
273-
@Path("/fake/test-query-parameters")
270+
@Path("/test-query-parameters")
274271
@ApiOperation(value = "", notes = "To test the collection format in query parameters", tags={ "fake" })
275272
@ApiResponses(value = {
276273
@ApiResponse(code = 200, message = "Success", response = Void.class) })
@@ -286,7 +283,7 @@ public interface FakeApi {
286283
* @return successful operation
287284
*/
288285
@POST
289-
@Path("/fake/{petId}/uploadImageWithRequiredFile")
286+
@Path("/{petId}/uploadImageWithRequiredFile")
290287
@Consumes({ "multipart/form-data" })
291288
@Produces({ "application/json" })
292289
@ApiOperation(value = "uploads an image (required)", notes = "", authorizations = {

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/FakeClassnameTestApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/**
1717
* Represents a collection of functions to interact with the API endpoints.
1818
*/
19+
@Path("/fake_classname_test")
1920
@Api(description = "the fake_classname_test API")
2021
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2122
public interface FakeClassnameTestApi {
@@ -27,7 +28,6 @@ public interface FakeClassnameTestApi {
2728
* @return successful operation
2829
*/
2930
@PATCH
30-
@Path("/fake_classname_test")
3131
@Consumes({ "application/json" })
3232
@Produces({ "application/json" })
3333
@ApiOperation(value = "To test class name in snake case", notes = "To test class name in snake case", authorizations = {

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/PetApi.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/**
2020
* Represents a collection of functions to interact with the API endpoints.
2121
*/
22+
@Path("/pet")
2223
@Api(description = "the pet API")
2324
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2425
public interface PetApi {
@@ -31,7 +32,6 @@ public interface PetApi {
3132
* @return Invalid input
3233
*/
3334
@POST
34-
@Path("/pet")
3535
@Consumes({ "application/json", "application/xml" })
3636
@ApiOperation(value = "Add a new pet to the store", notes = "", authorizations = {
3737
@Authorization(value = "petstore_auth", scopes = {
@@ -53,7 +53,7 @@ public interface PetApi {
5353
* @return Invalid pet value
5454
*/
5555
@DELETE
56-
@Path("/pet/{petId}")
56+
@Path("/{petId}")
5757
@ApiOperation(value = "Deletes a pet", notes = "", authorizations = {
5858
@Authorization(value = "petstore_auth", scopes = {
5959
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -73,7 +73,7 @@ public interface PetApi {
7373
* @return Invalid status value
7474
*/
7575
@GET
76-
@Path("/pet/findByStatus")
76+
@Path("/findByStatus")
7777
@Produces({ "application/xml", "application/json" })
7878
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", authorizations = {
7979
@Authorization(value = "petstore_auth", scopes = {
@@ -94,7 +94,7 @@ public interface PetApi {
9494
* @return Invalid tag value
9595
*/
9696
@GET
97-
@Path("/pet/findByTags")
97+
@Path("/findByTags")
9898
@Produces({ "application/xml", "application/json" })
9999
@ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", authorizations = {
100100
@Authorization(value = "petstore_auth", scopes = {
@@ -116,7 +116,7 @@ public interface PetApi {
116116
* @return Pet not found
117117
*/
118118
@GET
119-
@Path("/pet/{petId}")
119+
@Path("/{petId}")
120120
@Produces({ "application/xml", "application/json" })
121121
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", authorizations = {
122122

@@ -139,7 +139,6 @@ public interface PetApi {
139139
* @return Validation exception
140140
*/
141141
@PUT
142-
@Path("/pet")
143142
@Consumes({ "application/json", "application/xml" })
144143
@ApiOperation(value = "Update an existing pet", notes = "", authorizations = {
145144
@Authorization(value = "petstore_auth", scopes = {
@@ -163,7 +162,7 @@ public interface PetApi {
163162
* @return Invalid input
164163
*/
165164
@POST
166-
@Path("/pet/{petId}")
165+
@Path("/{petId}")
167166
@Consumes({ "application/x-www-form-urlencoded" })
168167
@ApiOperation(value = "Updates a pet in the store with form data", notes = "", authorizations = {
169168
@Authorization(value = "petstore_auth", scopes = {
@@ -184,7 +183,7 @@ public interface PetApi {
184183
* @return successful operation
185184
*/
186185
@POST
187-
@Path("/pet/{petId}/uploadImage")
186+
@Path("/{petId}/uploadImage")
188187
@Consumes({ "multipart/form-data" })
189188
@Produces({ "application/json" })
190189
@ApiOperation(value = "uploads an image", notes = "", authorizations = {

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/StoreApi.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* Represents a collection of functions to interact with the API endpoints.
1919
*/
20+
@Path("/store")
2021
@Api(description = "the store API")
2122
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2223
public interface StoreApi {
@@ -29,7 +30,7 @@ public interface StoreApi {
2930
* @return Order not found
3031
*/
3132
@DELETE
32-
@Path("/store/order/{order_id}")
33+
@Path("/order/{order_id}")
3334
@ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store" })
3435
@ApiResponses(value = {
3536
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@@ -43,7 +44,7 @@ public interface StoreApi {
4344
* @return successful operation
4445
*/
4546
@GET
46-
@Path("/store/inventory")
47+
@Path("/inventory")
4748
@Produces({ "application/json" })
4849
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", authorizations = {
4950

@@ -63,7 +64,7 @@ public interface StoreApi {
6364
* @return Order not found
6465
*/
6566
@GET
66-
@Path("/store/order/{order_id}")
67+
@Path("/order/{order_id}")
6768
@Produces({ "application/xml", "application/json" })
6869
@ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", tags={ "store" })
6970
@ApiResponses(value = {
@@ -81,7 +82,7 @@ public interface StoreApi {
8182
* @return Invalid Order
8283
*/
8384
@POST
84-
@Path("/store/order")
85+
@Path("/order")
8586
@Produces({ "application/xml", "application/json" })
8687
@ApiOperation(value = "Place an order for a pet", notes = "", tags={ "store" })
8788
@ApiResponses(value = {

samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/api/UserApi.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* Represents a collection of functions to interact with the API endpoints.
1919
*/
20+
@Path("/user")
2021
@Api(description = "the user API")
2122
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", comments = "Generator version: 7.18.0-SNAPSHOT")
2223
public interface UserApi {
@@ -28,7 +29,6 @@ public interface UserApi {
2829
* @return successful operation
2930
*/
3031
@POST
31-
@Path("/user")
3232
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", tags={ "user" })
3333
@ApiResponses(value = {
3434
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@@ -42,7 +42,7 @@ public interface UserApi {
4242
* @return successful operation
4343
*/
4444
@POST
45-
@Path("/user/createWithArray")
45+
@Path("/createWithArray")
4646
@ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user" })
4747
@ApiResponses(value = {
4848
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@@ -56,7 +56,7 @@ public interface UserApi {
5656
* @return successful operation
5757
*/
5858
@POST
59-
@Path("/user/createWithList")
59+
@Path("/createWithList")
6060
@ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user" })
6161
@ApiResponses(value = {
6262
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@@ -71,7 +71,7 @@ public interface UserApi {
7171
* @return User not found
7272
*/
7373
@DELETE
74-
@Path("/user/{username}")
74+
@Path("/{username}")
7575
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", tags={ "user" })
7676
@ApiResponses(value = {
7777
@ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
@@ -88,7 +88,7 @@ public interface UserApi {
8888
* @return User not found
8989
*/
9090
@GET
91-
@Path("/user/{username}")
91+
@Path("/{username}")
9292
@Produces({ "application/xml", "application/json" })
9393
@ApiOperation(value = "Get user by user name", notes = "", tags={ "user" })
9494
@ApiResponses(value = {
@@ -107,7 +107,7 @@ public interface UserApi {
107107
* @return Invalid username/password supplied
108108
*/
109109
@GET
110-
@Path("/user/login")
110+
@Path("/login")
111111
@Produces({ "application/xml", "application/json" })
112112
@ApiOperation(value = "Logs user into the system", notes = "", tags={ "user" })
113113
@ApiResponses(value = {
@@ -122,7 +122,7 @@ public interface UserApi {
122122
* @return successful operation
123123
*/
124124
@GET
125-
@Path("/user/logout")
125+
@Path("/logout")
126126
@ApiOperation(value = "Logs out current logged in user session", notes = "", tags={ "user" })
127127
@ApiResponses(value = {
128128
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@@ -138,7 +138,7 @@ public interface UserApi {
138138
* @return User not found
139139
*/
140140
@PUT
141-
@Path("/user/{username}")
141+
@Path("/{username}")
142142
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", tags={ "user" })
143143
@ApiResponses(value = {
144144
@ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),

0 commit comments

Comments
 (0)