swagger-api / swagger-api/swagger-codegen
[jaxrs-resteasy] Tags not considered when generating API classes
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
For jaxrs-resteasy server stub code generation, the naming/grouping of API classes with tags as described here does not work.
In the below example I would expect an OperationOneApi and OperationTwoApi to be generated. Instead I get a SourceApi because of the path parameter {source}.
Swagger-codegen version
2.2.0
Swagger declaration file content or url
swagger: "2.0"
info:
version: "0.2"
title: title
description: description
consumes:
- application/json
produces:
- application/json
paths:
/{source}/operationOne:
post:
tags:
- operationOne
parameters:
- name: source
in: path
required: true
type: string
responses:
'200':
description: response
/{source}/operationTwo:
post:
tags:
- operationTwo
parameters:
- name: source
in: path
required: true
type: string
responses:
'200':
description: response
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i test.yml -l jaxrs-resteasy -o generated
Steps to reproduce
see above
Related issues
#820
Suggest a Fix
Though I do not really understand the structure of the code, it seems to me that the problem is located in JavaResteasyServerCodegen.addOperationToGroup().
The method is identical (or, some would say "copy&paste") to other classes of the io.swagger.codegen.languages package, but the tag parameter is never used.
If I replace the method with the same method from JavaCXFServerCodegen
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
super.addOperationToGroup(tag, resourcePath, operation, co, operations);
co.subresourceOperation = !co.path.isEmpty();
}
then it works for me. But I have no idea if this is the right way...
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 with JavaResteasyServerCodegen.addOperationToGroup() and compare its handling with JavaCXFServerCodegen.addOperationToGroup(). Run the supplied swagger-codegen-cli command with the YAML example, then verify that the tagged operations generate separate OperationOneApi and OperationTwoApi classes rather than SourceApi.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100