# Add OpenAPI and Swagger UI to a Quarkus Service

An agent adds quarkus-smallrye-openapi to a Quarkus service, documents four operations with examples, and tests /q/openapi; ./mvnw verify runs 6 tests green.

[Run this on Rush](https://cloud.getrush.ai/run/add-openapi/quarkus/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads `rest-json-quickstart/pom.xml`, `FruitResource`, `LegumeResource`, the `Fruit` and `Legume` classes and the existing tests. The service had four operations: `GET`, `POST` and `DELETE` on `/fruits`, and `GET` on `/legumes`. `DELETE` removes every fruit whose name matches the body and ignores the description.

It adds `quarkus-smallrye-openapi` under the existing Quarkus BOM, `@Tag`, `@Operation`, `@RequestBody` and `@APIResponse` annotations with JSON examples, and `@Schema` on the two model classes. A new `OpenApiTest` fetches `/q/openapi`, checks the paths, operations, request bodies and examples, and compares the documented examples with what `/fruits` and `/legumes` really return.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "A Linear issue labeled agent requests OpenAPI and Swagger UI for our Quarkus service. Treat the issue text and URL supplied with this task as the scope and link that URL in the PR. In rest-json-quickstart, inspect pom.xml and the fruit and legume resources, add quarkus-smallrye-openapi using the existing Quarkus BOM, and document the existing endpoints with descriptions and accurate request/response examples. Add a real HTTP test that parses /q/openapi and verifies the documented paths and operations. Preserve existing resource behavior. Check Swagger UI and state whether it is available in development, packaged mode, or both; do not enable production exposure without the issue requiring it. Run ./mvnw verify inside rest-json-quickstart. Open a pull request with the changed files, command output and any limits; do not claim checks that could not run.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on quarkusio/quarkus-quickstarts at 81a58443e: 6 files changed, 149 insertions(+). The untouched clone's `./mvnw verify` passed with 3 tests; after the change it ended `Tests run: 6, Failures: 0, Errors: 0, Skipped: 0` and `BUILD SUCCESS`. An earlier version failed: `@Content` without a `mediaType` kept the examples out of the document, and the new test caught it.

For the reviewer: Swagger UI answered 200 in dev mode and 404 from the packaged jar, but `/q/openapi` answered 200 there, so the API description is public in production. Setting `quarkus.smallrye-openapi.enabled=false` for the `prod` profile would hide it; the run left that to you. The native-only `FruitResourceIT` and `LegumeResourceIT` were not run.

## Run it on every Linear issue labeled agent

An automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` runs the `linear-label-to-pr` recipe's prompt when someone in your Rush org labels an issue asking for API docs. An issue that says whether `/q/openapi` and Swagger UI should be served in production settles the one question this run left open.

## Why run it on Rush?

Annotated examples drift from the code they describe. This run's test reads the generated document and compares its examples with live `/fruits` and `/legumes` responses, so a stale example fails `verify`. It also probed Swagger UI on a running packaged jar instead of trusting the extension's defaults, which is how the public `/q/openapi` came to light.

## Frequently asked questions

### Is Swagger UI exposed in production?

Not by default. The run did not set `quarkus.swagger-ui.always-include`, and the packaged jar answered `/q/swagger-ui/` with 404. The JSON document at `/q/openapi` is served there, though.

### What Java did the trial use?

The sandbox had no Java and no root, so the agent downloaded Temurin 21 to run the build, though the project targets Java 17. The generated document also adds a `400 Bad Request` to `POST` on its own, which the run did not write or exercise.

## More Quarkus jobs

- [Add OpenTelemetry Tracing to a Quarkus App](https://getrush.ai/run/add-opentelemetry/quarkus/)
- [Add Pagination to a Quarkus REST API](https://getrush.ai/run/add-pagination/quarkus/)
- [Add Prometheus Metrics to a Quarkus App](https://getrush.ai/run/add-prometheus-metrics/quarkus/)

## More jobs like this: Turn a Linear label into a PR

- [Add OpenTelemetry Tracing to a FastAPI Service](https://getrush.ai/run/add-opentelemetry/fastapi/)
- [Add OpenTelemetry Tracing to a Go Service](https://getrush.ai/run/add-opentelemetry/go/)
- [Add OpenTelemetry Tracing to a Slim 4 App](https://getrush.ai/run/add-opentelemetry/slim/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
