This example explains how Quarkus application can expose its API description through an OpenAPI specification and how one can test it via a user-friendly UI named Swagger UI.
In this example we are going to see how REST APIs Document Specification can be generated Using OPENAPI and SWAGGER UI from external static openapi.yaml file in just 7 Simple Steps.
Prerequisites To complete this example:
- An IDE
- JDK 11+ installed with JAVA_HOME configured appropriately
- Apache Maven 3.8.1+
Here are the Steps:
1. Create a maven project using Quarkus and add the below Dependencies in pom.xml
2. Create the static openapi file to serve which must be a valid document conforming to the OpenAPI specification. The openapi file can be represented in yaml or json
formats.
3. Here is our openapi.yaml file looks like
4. Place static OpenAPI document file under META-INF/openapi.yaml.
To serve the static OpenAPI document we will add mp.openapi.scan.disable=true
configuration into application.properties.
5. run Quarkus application in dev using below command
6. Quarkus Application will be started with below logs:
7. Open this URL http://localhost:8080/q/teachlea/ in browser, It will load the OpenApi Specification in swager-ui page.
0 Comments