openapi¶
- class litestar.openapi.OpenAPIConfig[source]¶
Bases:
objectConfiguration for OpenAPI.
To enable OpenAPI schema generation and serving, pass an instance of this class to the
Litestarconstructor using theopenapi_configkwargs.- random_seed: int = 10¶
The random seed used when creating the examples to ensure deterministic generation of examples.
- external_docs: ExternalDocumentation | None = None¶
Links to external documentation.
Should be an instance of
ExternalDocumentation.
- security: list[SecurityRequirement] | None = None¶
API Security requirements information.
- Should be an instance of
- components: Components | list[Components]¶
API Components information.
Should be an instance of
Componentsor a list thereof.
- __init__(title: str, version: str, create_examples: bool = False, random_seed: int = 10, contact: Contact | None = None, description: str | None = None, external_docs: ExternalDocumentation | None = None, license: License | None = None, security: list[SecurityRequirement] | None = None, components: Components | list[Components] = <factory>, servers: list[Server] = <factory>, summary: str | None = None, tags: list[Tag] | None = None, terms_of_service: str | None = None, use_handler_docstrings: bool = False, webhooks: dict[str, PathItem | Reference] | None=None, operation_id_creator: OperationIDCreator = <function default_operation_id_creator>, path: str = '/schema', render_plugins: Sequence[OpenAPIRenderPlugin] = (<litestar.openapi.plugins.ScalarRenderPlugin object>, ), openapi_router: Router | None = None) None¶
- use_handler_docstrings: bool = False¶
Draw operation description from route handler docstring if not otherwise provided.
- webhooks: dict[str, PathItem | Reference] | None = None¶
A mapping of key to either
PathItemor.Referenceobjects.
- operation_id_creator(http_method: Method, path_components: list[str | PathParameterDefinition]) str¶
A callable that generates unique operation ids
- path: str = '/schema'¶
Base path for the OpenAPI documentation endpoints.
If no path is provided the default is
/schema.Ignored if
openapi_routeris provided.
- render_plugins: Sequence[OpenAPIRenderPlugin] = (<litestar.openapi.plugins.ScalarRenderPlugin object>,)¶
Plugins for rendering OpenAPI documentation UIs.
Changed in version 3.0.0: Default behavior changed to serve only
ScalarRenderPlugin.
- openapi_router: Router | None = None¶
An optional router for serving OpenAPI documentation and schema files.
If provided,
pathis ignored.openapi_routeris not required, but it can be passed to customize the configuration of the router used to serve the documentation endpoints. For example, you can add middleware or guards to the router.Handlers to serve the OpenAPI schema and documentation sites are added to this router according to
render_plugins, so routes shouldn’t be added that conflict with these.
- class litestar.openapi.ResponseSpec[source]¶
Bases:
objectContainer type of additional responses.