mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
cd8b504568
* Pass model_class to schema_extra staticmethod Resolves #1122 * Add changelog * Apply suggestions from code review Co-Authored-By: Samuel Colvin <samcolvin@gmail.com> * Fix import after rebase * Fix test bug * Use TypeError instead of assert as per review * Rename var so declaration fits one one line * tiny tweaks Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
16 lines
395 B
Python
16 lines
395 B
Python
# output-json
|
|
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))
|