Search code examples
springopenapiresteasyquarkusapi-gateway

Quarkus application - add base path to OpenAPI definition


I'm currently working on a Quarkus based API that is due to be hosted on an API gateway that requires our application to be running with a base-path and I found out that by setting quarkus.resteasy.path in application.properties I can run the application with a base-path and it is being added to the specification automatically.

I am generating an OpenAPI 3 specification by using org.eclipse.microprofile.openapi.annotations. My problem is that in the specification this base-path is added to every single operation. I am instead trying to only apply the base-path within the servers declaration basically like the equivalent of what basePath used to be in OpenAPI 2.0.

Current outcome:

servers:
- url: https://dev.example.com
  description: Development
- url: https://example.com
  description: Production
security:
- jwt: []
paths:
  /api/capacity/availability:
    get:
      ...
  /api/capacity/consume:
    post:
      ...

Desired outcome:

servers:
- url: https://dev.example.com/api
  description: Development
- url: https://example.com/api
  description: Production
security:
- jwt: []
paths:
  /capacity/availability:
    get:
      ...
  /capacity/consume:
    post:
      ...

Any help would be appreciated.


Solution

  • You can also use config to set the servers: quarkus.smallrye-openapi.servers

    See https://quarkus.io/guides/openapi-swaggerui#quarkus-smallrye-openapi_quarkus.smallrye-openapi.servers