Skip to content

Commit 42a9368

Browse files
Zomzogwing328
authored andcommitted
Fix JaxRS-Jersey template for files upload (#2570)
* Fix JaxRS-Jersey template for files For #2474 * Samples * PR Review * Samples * Add openapi3 to sample script jaxrs server all * Sample
1 parent 1436ee1 commit 42a9368

File tree

26 files changed

+138
-136
lines changed

26 files changed

+138
-136
lines changed

bin/java-jaxrs-petstore-server-all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
./bin/jaxrs-spec-petstore-server.sh
1919
./bin/jaxrs-usetags-petstore-server.sh
2020

21+
./bin/openapi3/jaxrs-jersey-petstore.sh
22+
2123
echo " Please run ./bin/jaxrs-cxf-petstore-server-test-data.sh manually instead"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class {{classname}} {
7676
{{/hasMore}}{{/responses}} })
7777
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
7878
throws NotFoundException {
79-
return delegate.{{nickname}}({{#allParams}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
79+
return delegate.{{nickname}}({{#allParams}}{{#isFormParam}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{/isFormParam}}{{^isFile}}{{paramName}}{{/isFile}}{{^isFormParam}}{{#isFile}}{{paramName}}{{/isFile}}{{/isFormParam}}, {{/allParams}}securityContext);
8080
}
8181
{{/operation}}
8282
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/AnotherFakeApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
6565
public Response call123testSpecialTags(@ApiParam(value = "client model" ,required=true) @NotNull @Valid Client body
6666
,@Context SecurityContext securityContext)
6767
throws NotFoundException {
68-
return delegate.call123testSpecialTags(body,securityContext);
68+
return delegate.call123testSpecialTags(body, securityContext);
6969
}
7070
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/FakeApi.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public FakeApi(@Context ServletConfig servletContext) {
7575
public Response createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true) @NotNull @Valid XmlItem xmlItem
7676
,@Context SecurityContext securityContext)
7777
throws NotFoundException {
78-
return delegate.createXmlItem(xmlItem,securityContext);
78+
return delegate.createXmlItem(xmlItem, securityContext);
7979
}
8080
@POST
8181
@Path("/outer/boolean")
@@ -87,7 +87,7 @@ public Response createXmlItem(@ApiParam(value = "XmlItem Body" ,required=true) @
8787
public Response fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) Boolean body
8888
,@Context SecurityContext securityContext)
8989
throws NotFoundException {
90-
return delegate.fakeOuterBooleanSerialize(body,securityContext);
90+
return delegate.fakeOuterBooleanSerialize(body, securityContext);
9191
}
9292
@POST
9393
@Path("/outer/composite")
@@ -99,7 +99,7 @@ public Response fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as po
9999
public Response fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid OuterComposite body
100100
,@Context SecurityContext securityContext)
101101
throws NotFoundException {
102-
return delegate.fakeOuterCompositeSerialize(body,securityContext);
102+
return delegate.fakeOuterCompositeSerialize(body, securityContext);
103103
}
104104
@POST
105105
@Path("/outer/number")
@@ -111,7 +111,7 @@ public Response fakeOuterCompositeSerialize(@ApiParam(value = "Input composite a
111111
public Response fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) BigDecimal body
112112
,@Context SecurityContext securityContext)
113113
throws NotFoundException {
114-
return delegate.fakeOuterNumberSerialize(body,securityContext);
114+
return delegate.fakeOuterNumberSerialize(body, securityContext);
115115
}
116116
@POST
117117
@Path("/outer/string")
@@ -123,7 +123,7 @@ public Response fakeOuterNumberSerialize(@ApiParam(value = "Input number as post
123123
public Response fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) String body
124124
,@Context SecurityContext securityContext)
125125
throws NotFoundException {
126-
return delegate.fakeOuterStringSerialize(body,securityContext);
126+
return delegate.fakeOuterStringSerialize(body, securityContext);
127127
}
128128
@PUT
129129
@Path("/body-with-file-schema")
@@ -135,7 +135,7 @@ public Response fakeOuterStringSerialize(@ApiParam(value = "Input string as post
135135
public Response testBodyWithFileSchema(@ApiParam(value = "" ,required=true) @NotNull @Valid FileSchemaTestClass body
136136
,@Context SecurityContext securityContext)
137137
throws NotFoundException {
138-
return delegate.testBodyWithFileSchema(body,securityContext);
138+
return delegate.testBodyWithFileSchema(body, securityContext);
139139
}
140140
@PUT
141141
@Path("/body-with-query-params")
@@ -148,7 +148,7 @@ public Response testBodyWithQueryParams(@ApiParam(value = "",required=true) @Que
148148
,@ApiParam(value = "" ,required=true) @NotNull @Valid User body
149149
,@Context SecurityContext securityContext)
150150
throws NotFoundException {
151-
return delegate.testBodyWithQueryParams(query,body,securityContext);
151+
return delegate.testBodyWithQueryParams(query, body, securityContext);
152152
}
153153
@PATCH
154154

@@ -160,7 +160,7 @@ public Response testBodyWithQueryParams(@ApiParam(value = "",required=true) @Que
160160
public Response testClientModel(@ApiParam(value = "client model" ,required=true) @NotNull @Valid Client body
161161
,@Context SecurityContext securityContext)
162162
throws NotFoundException {
163-
return delegate.testClientModel(body,securityContext);
163+
return delegate.testClientModel(body, securityContext);
164164
}
165165
@POST
166166

@@ -191,7 +191,7 @@ public Response testEndpointParameters(@ApiParam(value = "None", required=true)
191191
,@ApiParam(value = "None") @FormParam("callback") String paramCallback
192192
,@Context SecurityContext securityContext)
193193
throws NotFoundException {
194-
return delegate.testEndpointParameters(number,_double,patternWithoutDelimiter,_byte,integer,int32,int64,_float,string,binaryInputStream, binaryDetail,date,dateTime,password,paramCallback,securityContext);
194+
return delegate.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binaryInputStream, binaryDetail, date, dateTime, password, paramCallback, securityContext);
195195
}
196196
@GET
197197

@@ -212,7 +212,7 @@ public Response testEnumParameters(@ApiParam(value = "Header parameter enum test
212212
,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @DefaultValue("-efg") @FormParam("enum_form_string") String enumFormString
213213
,@Context SecurityContext securityContext)
214214
throws NotFoundException {
215-
return delegate.testEnumParameters(enumHeaderStringArray,enumHeaderString,enumQueryStringArray,enumQueryString,enumQueryInteger,enumQueryDouble,enumFormStringArray,enumFormString,securityContext);
215+
return delegate.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString, securityContext);
216216
}
217217
@DELETE
218218

@@ -229,7 +229,7 @@ public Response testGroupParameters(@ApiParam(value = "Required String in group
229229
,@ApiParam(value = "Integer in group parameters") @QueryParam("int64_group") Long int64Group
230230
,@Context SecurityContext securityContext)
231231
throws NotFoundException {
232-
return delegate.testGroupParameters(requiredStringGroup,requiredBooleanGroup,requiredInt64Group,stringGroup,booleanGroup,int64Group,securityContext);
232+
return delegate.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group, securityContext);
233233
}
234234
@POST
235235
@Path("/inline-additionalProperties")
@@ -241,7 +241,7 @@ public Response testGroupParameters(@ApiParam(value = "Required String in group
241241
public Response testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true) @NotNull @Valid Map<String, String> param
242242
,@Context SecurityContext securityContext)
243243
throws NotFoundException {
244-
return delegate.testInlineAdditionalProperties(param,securityContext);
244+
return delegate.testInlineAdditionalProperties(param, securityContext);
245245
}
246246
@GET
247247
@Path("/jsonFormData")
@@ -254,7 +254,7 @@ public Response testJsonFormData(@ApiParam(value = "field1", required=true) @Fo
254254
,@ApiParam(value = "field2", required=true) @FormParam("param2") String param2
255255
,@Context SecurityContext securityContext)
256256
throws NotFoundException {
257-
return delegate.testJsonFormData(param,param2,securityContext);
257+
return delegate.testJsonFormData(param, param2, securityContext);
258258
}
259259
@POST
260260
@Path("/{petId}/uploadImageWithRequiredFile")
@@ -275,6 +275,6 @@ public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to updat
275275
,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata") String additionalMetadata
276276
,@Context SecurityContext securityContext)
277277
throws NotFoundException {
278-
return delegate.uploadFileWithRequiredFile(petId,requiredFileInputStream, requiredFileDetail,additionalMetadata,securityContext);
278+
return delegate.uploadFileWithRequiredFile(petId, requiredFileInputStream, requiredFileDetail, additionalMetadata, securityContext);
279279
}
280280
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/FakeClassnameTestApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ public FakeClassnameTestApi(@Context ServletConfig servletContext) {
6767
public Response testClassname(@ApiParam(value = "client model" ,required=true) @NotNull @Valid Client body
6868
,@Context SecurityContext securityContext)
6969
throws NotFoundException {
70-
return delegate.testClassname(body,securityContext);
70+
return delegate.testClassname(body, securityContext);
7171
}
7272
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/PetApi.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public PetApi(@Context ServletConfig servletContext) {
7272
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) @NotNull @Valid Pet body
7373
,@Context SecurityContext securityContext)
7474
throws NotFoundException {
75-
return delegate.addPet(body,securityContext);
75+
return delegate.addPet(body, securityContext);
7676
}
7777
@DELETE
7878
@Path("/{petId}")
@@ -90,7 +90,7 @@ public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @P
9090
,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey
9191
,@Context SecurityContext securityContext)
9292
throws NotFoundException {
93-
return delegate.deletePet(petId,apiKey,securityContext);
93+
return delegate.deletePet(petId, apiKey, securityContext);
9494
}
9595
@GET
9696
@Path("/findByStatus")
@@ -109,7 +109,7 @@ public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @P
109109
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter",required=true, allowableValues="available, pending, sold", defaultValue="new ArrayList<>()") @DefaultValue("new ArrayList<>()") @QueryParam("status") List<String> status
110110
,@Context SecurityContext securityContext)
111111
throws NotFoundException {
112-
return delegate.findPetsByStatus(status,securityContext);
112+
return delegate.findPetsByStatus(status, securityContext);
113113
}
114114
@GET
115115
@Path("/findByTags")
@@ -128,7 +128,7 @@ public Response findPetsByStatus(@ApiParam(value = "Status values that need to b
128128
public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true, defaultValue="new ArrayList<>()") @DefaultValue("new ArrayList<>()") @QueryParam("tags") List<String> tags
129129
,@Context SecurityContext securityContext)
130130
throws NotFoundException {
131-
return delegate.findPetsByTags(tags,securityContext);
131+
return delegate.findPetsByTags(tags, securityContext);
132132
}
133133
@GET
134134
@Path("/{petId}")
@@ -146,7 +146,7 @@ public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=tr
146146
public Response getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathParam("petId") Long petId
147147
,@Context SecurityContext securityContext)
148148
throws NotFoundException {
149-
return delegate.getPetById(petId,securityContext);
149+
return delegate.getPetById(petId, securityContext);
150150
}
151151
@PUT
152152

@@ -167,7 +167,7 @@ public Response getPetById(@ApiParam(value = "ID of pet to return",required=true
167167
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) @NotNull @Valid Pet body
168168
,@Context SecurityContext securityContext)
169169
throws NotFoundException {
170-
return delegate.updatePet(body,securityContext);
170+
return delegate.updatePet(body, securityContext);
171171
}
172172
@POST
173173
@Path("/{petId}")
@@ -186,7 +186,7 @@ public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be
186186
,@ApiParam(value = "Updated status of the pet") @FormParam("status") String status
187187
,@Context SecurityContext securityContext)
188188
throws NotFoundException {
189-
return delegate.updatePetWithForm(petId,name,status,securityContext);
189+
return delegate.updatePetWithForm(petId, name, status, securityContext);
190190
}
191191
@POST
192192
@Path("/{petId}/uploadImage")
@@ -207,6 +207,6 @@ public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true
207207
@FormDataParam("file") FormDataContentDisposition fileDetail
208208
,@Context SecurityContext securityContext)
209209
throws NotFoundException {
210-
return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext);
210+
return delegate.uploadFile(petId, additionalMetadata, fileInputStream, fileDetail, securityContext);
211211
}
212212
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/StoreApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public StoreApi(@Context ServletConfig servletContext) {
6868
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("order_id") String orderId
6969
,@Context SecurityContext securityContext)
7070
throws NotFoundException {
71-
return delegate.deleteOrder(orderId,securityContext);
71+
return delegate.deleteOrder(orderId, securityContext);
7272
}
7373
@GET
7474
@Path("/inventory")
@@ -97,7 +97,7 @@ public Response getInventory(@Context SecurityContext securityContext)
9797
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("order_id") Long orderId
9898
,@Context SecurityContext securityContext)
9999
throws NotFoundException {
100-
return delegate.getOrderById(orderId,securityContext);
100+
return delegate.getOrderById(orderId, securityContext);
101101
}
102102
@POST
103103
@Path("/order")
@@ -111,6 +111,6 @@ public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetch
111111
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) @NotNull @Valid Order body
112112
,@Context SecurityContext securityContext)
113113
throws NotFoundException {
114-
return delegate.placeOrder(body,securityContext);
114+
return delegate.placeOrder(body, securityContext);
115115
}
116116
}

samples/server/petstore/jaxrs-datelib-j8/src/gen/java/org/openapitools/api/UserApi.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public UserApi(@Context ServletConfig servletContext) {
6666
public Response createUser(@ApiParam(value = "Created user object" ,required=true) @NotNull @Valid User body
6767
,@Context SecurityContext securityContext)
6868
throws NotFoundException {
69-
return delegate.createUser(body,securityContext);
69+
return delegate.createUser(body, securityContext);
7070
}
7171
@POST
7272
@Path("/createWithArray")
@@ -78,7 +78,7 @@ public Response createUser(@ApiParam(value = "Created user object" ,required=tru
7878
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) @NotNull @Valid List<User> body
7979
,@Context SecurityContext securityContext)
8080
throws NotFoundException {
81-
return delegate.createUsersWithArrayInput(body,securityContext);
81+
return delegate.createUsersWithArrayInput(body, securityContext);
8282
}
8383
@POST
8484
@Path("/createWithList")
@@ -90,7 +90,7 @@ public Response createUsersWithArrayInput(@ApiParam(value = "List of user object
9090
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) @NotNull @Valid List<User> body
9191
,@Context SecurityContext securityContext)
9292
throws NotFoundException {
93-
return delegate.createUsersWithListInput(body,securityContext);
93+
return delegate.createUsersWithListInput(body, securityContext);
9494
}
9595
@DELETE
9696
@Path("/{username}")
@@ -104,7 +104,7 @@ public Response createUsersWithListInput(@ApiParam(value = "List of user object"
104104
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathParam("username") String username
105105
,@Context SecurityContext securityContext)
106106
throws NotFoundException {
107-
return delegate.deleteUser(username,securityContext);
107+
return delegate.deleteUser(username, securityContext);
108108
}
109109
@GET
110110
@Path("/{username}")
@@ -120,7 +120,7 @@ public Response deleteUser(@ApiParam(value = "The name that needs to be deleted"
120120
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.",required=true) @PathParam("username") String username
121121
,@Context SecurityContext securityContext)
122122
throws NotFoundException {
123-
return delegate.getUserByName(username,securityContext);
123+
return delegate.getUserByName(username, securityContext);
124124
}
125125
@GET
126126
@Path("/login")
@@ -135,7 +135,7 @@ public Response loginUser(@ApiParam(value = "The user name for login",required=t
135135
,@ApiParam(value = "The password for login in clear text",required=true) @QueryParam("password") String password
136136
,@Context SecurityContext securityContext)
137137
throws NotFoundException {
138-
return delegate.loginUser(username,password,securityContext);
138+
return delegate.loginUser(username, password, securityContext);
139139
}
140140
@GET
141141
@Path("/logout")
@@ -161,6 +161,6 @@ public Response updateUser(@ApiParam(value = "name that need to be deleted",requ
161161
,@ApiParam(value = "Updated user object" ,required=true) @NotNull @Valid User body
162162
,@Context SecurityContext securityContext)
163163
throws NotFoundException {
164-
return delegate.updateUser(username,body,securityContext);
164+
return delegate.updateUser(username, body, securityContext);
165165
}
166166
}

samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/AnotherFakeApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ public AnotherFakeApi(@Context ServletConfig servletContext) {
6565
public Response call123testSpecialTags(@ApiParam(value = "client model" ,required=true) @NotNull @Valid Client client
6666
,@Context SecurityContext securityContext)
6767
throws NotFoundException {
68-
return delegate.call123testSpecialTags(client,securityContext);
68+
return delegate.call123testSpecialTags(client, securityContext);
6969
}
7070
}

0 commit comments

Comments
 (0)