Skip to main content

Module docs

Module docs 

Source
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 interface
  • GET /redoc - ReDoc interface
  • GET /openapi.json - OpenAPI 3.1 specification
  • GET /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§

DocsConfig
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.