Skip to content

Add Swagger UI for interactive API documentation#4211

Open
ajantha-bhat wants to merge 3 commits intomainfrom
feat/add-swagger-ui
Open

Add Swagger UI for interactive API documentation#4211
ajantha-bhat wants to merge 3 commits intomainfrom
feat/add-swagger-ui

Conversation

@ajantha-bhat
Copy link
Copy Markdown
Member

@ajantha-bhat ajantha-bhat commented Apr 15, 2026

Summary

  • Add quarkus-smallrye-openapi extension to expose the OpenAPI spec at /q/openapi and Swagger UI at /q/swagger-ui in dev mode
  • Polaris already uses Swagger annotations (swagger.jaxrs, swagger.annotations) throughout the codebase but does not serve API docs to developers

Motivation

Polaris currently requires developers to reference external OpenAPI spec files or read source code to understand the REST API surface. This change improves API discoverability for developers evaluating or integrating with Polaris.

Changes

  • runtime/service/build.gradle.kts — add quarkus-smallrye-openapi dependency
  • runtime/defaults/src/main/resources/application.properties — configure schema output directory
  • runtime/server/distribution/LICENSE — add license entries for transitive dependencies

Swagger UI is auto-enabled by Quarkus in dev mode only. With quarkus.management.enabled=true, both endpoints are served on the management port (8182):

  • http://localhost:8182/q/swagger-ui/
  • http://localhost:8182/q/openapi

Production builds do not include Swagger UI unless users explicitly opt in with quarkus.swagger-ui.always-include=true at build time.

Test plan

  • ./gradlew :polaris-runtime-service:compileJava :polaris-server:compileJava — builds successfully
  • ./gradlew :polaris-server:generateLicenseReport — license check passes
  • ./gradlew :polaris-runtime-service:spotlessCheck — formatting passes
  • ./gradlew quarkusDev → verified Swagger UI at http://localhost:8182/q/swagger-ui/
  • Verified /q/openapi returns the OpenAPI spec in YAML format on port 8182
  • CI passes

Add the quarkus-smallrye-openapi extension to expose interactive Swagger UI
at /q/swagger-ui and the OpenAPI spec at /q/openapi. Polaris already uses
Swagger annotations throughout the codebase but does not serve API docs.

This improves API discoverability for developers evaluating or integrating
with Polaris.
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Apr 15, 2026
@ajantha-bhat ajantha-bhat changed the title feat(server): add Swagger UI for interactive API documentation Add Swagger UI for interactive API documentation Apr 15, 2026
@ajantha-bhat ajantha-bhat requested review from adutra, dimas-b and snazy and removed request for dimas-b April 15, 2026 14:36
@jbonofre jbonofre self-requested a review April 15, 2026 15:05
Copy link
Copy Markdown
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ajantha-bhat ! The idea look good to me, however, I wonder whether the Swagger UI should be exposed on the main (8181) port or perhaps on the management port (internal)... WDYT?

…endencies

Add missing Apache License mentions for the transitive dependencies
introduced by quarkus-smallrye-openapi: quarkus-swagger-ui, jandex,
smallrye-open-api-core, smallrye-open-api-model, and
microprofile-openapi-api.
Remove quarkus.swagger-ui.always-include=true since it is a build-time
property that would expose Swagger UI in all deployments. Quarkus
auto-enables Swagger UI in dev mode, so developers get it via
./gradlew quarkusDev without any config. Production builds remain
unaffected.
@ajantha-bhat
Copy link
Copy Markdown
Member Author

Thanks for the review!

I checked locally — with quarkus.management.enabled=true, Swagger UI lands on the management port (8182), not 8181. The "Try it out" feature won't work from there since APIs are on 8181 and there's no servers section in the generated spec.

quarkus.swagger-ui.always-include and quarkus.swagger-ui.enabled are both build-time properties — no runtime on/off toggle available in Quarkus.

I've removed always-include=true from the defaults so production builds are unaffected. Quarkus auto-enables Swagger UI in dev mode, so ./gradlew quarkusDev will have it on the main port (8181). Users who want it in production can opt in at build time.

The /q/openapi endpoint is available in all modes for tooling and code generation, which is arguably the more valuable part of this change.

@ajantha-bhat
Copy link
Copy Markdown
Member Author

Correction to my previous comment — I verified in dev mode (quarkusDev) and Swagger UI is still on the management port (8182), not 8181. With quarkus.management.enabled=true, all /q/* endpoints route to the management port regardless of mode.

So the behavior is:

  • Dev mode: Swagger UI at http://localhost:8182/q/swagger-ui/, OpenAPI spec at http://localhost:8182/q/openapi
  • Production: Not included unless quarkus.swagger-ui.always-include=true is set at build time

The "Try it out" feature won't work from 8182 since APIs are on 8181, but the spec and documentation are still useful for reference. If we want it fully interactive on the main port, we'd need to set quarkus.smallrye-openapi.management.enabled=false.

Copy link
Copy Markdown
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @ajantha-bhat .
Non-blocker: Should we add integration tests for the OpenAPI endpoint?

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Apr 15, 2026
@adutra
Copy link
Copy Markdown
Contributor

adutra commented Apr 16, 2026

all /q/* endpoints route to the management port regardless of mode.

Yes, I think this needs to be exposed on the management port.

@adutra
Copy link
Copy Markdown
Contributor

adutra commented Apr 16, 2026

./gradlew quarkusDev → verified Swagger UI at http://localhost:8182/q/swagger-ui/

How did you manage to make this work? Running quarkusDev on all modules usually results in errors. I tried instead: ./gradlew :polaris-server:quarkusDev but I couldn't see the Swagger UI 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants