-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix JaxRS-Jersey template for files upload #2570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
thanks for you PR but with this change, it seem like there is a regression with type file in OAS2 :
you can refer to swagger-api/swagger-codegen#3300 |
@@ -76,7 +76,7 @@ public class {{classname}} { | |||
{{/hasMore}}{{/responses}} }) | |||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext) | |||
throws NotFoundException { | |||
return delegate.{{nickname}}({{#allParams}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext); | |||
return delegate.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}securityContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually the real problem is the missing isFormParam
in this condition. the formParams.mustache who generate an InputStream and an FormDataContentDisposition variables are conditionned with the isFormParam
so this line should be fixed with :
return delegate.{{nickname}}({{#allParams}}{{#isFormParam}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{/isFormParam}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
to solve the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the template with something inspired by your solution.
I've tried it with the issue's sample and this one :
/Plugin:
post:
summary: uploads an image
description: ''
operationId: uploadFile
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks . can you please push your new commit to your branch "2474" to update the PR ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be useful. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
circle-ci error doesn't seem to be caused by this change
can you please edit the PR description and add "fix #2474" to auto-close the related issue when PR will be merged ? thanks
Please update the samples:
Tested via https://circleci.com/gh/OpenAPITools/openapi-generator/5930#tests/containers/2 |
I've updated java-jaxrs-petstore-server-all.sh to run also this sample and run it. |
CircleCI test passed via https://circleci.com/gh/OpenAPITools/openapi-generator/5932 |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,. Default:3.4.x
,4.0.x
master
.Description of the PR
Remove specific File management from template to align it with the service.
fix #2474
@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03)