liveBook · Manning

OpenAPI specification

As explained in Quarkus in Action

OpenAPI is a standard machine-readable description of an HTTP API's operations, parameters, and responses.

An OpenAPI specification is a machine-readable description of an HTTP API. In Quarkus, the quarkus-smallrye-openapi extension generates the document from REST resources according to the MicroProfile OpenAPI specification. section 4.10 section 4.2.3

A generated document can describe:

  • Service metadata such as its title and version. section 4.2.3
  • REST paths and operations, including request bodies, response codes, media types, and schemas. section 4.2.3
  • JSON representations linked to application classes through component schema references. section 4.2.3

Swagger UI provides a graphical view of the specification and lets developers execute the documented operations in a browser. Quarkus exposes the document at /q/openapi and the UI at /q/swagger-ui. section 4.2.3

Reservation service

A generated document can describe POST /reservation as accepting and returning application/json, with both payloads represented by a Reservation schema. The same interface can expose GET /reservation/availability for checking available cars. section 4.2.3

Listing 4.9 The OpenAPI document of the Reservation service
---
openapi: 3.0.3
info:
  title: reservation-service API
  version: 1.0.0-SNAPSHOT
paths:
  /reservation:
    post:
      tags:
      - Reservation Resource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reservation'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Reservation'

Inspect the generated OpenAPI document to see service metadata, paths, HTTP operations, JSON content types, responses, and schema references. section 4.2.3

Swagger UI is included by default in Dev mode. Production deployments require quarkus.swagger-ui.always-include=true when the interactive UI should remain available; document customization is possible but deferred. section 4.2.3

How Quarkus in Action covers it

How deep it goes
Explains generated metadata, operations, payload schemas, and responses, but defers document customization.
Examples
Uses a reservation service with POST and GET operations, Reservation schemas, JSON payloads, and available-car responses.
What it assumes
Assumes REST resources and JSON-based HTTP operations, while showing their generated API description from application code.
What you can do after
Operate/configure Quarkus endpoints through generated OpenAPI documents and Swagger UI, including production UI availability.
How it connects
Connects REST resources, Swagger UI, Quarkus, and the MicroProfile OpenAPI specification.

Also explained in

Compare how 12 books explain OpenAPI specification →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.