Model Adapter¶
- class spectree.model_adapter.ModelAdapter[source]¶
The protocol of model adapter.
check the model type
validate the model
dump model instance to a JSON
generate the JSON schema
check the validation errors
- __init__(*args, **kwargs)¶
- class spectree.model_adapter.pydantic_adapter.BaseFile[source]¶
An uploaded file, will be assigned as the corresponding web framework’s file object.
- class spectree.model_adapter.pydantic_adapter.PydanticModelAdapter[source]¶
pydantic model adapter.
- class spectree.model_adapter.pydantic_adapter.ValidationErrorType[source]¶
Model of a validation error response.
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class spectree.model_adapter.msgspec_adapter.MsgspecModelAdapter[source]¶
msgspec model adapter.
- is_model_instance(value: Any, model) bool[source]¶
Check if the value is the instance of the model under this adapter.
If it’s already an instance, we could skip the validation.
- json_schema(model: type[Any], *, ref_template: str, mode: Literal['validation', 'serialization'] = 'validation') dict[str, Any][source]¶
mode is not supported by msgspec.
- make_root_model(root_type: type[Any], *, name: str = 'GeneratedRootModel', module: str | None = None) type[Struct][source]¶
All the types are treated the same in msgspec.
- validation_error¶
alias of
ValidationError