4

I found this project https://github.com/OAI/OpenAPI-Specification As I understood we can write documentation in .json/.yml files. Also, I can see in http://editor.swagger.io/ that it could be rendered to .html file.

My question is - how can I generate static .html pages from .json/.yml files? Is there any tutorial for spring boot application? Should I somehow set .json/.yml files to swagger configuration and get .html file with documentation?

1 Answer 1

4

There is no need to generate collection of HTMLs, JavaScripts and CSS assets from the .yml or .json files. Just pass the YAML/JSON file to a server running the Swagger UI and Swagger UI will dynamically generate beautiful documentation from those Swagger-compliant APIs. The petstore example should give you the idea.

You can use a build engine (CI/CD server or whatever) like Jenkins to automate the documentation publishing process. For example, each REST API repository should provide at least one of these .yml or .json files (which by the way are generated by the Swagger Editor). Then after each push to that repository, Jenkins will get those .yml or .json files and upload them to your Documentation server where the Swagger UI is up and running.

REST API developers can share the API documentation link with client developers and also can be confident that each change in the .yml or .json files will be reflected in the documentation. They just need to push the changes. Since you need to maintain those Swagger-compliant APIs, I personally suggest to use the .yml file, simply because it's more readable.

Sign up to request clarification or add additional context in comments.

3 Comments

Is it possible that swagger-ui will render json from same directory? For example I have swagger-ui in my /static content folder and also I have there swagger.json file.
@Orest It should be possible. You just pass the yml file link to the swagger UI
@AliDehghani - How can we pass the custom pagination details through Open API 3 UI ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.