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

  1. 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"
    Copy to Clipboard Toggle word wrap

    The following dependency is added to your pom.xml:

    pom.xml

    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-smallrye-openapi</artifactId>
    </dependency>
    Copy to Clipboard Toggle word wrap

  2. Obtain the schema document from the /q/openapi. Enter the following command:

    curl http://localhost:8080/q/openapi
    Copy to Clipboard Toggle word wrap

    You receive a response with the generated OpenAPI schema document in YAML format:

    ---
    openapi: 3.0.3
    info:
      title: Generated API
      version: "1.0"
    paths:
      /greeting:
        get:
          responses:
            "200":
              description: OK
              content:
                text/plain:
                  schema:
                    type: string
      /greeting/{name}:
        get:
          parameters:
          - name: name
            in: path
            required: true
            schema:
              type: string
          responses:
            "200":
              description: OK
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/Greeting'
    components:
      schemas:
        Greeting:
          type: object
          properties:
            message:
              type: string
    Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat