Add Swagger UI for interactive API documentation#4211
Add Swagger UI for interactive API documentation#4211ajantha-bhat wants to merge 3 commits intomainfrom
Conversation
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.
dimas-b
left a comment
There was a problem hiding this comment.
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.
|
Thanks for the review! I checked locally — with
I've removed The |
|
Correction to my previous comment — I verified in dev mode ( So the behavior is:
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 |
flyrain
left a comment
There was a problem hiding this comment.
Thanks for adding this @ajantha-bhat .
Non-blocker: Should we add integration tests for the OpenAPI endpoint?
Yes, I think this needs to be exposed on the management port. |
How did you manage to make this work? Running |
Summary
quarkus-smallrye-openapiextension to expose the OpenAPI spec at/q/openapiand Swagger UI at/q/swagger-uiin dev modeswagger.jaxrs,swagger.annotations) throughout the codebase but does not serve API docs to developersMotivation
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— addquarkus-smallrye-openapidependencyruntime/defaults/src/main/resources/application.properties— configure schema output directoryruntime/server/distribution/LICENSE— add license entries for transitive dependenciesSwagger 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/openapiProduction builds do not include Swagger UI unless users explicitly opt in with
quarkus.swagger-ui.always-include=trueat 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 athttp://localhost:8182/q/swagger-ui//q/openapireturns the OpenAPI spec in YAML format on port 8182