2014-09-12 64 views
1

,当我面临着类似的问题比在线程中描述的一个无法生成文档资源模型:阐明与扬鞭 - 使用泛型

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

我使用字正腔圆1.28启用春季和招摇模块。

所以考虑一个抽象的资源类,如:

public abstract class AbstractResource<T> { 

    @Autowired 
    private SomeService<T> service; 

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

    @POST 
    public Response post(T entity) { 
     return service.post(entity); 
    } 
} 

和一个具体的实现:

@Path("/authors") 
public class AuthorResource extends AbstractResource<Author> { } 
  1. 字正腔圆文档不与适当的“作者”的数据模型生成GET和POST方法。

对于GET我有:

Response Body element: (custom)` 

和POST:

Request Body element: entity` 
  • 对于扬鞭作者模型没有示出作为JSON模型GET作为“responseClass”和POST的身体“dataType”。相反,我得到了两个字符串。
  • 但是,作者模型列在swagger/ui目录中生成的AuthorResource.json中。 responseClass和dataType字段只是缺少到模型的链接。

    手动更换:

    "responseClass" : "string"` by `"responseClass" : "ns0_Author" (GET) 
    "dataType" : "string"` by `"dataType" : "ns0_Author" (POST) 
    

    的伎俩。

    注意:我确认在我的一侧,作者使用@XmlRootElement注释,作者类包含在我的<api-import pattern="com.my.package.**"/>中,该类位于类路径的jar文件中。

    在这种情况下,如何调整Enunciate/Swagger文档生成的任何想法?

    谢谢

    回答

    0

    闻起来像一个错误。跟踪它here