Skip to content

OpenAPI

Generate an OpenAPI 3.0 schema for a Jetio application.

The generator inspects: - all registered Jetio models (from the ORM registry) to pre-register schemas - all routes and handler signatures to build the paths section

Path conversion

Jetio allows typed path params like /users/{id:int}. OpenAPI uses /users/{id}; Jetio types are removed for schema output.

Request bodies

If a handler parameter is annotated with a Pydantic model, it is treated as a JSON request body.

Responses

If the handler has a return annotation, Jetio attempts to generate a matching JSON schema for 200/201 responses.

Parameters:

Name Type Description Default
app Jetio

Jetio application instance.

required

Returns:

Name Type Description
dict

OpenAPI specification document.

Mount Swagger UI and OpenAPI schema routes.

Adds
  • GET /docs: Swagger UI HTML
  • GET /openapi.json: OpenAPI schema JSON
Notes

Supports sub-path deployments (reverse proxies) by reading ASGI root_path and setting: - Swagger UI's schema URL - servers field in the OpenAPI document