plugins#
- class litestar.openapi.plugins.OpenAPIRenderPlugin#
Bases:
ABC
Base class for OpenAPI UI render plugins.
- __init__(*, path: str | Sequence[str], media_type: MediaType | OpenAPIMediaType = MediaType.HTML, favicon: str = "<link rel='icon' type='image/png' href='https://cdn.jsdelivr.net/gh/litestar-org/branding@main/assets/Branding%20-%20PNG%20-%20Transparent/Badge%20-%20Blue%20and%20Yellow.png'>", style: str = '<style>body { margin: 0; padding: 0 }</style>') None #
Initialize the OpenAPI UI render plugin.
- static render_json(request: Request, openapi_schema: dict[str, Any]) bytes #
Render the OpenAPI schema as JSON.
- static get_openapi_json_route(request: Request) str #
Get the route for the OpenAPI JSON schema.
- Returns:
The route for the OpenAPI JSON schema.
- class litestar.openapi.plugins.RapidocRenderPlugin#
Bases:
OpenAPIRenderPlugin
Render an OpenAPI schema using Rapidoc.
- __init__(*, version: str = '9.3.4', js_url: str | None = None, path: str | Sequence[str] = '/rapidoc', **kwargs: Any) None #
Initialize the OpenAPI UI render plugin.
- Parameters:
version¶ – Rapidoc version to download from the CDN. If js_url is provided, this is ignored.
js_url¶ – Download url for the RapiDoc JS bundle. If not provided, the version will be used to construct the url.
path¶ – Path to serve the OpenAPI UI at.
**kwargs¶ – Additional arguments to pass to the base class.
- class litestar.openapi.plugins.RedocRenderPlugin#
Bases:
OpenAPIRenderPlugin
Render an OpenAPI schema using Redoc.
- __init__(*, version: str = 'next', js_url: str | None = None, google_fonts: bool = True, path: str | Sequence[str] = '/redoc', **kwargs: Any) None #
Initialize the OpenAPI UI render plugin.
- Parameters:
version¶ – Redoc version to download from the CDN. If js_url is provided, this is ignored.
js_url¶ – Download url for the Redoc JS bundle. If not provided, the version will be used to construct the url.
google_fonts¶ – Download google fonts via CDN. Should be set to False when not using a CDN.
path¶ – Path to serve the OpenAPI UI at.
**kwargs¶ – Additional arguments to pass to the base class.
- class litestar.openapi.plugins.ScalarRenderPlugin#
Bases:
OpenAPIRenderPlugin
Plugin to render an OpenAPI schema using Scalar.
New in version 2.8.0.
- __init__(*, version: str = 'latest', js_url: str | None = None, css_url: str | None = None, path: str | Sequence[str] = '/scalar', **kwargs: Any) None #
Initialize the Scalar OpenAPI UI render plugin.
- Parameters:
version¶ – Scalar version to download from the CDN. If js_url is provided, this is ignored.
js_url¶ – Download url for the Scalar JS bundle. If not provided, the version will be used to construct the url.
css_url¶ – Download url for the Scalar CSS bundle. If not provided, the Litestar-provided CSS will be used.
path¶ – Path to serve the OpenAPI UI at.
**kwargs¶ – Additional arguments to pass to the base class.
- class litestar.openapi.plugins.StoplightRenderPlugin#
Bases:
OpenAPIRenderPlugin
Render an OpenAPI schema using StopLight Elements.
- __init__(*, version: str = '7.7.18', js_url: str | None = None, css_url: str | None = None, path: str | Sequence[str] = '/elements', **kwargs: Any) None #
Initialize the OpenAPI UI render plugin.
- Parameters:
version¶ – StopLight Elements version to download from the CDN. If js_url is provided, this is ignored.
js_url¶ – Download url for the StopLight Elements JS bundle. If not provided, the version will be used to construct the url.
css_url¶ – Download url for the StopLight Elements CSS bundle. If not provided, the version will be used to construct the url.
path¶ – Path to serve the OpenAPI UI at.
**kwargs¶ – Additional arguments to pass to the base class.
- class litestar.openapi.plugins.SwaggerRenderPlugin#
Bases:
OpenAPIRenderPlugin
Render an OpenAPI schema using Swagger-UI.
- __init__(version: str = '5.1.3', js_url: str | None = None, css_url: str | None = None, standalone_preset_js_url: str | None = None, init_oauth: dict[str, Any] | bytes | None = None, path: str | Sequence[str] = '/swagger', **kwargs: Any) None #
Initialize the OpenAPI UI render plugin.
- Parameters:
version¶ – SwaggerUI version to download from the CDN. If js_url is provided, this is ignored.
js_url¶ – Download url for the Swagger UI JS bundle. If not provided, the version will be used to construct the url.
css_url¶ – Download url for the Swagger UI CSS bundle. If not provided, the version will be used to construct the url.
standalone_preset_js_url¶ – Download url for the Swagger Standalone Preset JS bundle. If not provided, the version will be used to construct the url.
init_oauth¶ – JSON to initialize Swagger UI OAuth2 by calling the
initOAuth
method. Refer to the following URL for details: Swagger-UI.path¶ – Path to serve the OpenAPI UI at.
**kwargs¶ – Additional arguments to pass to the base class.
- render(request: Request, openapi_schema: dict[str, Any]) bytes #
Render an HTML page for Swagger-UI.
Notes
override this method to customize the template.
- class litestar.openapi.plugins.YamlRenderPlugin#
Bases:
OpenAPIRenderPlugin
Render an OpenAPI schema as YAML.