1

我面临的问题与该线程中描述的问题类似:

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

我正在使用启用了 spring 和 swagger 模块的 enunciate 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`
  1. 对于 Swagger,作者模型未显示为 GET 的 JSON 模型为“responseClass”,而 POST 为正文“dataType”。相反,我得到了两者的字符串。

但是 Author 模型列在 swagger/ui 目录中生成的 AuthorResource.json 中。responseClass 和 dataType 字段只是缺少模型的链接。

手动更换:

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

成功了。

注意:我确认在我这边 Author 是用 @XmlRootElement 注释的,并且 Author 类包含在我的类中<api-import pattern="com.my.package.**"/>,它位于类路径上的 jar 文件中。

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

谢谢

4

1 回答 1

0

闻起来像虫子。在这里跟踪它。

于 2014-09-17T22:54:54.473 回答