docs/python-sdk/fastmcp-utilities-openapi-formatters.mdx
fastmcp.utilities.openapi.formattersParameter formatting functions for OpenAPI operations.
format_array_parameter <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/openapi/formatters.py#L12" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>format_array_parameter(values: list, parameter_name: str, is_query_parameter: bool = False) -> str | list
Format an array parameter according to OpenAPI specifications.
Args:
values: List of values to formatparameter_name: Name of the parameter (for error messages)is_query_parameter: If True, can return list for explode=True behaviorReturns:
format_deep_object_parameter <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/openapi/formatters.py#L66" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>format_deep_object_parameter(param_value: dict, parameter_name: str) -> dict[str, str]
Format a dictionary parameter for deep-object style serialization.
According to OpenAPI 3.0 spec, deepObject style with explode=true serializes object properties as separate query parameters with bracket notation.
For example, {"id": "123", "type": "user"} becomes
param[id]=123¶m[type]=user.
Args:
param_value: Dictionary value to formatparameter_name: Name of the parameterReturns:
generate_example_from_schema <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/openapi/formatters.py#L100" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>generate_example_from_schema(schema: JsonSchema | None) -> Any
Generate a simple example value from a JSON schema dictionary. Very basic implementation focusing on types.
format_json_for_description <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/openapi/formatters.py#L183" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>format_json_for_description(data: Any, indent: int = 2) -> str
Formats Python data as a JSON string block for Markdown.
format_description_with_responses <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/utilities/openapi/formatters.py#L192" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>format_description_with_responses(base_description: str, responses: dict[str, Any], parameters: list[ParameterInfo] | None = None, request_body: RequestBodyInfo | None = None) -> str
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: