swagger-api/swagger-codegen

[jaxrs-resteasy] Tags not considered when generating API classes

Open

#3,446 opened on Jul 25, 2016

View on GitHub
 (1 comment) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Issue: BugServer: Javahelp wanted

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