Class RedocMixin

java.lang.Object
org.apache.juneau.rest.server.docs.RedocMixin

public class RedocMixin extends Object
Mixin that publishes the Redoc HTML view at /redoc for the OpenAPI 3.1 spec.

Sibling of SwaggerMixin (Swagger v2 spec at /api), SwaggerUiMixin (HTML-first mount at /swagger), and OpenApiMixin (OpenAPI 3.1 spec at /openapi*). All four classes live in the org.apache.juneau.rest.server.docs api-docs mixin pack.

Declares @Rest(mixins={OpenApiMixin.class}) so transitive resolution pulls in OpenApiMixin (and its /openapi* mounts) automatically when this mixin is composed into a host.

Configurable mount path:

The default mount /redoc/* can be overridden via the SVL variable ${juneau.redoc.path:redoc} — set via system property (-Djuneau.redoc.path=docs), environment variable (JUNEAU_REDOC_PATH=docs), or Config key (juneau.redoc.path = docs) to change the runtime mount without subclassing. Resolution happens once at RestContext construction time (SVL resolution in @RestOp(path)).

Override accepts bare token (redoc), leading slash (/redoc), trailing slash (redoc/), or wildcard suffix (/redoc/*) — all resolve to the same mount.

Mixin-only deployment:

This resource is designed for composition via @Rest(mixins=...). The mount path is pinned at the op level by @RestGet(path="/{juneau.redoc.path:redoc}/*") on getRedoc(org.apache.juneau.rest.server.RestRequest); a class-level @Rest(paths=...) declaration would be silently ignored under the mixin pattern (see @Rest(paths) Javadoc).

Composition example:

@Rest(path="/myresource", mixins=RedocMixin.class) public class MyResource extends RestServlet { // Serves /myresource/openapi, /openapi.json, /openapi.yaml (transitively) and /myresource/redoc (this mixin). }

Content negotiation:

@Rest(defaultAccept="text/html") causes bare browser requests (no Accept header) to render HTML via the RedocUI swap. Explicit accept headers (e.g. Accept: application/json) are honored normally.

See Also:
Since:
10.0.0
  • Constructor Details

  • Method Details

    • getRedoc

      [GET /redoc] — render the Redoc HTML view (or the spec, depending on Accept).
      Parameters:
      req - The current REST request.
      Returns:
      The OpenAPI document.
      Throws:
      NotFound - If no OpenAPI document is available for this resource.