Files
pydantic/docs/examples/schema_extra_callable.py
T
John Carter cd8b504568 Pass model_class to schema_extra staticmethod (#1125)
* 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>
2020-01-06 12:01:03 +00:00

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))