Chapter 6. Enabling OpenAPI and Swagger-UI support in your Spring Web example
You can add support for generating OpenAPI schema documents of your REST endpoints with Swagger-UI to your application by adding the quarkus-smallrye-openapi
extension.
Procedure
Add the
quarkus-smallrye-openapi
extension as a dependency of your Spring Web example. By adding the extension, you can generate a basic OpenAPI schema document from your REST Endpoints. Enter the following command:./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-smallrye-openapi"
./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-smallrye-openapi"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following dependency is added to your
pom.xml
:pom.xml
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-openapi</artifactId> </dependency>
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-openapi</artifactId> </dependency>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the schema document from the
/q/openapi
. Enter the following command:curl http://localhost:8080/q/openapi
curl http://localhost:8080/q/openapi
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You receive a response with the generated OpenAPI schema document in YAML format:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow