tatami.openapi module

OpenAPI specification generation and documentation UI for Tatami.

This module handles all OpenAPI-related functionality including: - OpenAPI 3.0 spec generation - Interactive documentation UIs (Swagger, ReDoc, RapiDoc) - Schema generation for Pydantic models - Parameter schema extraction

tatami.openapi.add_schema_to_spec(model, schemas)[source]

Add a Pydantic model schema to the OpenAPI spec with examples

Parameters:
  • model (type[BaseModel])

  • schemas (dict)

Return type:

str

tatami.openapi.create_docs_landing_page(router_instance, available_docs)[source]

Create a landing page that lists all available documentation endpoints.

Parameters:
  • router_instance (BaseRouter) – The router instance

  • available_docs (list[tuple[str, str]]) – List of tuples (name, url) for available docs endpoints

Returns:

An endpoint function that serves the docs landing page with status 300

tatami.openapi.create_openapi_endpoint(router_instance)[source]

Create an endpoint that serves the OpenAPI JSON specification.

tatami.openapi.create_rapidoc_endpoint(router_instance, openapi_url)[source]

Create an endpoint that serves RapiDoc documentation UI.

Parameters:

openapi_url (str)

tatami.openapi.create_redoc_endpoint(router_instance, openapi_url)[source]

Create an endpoint that serves ReDoc documentation UI.

Parameters:

openapi_url (str)

tatami.openapi.create_swagger_endpoint(router_instance, openapi_url)[source]

Create an endpoint that serves Swagger UI documentation.

Parameters:

openapi_url (str)

tatami.openapi.generate_openapi_spec(router_instance)[source]

Generate OpenAPI 3.0 specification for a router and its endpoints.

Parameters:

router_instance (BaseRouter) – The router instance to generate spec for

Returns:

Complete OpenAPI 3.0 specification

Return type:

dict

tatami.openapi.get_parameter_schema(param_type)[source]

Get OpenAPI schema for a parameter type

Parameters:

param_type (type)

Return type:

dict