schema_of
Generate a JSON schema (as dict) for the passed model or dynamically generated one.
def schema_of(
type_: Any,
title: NameFactory | None = None,
by_alias: bool = True,
ref_template: str = DEFAULT_REF_TEMPLATE,
schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema
) - > dict[str, Any]
Generate a JSON schema (as dict) for the passed model or dynamically generated one.
Parameters
| Name | Type | Description |
|---|---|---|
| type_ | Any | The Pydantic model or Python type for which the JSON schema is generated. |
| title | `NameFactory | None` = None |
| by_alias | bool = True | Whether to use field aliases as keys in the generated JSON schema. |
| ref_template | str = DEFAULT_REF_TEMPLATE | The format string used for generating internal JSON schema references. |
| schema_generator | type[GenerateJsonSchema] = GenerateJsonSchema | The class used to customize the logic for generating the JSON schema. |
Returns
| Type | Description |
|---|---|
dict[str, Any] | A dictionary representing the JSON schema of the provided type. |