简体   繁体   English

Can Enunciate为处理泛型类型的API生成文档?

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

Given an abstract, generic Resource class and a concrete implementation: 给定一个抽象的,通用的Resource类和具体的实现:

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 . 看来,在为PersonResource生成文档时,Enunciate没有发现get()返回Person的事实。

  1. Person is not listed in the Data Model > Data Types section. Person未列在“数据模型”>“数据类型”部分中。

  2. Under the GET section, Response Body shows the element type as "(custom)". 在GET部分下,Response Body将元素类型显示为“(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? 有没有办法提示发音真实类型是什么,以便正确生成文档?

在此输入图像描述

Is Person annotated as @XmlRootElement ? Person是否注释为@XmlRootElement If so, is it included in the same project as PersonResource ? 如果是这样,它是否与PersonResource包含在同一个项目中? If not, are you importing the Person class as described in Enunciate: Multi-Module Projects ? 如果没有,您是否按照Enunciate:Multi-Module Projects中的描述导入Person类?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM