简体   繁体   English

使用 Spring REST Docs 生成 Swagger 客户端

[英]Swagger client generation with Spring REST Docs

I have seen this Spring REST Docs - video我看过这个 Spring REST Docs -视频

We are doing Spring boot projects and are using springfox library for generating the Swagger-ui and swagger documentation as outlinedhere我们正在做的春天启动的项目和使用springfox库所概述产生扬鞭的UI和招摇文档在这里

We like what Spring Rest docs can do for generating REST API documentation and the fact that we don't have to add swagger annotations like @ApiResponse or @ApiOperation in our Controller code.我们喜欢 Spring Rest 文档可以为生成 REST API 文档所做的事情,以及我们不必在控制器代码中添加像 @ApiResponse 或 @ApiOperation 这样的大摇大摆的注释这一事实。 And also the fact that the documentation now lives with the code.以及文档现在与代码一起存在的事实。

But if go with Spring Rest docs, we will miss out on the Swagger-UI that gets automatically generated for our API (when we use swagger integration).但是如果使用 Spring Rest 文档,我们将错过为我们的 API 自动生成的 Swagger-UI(当我们使用 swagger 集成时)。

Is it possible for Spring REST docs to generate a test UI like Swagger UI. Spring REST 文档是否可以生成像 Swagger UI 这样的测试 UI。

That pretty directly goes against the design idea and intention of Spring REST Docs.这直接违背了 Spring REST Docs 的设计思想和意图。 One of the main goals of it is that the docs are tied to unit tests so you know your documentation is rock solid even when you make logic or signature changes in your REST contract.它的主要目标之一是将文档与单元测试相关联,因此即使您在 REST 合同中进行逻辑或签名更改,您也知道您的文档坚如磐石。

Also as the video you linked to provided a number of examples of how automated docs generation produces a lot of undesirable un-intended output.此外,您链接到的视频提供了许多示例,说明自动化文档生成如何产生大量不需要的意外输出。

So its a choice of do more work to get much better docs, or do the fully automated option to save time and get workable, but lower quality docs.因此,它可以选择做更多的工作来获得更好的文档,或者选择完全自动化的选项来节省时间并获得可行但质量较低的文档。 It is what ever your priority is.这是您的首要任务。

This project generates an OpenAPI specification from Spring REST Docs.该项目从 Spring REST Docs 生成 OpenAPI 规范。

https://github.com/ePages-de/restdocs-api-spec https://github.com/ePages-de/restdocs-api-spec

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

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