[英]Enunciate with Swagger - cannot generate documentation resource models when using generics
I'm facing similar issue than the one described in that thread : 我面临的问题与该线程中描述的问题类似:
Can Enunciate generate docs for an API that handles generic types? Enunciuncate可以为处理通用类型的API生成文档吗?
I am using enunciate 1.28 with spring and swagger modules enabled. 我正在使用启用了spring和swagger模块的enunciate 1.28。
So considering an abstract resource class like : 因此,考虑一个抽象资源类,例如:
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);
}
}
and one concrete implementation : 和一个具体的实现:
@Path("/authors")
public class AuthorResource extends AbstractResource<Author> { }
For GET I have : 对于GET我有:
Response Body element: (custom)`
and POST : 和POST:
Request Body element: entity`
However the Author model is listed in the AuthorResource.json generated in swagger/ui directory. 但是Author模型在swagger / ui目录中生成的AuthorResource.json中列出。 The responseClass and dataType fields are just missing the link to the model. responseClass和dataType字段仅缺少指向模型的链接。
Manually replacing : 手动更换:
"responseClass" : "string"` by `"responseClass" : "ns0_Author" (GET)
"dataType" : "string"` by `"dataType" : "ns0_Author" (POST)
does the trick. 绝招。
Note : I confirm that on my side Author is annotated with @XmlRootElement and the Author class is included in my <api-import pattern="com.my.package.**"/>
which is located in a jar file on the classpath. 注意:我确认我这一边的作者用@XmlRootElement注释,并且Author类包含在我的<api-import pattern="com.my.package.**"/>
,该文件位于类路径的jar文件中。
Any ideas on how to tweak the Enunciate/Swagger documentation generation in that case ? 在这种情况下,如何调整Enunciate / Swagger文档生成的任何想法?
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.