-
Notifications
You must be signed in to change notification settings - Fork 6k
Open
Milestone
Description
Description
- the api is generated as class, but IMHO this should be an interface!?
- javax.ws.rs.core.Response is used instead of the real response data type
- @apiresponse uses wrong response type (the return type, not the response type of the contract)
- src/gen/java is not added to the build path
- "Attachment" is used for attachments, but no import is added for this (I think org.apache.cxf.jaxrs.ext.multipart.Attachment is referenced, but this is CXF-specific)
(see also JavaJaxRS spec : formParam uses Attachment which is CXF specific #4327)
Swagger-codegen version
2.2.2-SNAPSHOT
Related issues
Suggest a Fix
- generate api as interface (which then can be easily implemented)
changed in api.mustache, added new apiServiceImpl.mustache for implementation class
- use real response data types instead of javax.ws.rs.core.Response (x)
should be changed separately see #4713
- fix * @apiresponse data types
fixed in AbstractJavaJAXRSServerCodegen by adding a check for void for api-response:
// set vendorExtensions.x-java-is-response-void to true as dataType is set to "void"
if ( resp.dataType == null ) {
resp.vendorExtensions.put("x-java-is-response-void", true);
}and in api.mustache by adding the check for void and by using the baseType instead of returnType of @ApiReponse.
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}, response = {{{baseType}}}.class{{/vendorExtensions.x-java-is-response-void}}- add src/gen/java to the buildpath
- look for alternatives for JAXRS-compliant alternatives to org.apache.cxf.jaxrs.ext.multipart.Attachment or comment it out
as there is currently no standardized way for supporting multipart/form-data (see https://java.net/jira/browse/JAX_RS_SPEC-413), I changed formParams.mustache to
@FormParam(value = "{{paramName}}") InputStream {{paramName}}InputStreamThis should be a sufficient standard hint, although it will have to be adapted for CXF/Jersey/Resteasy then.
blub0hr and moshelav