[英]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.