CustomModelWrapper.model_json_schema#
- classmethod CustomModelWrapper.model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation', *, union_format='any_of')#
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. union_format: The format to use when combining schemas from unions together. Can be one of:
'any_of'
: Use the [anyOf
](https://json-schema.org/understanding-json-schema/reference/combining#anyOf)
keyword to combine schemas (the default). -
'primitive_type_array'
: Use the [type
](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (string
,boolean
,null
,integer
ornumber
) or contains constraints/metadata, falls back toany_of
.- schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema
with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.