Skip to content

Not scanning model with Generic Type #1344

@kiennguyen

Description

@kiennguyen

Hi, please look at my sample:
I have an abstract class with type variable: T

public abstract class ApiCrudRoute<T extends AbstractEntity, R extends ApiResponse> {
    protected ApiCrudService<T> service;

    @POST
    @ApiOperation(value = "Create")
    public Response doCreate(
            @ApiParam(value = "Create object", required = true) T entity) throws Exception {
        T newEntity = service.create(entity);
        return getResponse(getApiContext().getRequestId(), Status.CREATED, newEntity).build();
    }    
}

//Inherited class:
@Path("/api/users")
@Api(value = "/users")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class UserApiRoute extends ApiCrudRoute<User, UserApiResponse> {
}

//The model inherited from Abstract Model:
@XmlRootElement
@ApiModel(value = "User")
@XmlAccessorType(XmlAccessType.FIELD)
public class User extends AbstractEntity {
    public String name;
}

public abstract class AbstractEntity implements Serializable {
    public String id;
}

We want to have Swagger API "POST /api/users" with model:
{"id":"","name":""}

But we got the empty model {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions