Class SwaggerUi.Builder

java.lang.Object
com.jsgalactic.axiom.openapi.ui.SwaggerUi.Builder
Enclosing class:
SwaggerUi

public static final class SwaggerUi.Builder extends Object
Configures a SwaggerUi. Not thread-safe; build once at startup.
  • Method Details

    • path

      public SwaggerUi.Builder path(String path)
      Sets where the UI is served.
      Parameters:
      path - absolute path without a trailing slash and without parameters, default /docs
      Returns:
      this builder
    • title

      public SwaggerUi.Builder title(String title)
      Sets the page title.
      Parameters:
      title - text shown in the browser tab
      Returns:
      this builder
    • spec

      public SwaggerUi.Builder spec(String name, String url)
      Adds a document the UI can display. With several, the UI offers a selector and starts with the first.
      Parameters:
      name - label, for example OpenAPI 3.1
      url - same-origin path of the document, for example /openapi.json
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the URL is not a same-origin path (a scheme, host or // would be refused by the page's Content-Security-Policy)
    • build

      public SwaggerUi build()
      Builds the configuration.
      Returns:
      an immutable SwaggerUi
      Throws:
      IllegalStateException - if no spec was added