Skip to content

[Jaxrs-spec] Improvements for Jaxrs-spec #4509

@jfiala

Description

@jfiala
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

#4327

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

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}}InputStream

This should be a sufficient standard hint, although it will have to be adapted for CXF/Jersey/Resteasy then.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions