Class OpenApiResource

java.lang.Object
io.goobi.viewer.api.rest.v1.OpenApiResource

@Path("/openapi.json") public class OpenApiResource extends Object
Author:
Florian Alpers
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyBearerSecurityScheme(io.swagger.v3.oas.models.OpenAPI openApi)
    Declares the bearer security scheme on the given spec.
    static void
    applyTokenSecurityScheme(io.swagger.v3.oas.models.OpenAPI openApi)
    Declares the token security scheme on the given spec.
    static io.swagger.v3.oas.models.security.SecurityScheme
    Returns the security scheme describing the user bearer token.
    static io.swagger.v3.oas.models.info.Info
    Made static so the build-time OpenAPI spec generator can reuse the exact same Info object as the runtime resource, instead of duplicating a slimmed-down copy that could drift out of sync (no instance state is used here).
    io.swagger.v3.oas.models.OpenAPI
     
    static List<io.swagger.v3.oas.models.tags.Tag>
    Returns the global tag list of the v1 API.
    static io.swagger.v3.oas.models.security.SecurityScheme
    Returns the security scheme describing the API token.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenApiResource

      public OpenApiResource()
  • Method Details

    • getOpenApi

      @GET @Produces("application/json") public io.swagger.v3.oas.models.OpenAPI getOpenApi()
    • getTokenSecurityScheme

      public static io.swagger.v3.oas.models.security.SecurityScheme getTokenSecurityScheme()
      Returns the security scheme describing the API token.

      The token is a static value the operator configures; it is sent in the request header named by AuthorizationFilter.TOKEN_HEADER. The deprecated query parameter fall-back is deliberately left undocumented: a machine readable spec is an invitation to use what it describes, and a token in the URL leaks into access logs, Referer headers and browser history.

      Returns:
      the api key security scheme for the token header
    • applyTokenSecurityScheme

      public static void applyTokenSecurityScheme(io.swagger.v3.oas.models.OpenAPI openApi)
      Declares the token security scheme on the given spec.

      Adds to the existing Components rather than replacing them: the reader has already filled in the model schemas at this point, and setComponents would drop them. Applied after read() for the same reason — the reader assigns the scheme map wholesale, so a pre-populated configuration could be overwritten.

      Static so the build-time spec generator applies the identical scheme, instead of a copy that could drift.

      Parameters:
      openApi - spec to declare the scheme on
    • getBearerSecurityScheme

      public static io.swagger.v3.oas.models.security.SecurityScheme getBearerSecurityScheme()
      Returns the security scheme describing the user bearer token.

      Issued by POST /auth/login, which returns the plaintext token in its response body. The endpoints requiring it also accept a logged-in browser session; that alternative is deliberately left undescribed, because a client cannot obtain a session through the API and no tooling can supply one.

      Returns:
      the http bearer security scheme
    • applyBearerSecurityScheme

      public static void applyBearerSecurityScheme(io.swagger.v3.oas.models.OpenAPI openApi)
      Declares the bearer security scheme on the given spec.

      Adds to the existing Components for the same reason as applyTokenSecurityScheme(OpenAPI).

      Parameters:
      openApi - spec to declare the scheme on
    • getInfo

      public static io.swagger.v3.oas.models.info.Info getInfo()
      Made static so the build-time OpenAPI spec generator can reuse the exact same Info object as the runtime resource, instead of duplicating a slimmed-down copy that could drift out of sync (no instance state is used here).
      Returns:
      Info
    • getTags

      public static List<io.swagger.v3.oas.models.tags.Tag> getTags()
      Returns the global tag list of the v1 API.

      Operations reference these tags by name only. Declaring them here is what gives each group in the API documentation a description, and this list's order is the order in which the groups are presented. A tag used by an operation but missing here still forms a group, just an undescribed one at the end.

      Static for the same reason as getInfo(): the build-time spec generator reuses it, so the validated spec stays identical to what this resource serves.

      Returns:
      tags of the v1 API, in presentation order