从现有REST API生成Swagger文档 [英] Generating Swagger documentation from existing REST api

查看:234
本文介绍了从现有REST API生成Swagger文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于现有的JAX-RS注释API接受&返回json,带有jackson-annotated类型,有没有办法可以生成一些YAML Swagger文档?我的计划B是编写一些使用反射来查找REST注释类型的代码,制作他们的参数的散列图。返回,然后抓取这些类以获取Jackson注释,并以这种方式生成文档。

Given an existing JAX-RS-annotated API that accepts & returns json, with jackson-annotated types, is there a way that I can generate some YAML Swagger documentation? My plan B is to write some code that uses reflection to find REST-annotated types, make a hashmap of their arguments & returns, and then crawl those classes for Jackson annotations, and generate the documentation that way.

我更愿意使用已经存在的解决方案来编写一次性的东西。我发现这个Swagger模块声称它可以解析Jackson的配置( https://github.com/FasterXML / jackson-module-swagger )但我对Swagger了解不足以了解哪些模块以及是否可以使用它来从现有代码生成Swagger。

I would prefer to use a solution that already exists to writing a one-off thing. I found this Swagger module that claims it can parse Jackson configurations (https://github.com/FasterXML/jackson-module-swagger) but I don't know enough about Swagger to understand what modules are and whether I can use it to generate Swagger from existing code.

推荐答案

您可能想看看这个项目: https://github.com/sdaschner/jaxrs-analyzer

You might want to have a look at this project: https://github.com/sdaschner/jaxrs-analyzer

它可以为JAX-RS自动生成Swagger文档。据我所知,杰克逊没有考虑具体的注释。

It can generate Swagger documentation automatically for JAX-RS. As far as I know Jackson specific annotations are not taken into consideration.

这篇关于从现有REST API生成Swagger文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆