简体   繁体   English

如何在“swagger-ui/index.html”中显示手动生成的 OAS

[英]How to display a manually generated OAS in "swagger-ui/index.html"

I've created a REST API with Spring Boot as a project for a boot camp.我创建了一个 REST API 和 Spring Boot 作为新兵训练营的项目。

After finishing it, I decided to document the endpoints and found "springdoc-openapi-ui" (which I understand is meant to create automatically documentation based on my project code)完成后,我决定记录端点并找到“springdoc-openapi-ui”(我理解它是为了根据我的项目代码自动创建文档)

The thing is, I've found the results quite disappointing so I took the JSON from "/v3/api-docs/", and pasted it into the online Swagger Editor问题是,我发现结果非常令人失望,所以我从“/v3/api-docs/”中取出 JSON,并将其粘贴到在线Swagger 编辑器

Once I finished creating a beautiful documentation I realized I don't know how to make the "swagger-ui/index.html" point to my swagger.json or swagger.yaml automatically. Once I finished creating a beautiful documentation I realized I don't know how to make the "swagger-ui/index.html" point to my swagger.json or swagger.yaml automatically. I've read in the Swagger UI configuration guide that I can create a "swagger-configuration.YAML" file and define a parameter called spec where I can point to my JSON object but I couldn't understand exactly how to implement that solution (don't know where to place the file and the syntaxes for said configuration) Another option I read somewhere on this page (can't find it now) was to embed the JSON in the index.html as a script but there was no example on how to do it correctly我已经阅读了 Swagger UI 配置指南,我可以创建一个“swagger-configuration.YAML”文件并定义一个名为 spec 的参数,我可以在其中指向我的 JSON ZA8CFDE6331BD59EB2AC96F8911C4B66不知道将文件放在哪里以及所述配置的语法)我在此页面某处读到的另一个选项(现在找不到)是将 JSON 嵌入 index.html 作为脚本,但没有示例关于如何正确地做

Which was the whole point of creating manually my documentation这是手动创建我的文档的重点

I'll appreciate any help and I hope I've been clear to explain what I'm looking for.我会很感激任何帮助,我希望我已经清楚地解释了我在寻找什么。

I've found the solution Extracted from Springdoc.org - FAQ我找到了从Springdoc.org 中提取的解决方案 - 常见问题解答

If your file open-api.json, contains the OpenAPI documentation in OpenAPI 3 format.如果您的文件 open-api.json 包含 OpenAPI 3 格式的 OpenAPI 文档。 Then simply declare: The file name can be anything you want, from the moment your declaration is consistent yaml or json OpenAPI Spec.然后简单地声明:文件名可以是任何你想要的,从你声明的那一刻起,你的声明是一致的 yaml 或 json OpenAPI Spec。

springdoc.swagger-ui.url=/open-api.json springdoc.swagger-ui.url=/open-api.json

Then the file open-api.json, should be located in: src/main/resources/static No additional configuration is needed.然后文件 open-api.json,应该位于:src/main/resources/static 不需要额外配置。

暂无
暂无

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

相关问题 如何在 swagger-UI 中的 index.html 中设置 url - How to set url in index.html in swagger-UI Swagger 错误 Springboot Could not resolve view with name 'forward:/swagger-ui/index.html' - Swagger error Springboot Could not resolve view with name 'forward:/swagger-ui/index.html' Spring springdoc-openapi:swagger-ui/index.html 找不到状态=404 - Spring springdoc-openapi : swagger-ui/index.html cannot be found status=404 获取,java.lang.IllegalArgumentException:访问swagger-ui时,路径index.html不能以“ /”字符开头 - Get, java.lang.IllegalArgumentException: Path index.html does not start with a “/” character, when accessing swagger-ui 如何在swagger-ui生成的文档中显示@PostMapping参数? - How to show @PostMapping parameters in swagger-ui generated docs? 如何在 swagger-ui 上显示“/oauth/token”端点? - How to display “/oauth/token” endpoint on swagger-ui? 如何在 spring-boot 中完全禁用 swagger-ui?(/swagger-ui.html 应该返回 404) - How to fully disable swagger-ui in spring-boot?(/swagger-ui.html should return 404) Swagger UI在index.html页面上不显示任何内容 - Swagger UI Not Displaying Any Content On index.html Page springdoc-openapi-ui生成的swagger-ui中如何更改请求header中授权key的名称 - How to change the name of the authorization key in the request header in the swagger-ui generated by springdoc-openapi-ui 如何在webapp中查看我的index.html文件,该文件是从url上的swagger ui克隆的 - how to view my index.html file inside webapp which is cloned from swagger ui on a url
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM