swagger-api / swagger-api/swagger-codegen
[codegen][JAVA-JAXRX-CXF-CLIENT] BUG: Http status code doesn’t have any response attached then Response object has .class
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Have an issue in swagger code gen project for "JAXRX-CXF-CLIENT" client generate option, as it generate response class as ".class". usecase that : http status code doesn’t have any response attached(empty response) to it.
Due to this issue, unable to generate our clients in code through yaml(we are stuck with 2.3.1). This issue has been happening on online Swagger-Editor UI Client generate option as well.
Swagger-codegen version
2.3.1
API Yaml:
delete:
description: deletes a single pet based on the ID supplied
operationId: deletePet
produces:
- application/json
parameters:
- name: id
in: path
description: ID of pet to delete
required: true
type: integer
format: int64
examples: 1
responses:
"204":
description: pet deleted
default:
description: unexpected error
schema:
$ref: '#/definitions/Error'
Command line used for generation
java -jar swagger-codegen-cli-2.3.1.jar generate -i petstore-expanded.yaml -l jaxrx-cxf-client -o mockservice -c java-config.json
Swagger
java-config.json:
{
"dateLibrary" : "java8-localdatetime",
"java8": true
}
Same issue in Swagger UI:
--> Navigate to the https://editor.swagger.io/# and click "jaxrx-cxf-client" under the "Generate Client"
Jax-rx CXF client generated code:
BEFORE FIX:
@DELETE
@Path("/pets/{id}")
@Produces({ "application/json" })
@ApiOperation(value = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 204, message = "pet deleted", response = .class),
@ApiResponse(code = 0, message = "unexpected error", response = Error.class) })
public void deletePet(@PathParam("id") Long id);
AFTER FIX:
@DELETE
@Path("/pets/{id}")
@Produces({ "application/json" })
@ApiOperation(value = "", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 204, message = "pet deleted"),
@ApiResponse(code = 200, message = "unexpected error", response = Error.class) })
public void deletePet(@PathParam("id") Long id);
Would it that possible to fix in 2.3.1 with minor release?
BTW: I don't see this issue in 2.4.0. snapshot version. when would be 2.4.0 would be released?
Please advice?
QuickFix would :
Line: 65 in the following file
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache
add {{#baseType}} {{/baseType}}
{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache around line 65 and reproduce generation with the supplied YAML and jaxrx-cxf-client command. Done means an empty 204 response no longer generates response = .class, while the default Error response remains generated correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100