Class OpenApiRoutesConfigurer<A extends ExchangeContext>

java.lang.Object
io.inverno.mod.web.server.OpenApiRoutesConfigurer<A>
Type Parameters:
A - the exchange context type
All Implemented Interfaces:
WebRoutesConfigurer<A>

public class OpenApiRoutesConfigurer<A extends ExchangeContext> extends Object implements WebRoutesConfigurer<A>

Web routes configurer used to configure routes exposing generated Open API specifications.

This configurer defines the following routes:

/open-api
Returns the JSON list the Open API specifications
If Swagger UI is enabled and request is made with accept: text/html header, a Swagger UI presenting all the specifications is returned
/open-api/{moduleName}
Returns the YAML Open API specification of the specified module
If Swagger UI is enabled and request is made with accept: text/html header, a Swagger UI presenting the module's specification is returned

Note that Swagger UI requires WebJars support and the swagger-ui WebJar.

Since:
1.3
Author:
Jeremy Kuhn
See Also:
  • Constructor Details

    • OpenApiRoutesConfigurer

      public OpenApiRoutesConfigurer(ResourceService resourceService)

      Creates an Open API web routes configurer with Swagger supprt and the specified resource service.

      Parameters:
      resourceService - the resource service
    • OpenApiRoutesConfigurer

      public OpenApiRoutesConfigurer(ResourceService resourceService, boolean enableSwagger)

      Creates an Open API web routes configurer with the specified resource service.

      Parameters:
      resourceService - the resource service
      enableSwagger - true to enable Swagger UI routes, false otherwise
  • Method Details

    • configure

      public void configure(WebRoutable<A,?> routes)
      Description copied from interface: WebRoutesConfigurer

      Configures routes.

      Specified by:
      configure in interface WebRoutesConfigurer<A extends ExchangeContext>
      Parameters:
      routes - the web routable to configure
    • listSpec

      public ByteBuf listSpec()

      Returns a JSON list including all available Open API specifications.

      Returns:
      a raw list of specifications
    • listSpecSwaggerUI

      public ByteBuf listSpecSwaggerUI()

      Returns the Swagger UI loading HTML for all available Open API specifications.

      Returns:
      a raw Swagger UI loader
    • getSpec

      public Resource getSpec(@PathParam String moduleName) throws NotFoundException

      Returns the Open API specification for the specified module usually in YAML format.

      Parameters:
      moduleName - the module name
      Returns:
      a raw Open API specification
      Throws:
      NotFoundException - if there's no specification for the specified module
    • getSpecSwaggerUI

      public ByteBuf getSpecSwaggerUI(@PathParam String moduleName) throws NotFoundException

      Returns the Swagger UI loading HTML for the Open API specification of the specified module

      Parameters:
      moduleName - the module name
      Returns:
      a raw Swagger UI loader
      Throws:
      NotFoundException - if there's no specification for the specified module