AFAIK it's not documented, but schema_extra parameter of SQLModel's Field is for passing parameters that are not present in the Field, but supported by Pydantic's Field.

For example, there is no validation_alias parameter, but you can pass it the following way:

id_: in = Field(schema_extra={"validation_alias": "item_id"})
🌐
Pydantic
docs.pydantic.dev › 1.10 › usage › schema
Schema - Pydantic
For more fine-grained control, you can alternatively set schema_extra to a callable and post-process the generated schema. The callable can have one or two positional arguments. The first will be the schema dictionary. The second, if accepted, will be the model class. The callable is expected to mutate the schema dictionary in-place; the return value is not used. For example, the title key can be removed from the model's properties: ... from typing import Dict, Any, Type from pydantic import BaseModel class Person(BaseModel): name: str age: int class Config: @staticmethod def schema_extra(schema: Dict[str, Any], model: Type['Person']) -> None: for prop in schema.get('properties', {}).values(): prop.pop('title', None) print(Person.schema_json(indent=2))
🌐
Pydantic
docs.pydantic.dev › latest › concepts › json_schema
JSON Schema - Pydantic Validation
At both the field and model levels, you can use the json_schema_extra option to add extra information to the JSON schema. For custom types, Pydantic offers other tools for customizing JSON schema generation:
Discussions

python - example in schema extra is ignored by pydantic in fastapi - Stack Overflow
I have a deeply nested schema for a pydantic model .I wanted to include an example for fastapi user .When I am trying to do so pydantic is ignoring the example .Below is my model code : # generated... More on stackoverflow.com
🌐 stackoverflow.com
Advice for setting schema_extra on primitive types
Using a BaseModel with a __root__ ... with a schema_extra on that. This would be the ideal solution, but it promotes the type of items to object, rather than string (this causes issues with FastAPI either which is my target in this case). I could create a Pydantic model factory ... More on github.com
🌐 github.com
2
May 26, 2020
Pydantic v2: how to post-process the generated schema now?
On this documentation page we see the example of how we can alternatively set schema_extra to a callable and post-process the generated schema. How to do it now when class Config is deprecated? Beta Was this translation helpful? Give feedback. ... from pydantic import BaseModel, ConfigDict ... More on github.com
🌐 github.com
2
1
Defining additional properties with a given schema
Thanks 😊 So additional properties are allowed as long as they adhere to a given schema, thanks! Beta Was this translation helpful? Give feedback. ... from typing import Any from pydantic import BaseModel, model_validator class Model(BaseModel, extra="allow"): model_config = dict( ... More on github.com
🌐 github.com
1
3
🌐
FastAPI
fastapi.tiangolo.com › em › tutorial › schema-extra-example
Pydantic schema_extra
FastAPI framework, high performance, easy to learn, fast to code, ready for production
🌐
FastAPI
fastapi.tiangolo.com › tutorial › schema-extra-example
Declare Request Example Data - FastAPI
... Even after OpenAPI 3.1.0 was ... model, using schema_extra or Field(examples=["something"]) that example is added to the JSON Schema for that Pydantic model....
🌐
GitHub
github.com › samuelcolvin › pydantic › issues › 1564
Advice for setting schema_extra on primitive types · Issue #1564 · pydantic/pydantic
May 26, 2020 - Customising the schema by implementing a config on Samples with a schema_extra static function (as per the docs) which targets a specific case (schema["properties"]["samples"]["items"]["format"] = "my-format"), but this doesn't generalise for any T (T may be a nested array of strings which also require specifying format on their elements).
Published   May 26, 2020
Author   lewisbelcher
🌐
GitHub
github.com › pydantic › pydantic › discussions › 8068
Pydantic v2: how to post-process the generated schema now? · pydantic/pydantic · Discussion #8068
On this documentation page we see the example of how we can alternatively set schema_extra to a callable and post-process the generated schema. How to do it now when class Config is deprecated? Beta Was this translation helpful? Give feedback. ... from pydantic import BaseModel, ConfigDict def my_schema_extra(schema: dict[str, Any]) -> None: for prop in schema.get('properties', {}).values(): prop.pop('title', None) class Person(BaseModel): name: str age: int model_config = ConfigDict( json_schema_extra=my_schema_extra, )
Author   pydantic
Find elsewhere
🌐
Netlify
field-idempotency--pydantic-docs.netlify.app › usage › schema
Schema - pydantic
The schema is generated by default using aliases as keys, but it can be generated using model property names instead by calling MainModel.schema/schema_json(by_alias=False). Optionally, the Field function can be used to provide extra information about the field and validations.
🌐
GitHub
github.com › pydantic › pydantic › discussions › 5853
Defining additional properties with a given schema · pydantic/pydantic · Discussion #5853
from typing import Any from pydantic import BaseModel, model_validator class Model(BaseModel, extra="allow"): model_config = dict( json_schema_extra={ "additionalProperties": { "type": "object", "properties": {"data": {"type": "str"}}, } } ) age: float @model_validator(mode="before") @classmethod def validate_additional_properties(cls, v: Any) -> Any: if isinstance(v, dict): errors = {} for k, value in v.items(): if k != "age" and isinstance(value, str): errors[k] = value if errors: raise ValueError(errors) return v print(Model.model_json_schema()) """ { "type": "object", "properties": {"age":
Author   pydantic
🌐
Pydantic
docs.pydantic.dev › 1.10 › usage › model_config
Model Config - Pydantic
schema_extra · a dict used to extend/update the generated JSON Schema, or a callable to post-process it; see schema customization · json_loads · a custom function for decoding JSON; see custom JSON (de)serialisation · json_dumps · a custom function for encoding JSON; see custom JSON ...
🌐
GitHub
github.com › pydantic › pydantic › blob › main › docs › concepts › json_schema.md
pydantic/docs/concepts/json_schema.md at main · pydantic/pydantic
At both the field and model levels, you can use the json_schema_extra option to add extra information to the JSON schema. For custom types, Pydantic offers other tools for customizing JSON schema generation:
Author   pydantic
🌐
GitHub
github.com › samuelcolvin › pydantic › issues › 1122
Support passing model class to schema_extra? · Issue #1122 · pydantic/pydantic
December 22, 2019 - My use case is that I'm adding sub-class configuration in my own nested Meta classes, and I'd like to extract information from them in the base class's schema_extra · from typing import Any, Dict import pydantic class MyBase(pydantic.BaseModel): class Config: @staticmethod def schema_extra(schema: Dict[str, Any], model_class): # ...do something with model_class schema["something"] = model_class.MyMeta.foo class MySubclass(MyBase): class MyMeta: foo = "bar"
Author   therefromhere
🌐
DeepWiki
deepwiki.com › pydantic › pydantic › 5-schema-generation
Schema Generation | pydantic/pydantic | DeepWiki
February 1, 2026 - When extra='allow', generates schema for __pydantic_extra__ dict
🌐
Instructor
python.useinstructor.com › examples › examples
Few-Shot Learning with Examples - Pydantic Models - Instructor
import instructor from typing import Iterable from pydantic import BaseModel, ConfigDict client = instructor.from_provider("openai/gpt-5-nano") class SyntheticQA(BaseModel): question: str answer: str model_config = ConfigDict( json_schema_extra={ "examples": [ {"question": "What is the capital of France?", "answer": "Paris"}, { "question": "What is the largest planet in our solar system?", "answer": "Jupiter", }, { "question": "Who wrote 'To Kill a Mockingbird'?", "answer": "Harper Lee", }, { "question": "What element does 'O' represent on the periodic table?", "answer": "Oxygen", }, ] } ) def get_synthetic_data() -> Iterable[SyntheticQA]: return client.create( model="gpt-4o-mini", messages=[ {"role": "system", "content": "Generate synthetic examples"}, { "role": "user", "content": "Generate the exact examples you see in the examples of this prompt.
🌐
Medium
medium.com › @kishanbabariya101 › episode-8-json-schema-generation-in-pydantic-9a4c4fee02c8
Episode 8: JSON Schema Generation in Pydantic | by Kishan Babariya | Medium
December 17, 2024 - Feature Description Automatic Schema Generation Generate JSON Schema for all Pydantic models using model_json_schema(). FastAPI Integration Leverage schema generation for interactive API docs and validation. Customization Use Field and json_schema_extra to add descriptions, examples, and override field definitions.
🌐
Pydantic
docs.pydantic.dev › latest › migration
Migration Guide - Pydantic Validation
Instead, any extra data you want to add to the JSON schema should be passed as a dictionary to the json_schema_extra keyword argument. In Pydantic V1, the alias property returns the field's name when no alias ...
🌐
Pydantic
docs.pydantic.dev › 2.4 › concepts › json_schema
JSON Schema - Pydantic
You can also use model config to customize JSON serialization and extra schema properties on a model. Specifically, the following config options are relevant: ... See ConfigDict for details on these options. If Pydantic finds constraints which are not being enforced, an error will be raised.