Can Enunciate generate docs for an API that handles generic types?

纵然是瞬间 提交于 2019-12-06 03:12:02

问题


Given an abstract, generic Resource class and a concrete implementation:

public abstract class AbstractResource<T> {

    @Autowired
    private SomeService<T> service;

    @Path("/{id}")
    @GET
    public T get(@PathParam("id") String id) {
        return service.get(id);
    }
}

@Path("/people")
public class PersonResource extends AbstractResource<Person> { }

It appears that when generating the docs for PersonResource, Enunciate is not picking up the fact that get() returns a Person.

  1. Person is not listed in the Data Model > Data Types section.

  2. Under the GET section, Response Body shows the element type as "(custom)".

Are these issues because of the use of generics as the entity types? Is there a way to hint to Enunciate what the real types are so the documentation can be generated correctly?


回答1:


Is Person annotated as @XmlRootElement? If so, is it included in the same project as PersonResource? If not, are you importing the Person class as described in Enunciate: Multi-Module Projects?



来源:https://stackoverflow.com/questions/15424467/can-enunciate-generate-docs-for-an-api-that-handles-generic-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!