Skip to content

[JAX-RS RESTEasy] Generated JAX-RS RESTEasy stub is missing swagger annotations #4447

@karnik

Description

@karnik
Description

After generating the server stub for my jee test application based on RESTEasy with swagger-codegen the generated swagger.json just shows:

{"swagger":"2.0"}

When I checked the generated server stub I noticed that the swagger annotations are missing. This is also the case with the petstore when exporting the stub with the swagger-editor. When generating for the default JAX-RS (Jersey), the code does include the annotations. For Example:

Pets.java - JAX-RS RESTEasy

@Path("/pets")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-12-21T16:38:44.967Z")
public class PetsApi  {
   private final PetsApiService delegate = PetsApiServiceFactory.getPetsApi();

    @POST
    
    @Consumes({ "application/json" })
    @Produces({ "application/json" })
    public Response addPet( NewPet pet,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.addPet(pet,securityContext);
    }
   . . .
}

PetsApi.java - JAX-RS (Jersey)

@Path("/pets")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@io.swagger.annotations.Api(description = "the pets API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-12-21T16:39:30.729Z")
public class PetsApi  {
   private final PetsApiService delegate = PetsApiServiceFactory.getPetsApi();

    @POST
    
    @Consumes({ "application/json" })
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "Creates a new pet in the store.  Duplicates are allowed", response = Pet.class, tags={  })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "pet response", response = Pet.class),
        
        @io.swagger.annotations.ApiResponse(code = 200, message = "unexpected error", response = Pet.class) })
    public Response addPet(@ApiParam(value = "Pet to add to the store" ,required=true) NewPet pet
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.addPet(pet,securityContext);
    }
   . . .
}

After checking the templates I found out that there is no swagger annotation definition in the RESTEasy templates at all.

Swagger-codegen version

Maven Plugin: 2.2.1
Swagger core: 1.5.10

Swagger declaration file content or url

Used the Swagger Petstore (Simple) definition
swagger.zip

Command line used for generation

Used maven plugin:

                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.1</version>
Steps to reproduce

Generate the JAX-RS RESTEasy server stub with the swagger-codegen maven plugin.

Related issues

Nothing found.

Suggest a Fix

When I add the annotations to the generated code manually they will appear in the generated swagger.json. So adding the annotations to the template should fix this issue!?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions