Expand description
Interactive API documentation endpoints.
This module provides handlers for serving Swagger UI and ReDoc documentation interfaces, as well as the OpenAPI JSON specification.
§Usage
ⓘ
use fastapi_core::{App, DocsConfig};
let app = App::builder()
.get("/items", list_items)
.post("/items", create_item)
.enable_docs(DocsConfig::default())
.build();This will add the following endpoints:
GET /docs- Swagger UI interfaceGET /redoc- ReDoc interfaceGET /openapi.json- OpenAPI 3.1 specificationGET /docs/oauth2-redirect- OAuth2 callback handler
§Configuration
ⓘ
let config = DocsConfig::new()
.docs_path("/api-docs") // Default: /docs
.redoc_path("/api-redoc") // Default: /redoc
.openapi_path("/api-spec.json") // Default: /openapi.json
.title("My API Documentation")
.swagger_ui_parameters(r#"{"docExpansion": "none"}"#);Structs§
- Docs
Config - Configuration for the API documentation endpoints.
Functions§
- oauth2_
redirect_ html - Generate the OAuth2 redirect HTML page.
- oauth2_
redirect_ response - Create a response with OAuth2 redirect HTML.
- redoc_
html - Generate the ReDoc HTML page.
- redoc_
response - Create a response with ReDoc HTML.
- swagger_
ui_ html - Generate the Swagger UI HTML page.
- swagger_
ui_ response - Create a response with Swagger UI HTML.