Automatic OpenAPI YAML generation - maven

I am working on the backend of a Spring Boot application that uses OpenAPI and Swagger to provide the interface for frontend application via an schema.yml file.
When a change is done on the controllers, we use the swagger-ui to get the api-docs JSON, convert it to yaml using the online swagger editor and paste the result in th schema.yml file
Now, I want to automate this so that we can just call a maven task that will automatically generate the yaml file, but I could not find any maven plugin that does this.
Is there a way to automate the generation of the yaml file or do I need to write my own plugin?

Related

How to generate an OpenAPI from a Spring app without running the app?

I can run a Spring Boot application and then use the springdoc-openapi-maven-plugin artifact to generate an OpenAPI spec.
However, is there also a way to generate the spec without running the application first?
I currently want to generate the spec in a GitHub Action and a direct way would simplify this a lot.
you can use swagger editor: https://editor.swagger.io/
It allows you to write a json/yaml with your specifications and at the same time you can view the result.
Also, in the upper part there are 2 features, which allow you to generate the code based on the json/yaml made.
For example you can create a spring application with all the endpoints you go to specify in your json/yaml ( server).
But you can also generate HTML. (Client)

Is there any example to generate a OAS3 html from yaml file using open-api generator

Is there any way to auto generate HTML file (same look and feel as swagger-editor) using maven dependency / plugin using existing YAML file?
Note: I'm targeting for OAS3 version.
Even the swagger editor > Generate Client > html OR html2 generates the look and feel which is different.
Will the following site https://springdoc.github.io/springdoc-openapi-demos be helpful in this aspect?

Maven Generate OpenAPI JSON for SpringBoot REST Controllers

Is there a Maven plugin which can generate an openapi.json file at build time for my SpringBoot RestControllers?
If not a Maven plugin, is there another simple package to generate the file at build time?
I only want the openapi.json file, I don't want Swagger UIs auto-integrated, etc.
I was able to get this working with SpringDoc.
I couldn't find a project which showed exactly my use-case (without all the swagger ui stuff), so I created an example project on GitHub for others to use as reference: springdoc-maven-plugin-demo
You can use Spring-doc which support OpenAPI 3
Look at the demos

Append Custom Tags in Swagger.yaml using swagger-maven plugin

I am using swagger-maven plugin to generate swagger.yaml for a spring boot 2 application. The plugin works fine for the default feilds like info, description,vender extension etc.
However, I need to append some custom yaml to the generated swagger.yaml. ex:
X-client-integration
Name:test
Package: test package
Catalogs:
-id: x
Seq:1
-id:y
Seq:2
This appended yaml can be hard coded or copied from a file from a project.
Is there any way to achieve this?

swagger ui without swagger auto apidoc json generation

I'd like to use the nice io.springfox:springfox-swagger-ui interface but I don't want to have my documentation auto generated via annotations in my springboot app (/v2/api-docs).
I have my proper swagger-api.json api description file under my project resources, how can I tell swagger-ui to use it as default ?
I tried to use: springfox.documentation.swagger.v2.path=/swagger-config.json as swagger properties but it does not use my file.

Resources