Skip to main content

schema_json_of

Generate a JSON schema (as JSON) for the passed model or dynamically generated one.

def schema_json_of(
type_: Any,
title: NameFactory | None = None,
by_alias: bool = True,
ref_template: string = DEFAULT_REF_TEMPLATE,
schema_generator: type[GenerateJsonSchema] = GenerateJsonSchema,
**dumps_kwargs: Any
) - > string

Generate a JSON schema (as JSON) for the passed model or dynamically generated one.

Parameters

NameTypeDescription
type_AnyThe Python type or Pydantic model for which the JSON schema is generated.
title`NameFactoryNone` = None
by_aliasbool = TrueWhether to use the field's alias as the key in the JSON schema if one is defined.
ref_templatestring = DEFAULT_REF_TEMPLATEThe format string used for generating internal JSON schema references.
schema_generatortype[GenerateJsonSchema] = GenerateJsonSchemaThe class used to customize the logic for generating the JSON schema.
**dumps_kwargsAnyAdditional keyword arguments passed directly to the underlying json.dumps call.

Returns

TypeDescription
stringA JSON-formatted string representing the JSON schema of the provided type.