2014-09-12 75 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