繁体   English   中英

用Swagger进行发音-使用泛型时无法生成文档资源模型

[英]Enunciate with Swagger - cannot generate documentation resource models when using generics

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

Enunciuncate可以为处理通用类型的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的JSON模型,分别为“ responseClass”和主体的“ dataType”。 相反,我都得到了字符串。

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

手动更换:

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

绝招。

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

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

谢谢

闻起来像臭虫。 在这里跟踪。

暂无
暂无

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

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