:py:mod:`openapi` ================= .. py:module:: openapi .. autoapi-nested-parse:: OpenAPI schema customization and code sample generation. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: openapi._build_query_params openapi._get_param_placeholder openapi.create_custom_openapi_schema openapi.generate_code_sample .. py:function:: _build_query_params(parameters) Build query string and dict from parameters. .. py:function:: _get_param_placeholder(param_type) Get placeholder value for parameter type. .. py:function:: create_custom_openapi_schema(app, logger) Create custom OpenAPI schema with code samples and customizations. This function is compatible with FastAPI 0.124+ which aggressively caches OpenAPI schemas. Instead of mutating a cached schema, we generate a fresh schema using get_openapi() and customize it before caching. :param app: FastAPI application instance :param logger: Logger instance for debugging :returns: Customized OpenAPI schema dictionary .. py:function:: generate_code_sample(language, method, path, parameters, base_url = '') Generate code sample for a given language, method, and path. Uses Jinja2 templates to generate code samples dynamically at runtime. The generated code includes a placeholder __API_SERVER_URL__ that will be replaced with the actual URL during documentation rendering. :param language: The programming language (shell, python, go, js) :param method: HTTP method (GET, POST, etc.) :param path: API endpoint path :param parameters: List of OpenAPI parameter definitions :param base_url: Base URL for the API (optional, defaults to empty string) :returns: Generated code sample as a string with __API_SERVER_URL__ placeholder