本文介绍了如何为使用JSON JAXB绑定的Jersey REST API生成文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我已经想出我可以在我的服务器上请求/响应它,我想弄清楚如何为不使用Java的人生成有用的文档。我的服务器代码如下所示:

Now that I've figured out how to use JAXB generate JSON I can request/respond with it on my server and I'd like to figure out how I can generate useful documentation for human beings that are not using Java. My server code looks like this:

@POST
@Path("apath")
@Consumes(MediaType.APPLICATION_JSON)
public String postAPath(InstanceWithXmlRootElementAnnotation instanceWithXmlRootElementAnnotation) {

这一切都很好好的,如果有人使用Java。我只是给它们带有 InstanceWithXmlRootElementAnnotation 类的Jar,并告诉他们发送它(是的,还有一些工作,忽略这些细节)。

That's all well in good if someone is using Java. I just give them the Jar with the InstanceWithXmlRootElementAnnotation class in it and tell them to send it over (yes, there's a little more work, ignore those details).

如果他们使用其他语言,我不知道我应该如何告诉他们有效载荷的格式以及服务器的期望值它返回 InstanceWithXmlRootElementAnnotation 。如何生成解释JSON有效负载的预期格式的文档?

If they're using some other language, I don't know how I'm supposed to tell them the format of their payload and what to expect from the server if it returns a InstanceWithXmlRootElementAnnotation. How can I generate documentation that explains the expected format of the JSON payload?

推荐答案

Swagger是一个不错的选择(根据@fehguy)您还应该查看并查看最适合您应用的内容......

Swagger is a good option (per @fehguy) and you should also check out enunciate and see what works best for your application...

这篇关于如何为使用JSON JAXB绑定的Jersey REST API生成文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 20:05