openapi
fastmcp.utilities.openapi
Functions
parse_openapi_to_http_routes
Parses an OpenAPI schema dictionary into a list of HTTPRoute objects using the openapi-pydantic library.
Supports both OpenAPI 3.0.x and 3.1.x versions.
clean_schema_for_display
Clean up a schema dictionary for display by removing internal/complex fields.
generate_example_from_schema
Generate a simple example value from a JSON schema dictionary. Very basic implementation focusing on types.
format_json_for_description
Formats Python data as a JSON string block for markdown.
format_description_with_responses
Formats the base description string with response, parameter, and request body information.
Args:
base_description
: The initial description to be formatted.responses
: A dictionary of response information, keyed by status code.parameters
: A list of parameter information, including path and query parameters. Each parameter includes details such as name, location, whether it is required, and a description.request_body
: Information about the request body, including its description, whether it is required, and its content schema.
Returns:
- The formatted description string with additional details about responses, parameters,
- and the request body.
Classes
ParameterInfo
Represents a single parameter for an HTTP operation in our IR.
RequestBodyInfo
Represents the request body for an HTTP operation in our IR.
ResponseInfo
Represents response information in our IR.
HTTPRoute
Intermediate Representation for a single OpenAPI operation.
OpenAPIParser
Unified parser for OpenAPI schemas with generic type parameters to handle both 3.0 and 3.1.
Methods:
parse
Parse the OpenAPI schema into HTTP routes.