Generating Swagger documentation from existing REST api(从现有的 REST api 生成 Swagger 文档)
问题描述
给定一个现有的带有 JAX-RS 注释的 API,它接受 &返回带有杰克逊注释类型的json,有没有办法可以生成一些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 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从现有的 REST api 生成 Swagger 文档


基础教程推荐
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01