API Reference¶
- pydanticmodelgen.generate_basemodel(schema: Mapping[str, Any], validate_schema: bool = True, model_name: str | None = None, format_validation: Mapping[str, Callable[[Any], bool]] | None = None) type[BaseModel] ¶
Generates a Pydantic BaseModel from a JSON Schema.
- Parameters:
schema – The JSON Schema to convert to a Pydantic model.
validate_schema – Whether to validate the JSON Schema. Defaults to True.
model_name – The name of the model. If not provided, uses the title of the schema or “DynamicModel”.
format_validation – A mapping of custom format names to validation functions. The functions are assumed to take the value and return whether or not they are valid based on the format.
- Returns:
The generated Pydantic BaseModel.