As the name suggests, the OpenAPI Generator generates code from an OpenAPI specification. It can create code for client libraries, server stubs, documentation and configuration. It supports various languages and frameworks.
OpenAPI and Swagger used to refer to the same thing. While there are differences today (OpenAPI refers to RESTful API design and Swagger refers to a set of SmartBear tools), this blog will use the terms interchangeably. If you develop software today, chances are you are developing web APIs as well.
I have an existing Spring REST API for which I want to generate the OpenAPI 3.0 YAML file and not Swagger 2.0 JSON/YAML?
Since as of now, SpringFox does not support YAML generation. It generates JSON with Swagger 2.0 (which follows OPEN API 3.0 spec).
Also, there is https://github.com/openapi-tools/swagger-maven-plugin but it does not seem to support Spring Rest.
I tried the Kongchen spring-maven-plugin which is able to generate the YAML file but with Swagger 2.0 definition and not OPEN API 3.0 like :
swagger: "2.0"
info:
description: "Test rest project"
version: "1.0"
title: "Some desc"
termsOfService: "http://swagger.io/terms/"
contact:
name: "Rest Support"
url: "http://www.swagger.io/support"
email: "[email protected]"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "example.com"
basePath: "/api/"
So my question is how can I generate the OPEN API YAML file like :
openapi: 3.0.0
info:
description: Some desc
version: "1.0"
title: Test rest project
termsOfService: http://swagger.io/terms/
contact:
name: Rest Support
url: http://www.swagger.io/support
email: [email protected]
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
I am currently using swagger-maven-plugin
to generate YAML file with Swagger 2.0 definition and converting it to Open API 3.0 definition using swagger2openapi
at https://mermade.org.uk/openapi-converter
Question 1:
Can spring-maven-plugin capture io.swagger.v3.oas.annotations
to generate the YAML ?
Question 2:
What is the best way to generate the YAML with OPEN API definitions in a Spring MVC Project?
Question 3:
Can io.swagger.v3.oas
be used with Spring projects or it is only for JAX-RS projects?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With