mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
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>
This commit is contained in:
committed by
Samuel Colvin
parent
e169bd60e4
commit
cd8b504568
@@ -1,5 +1,5 @@
|
||||
# output-json
|
||||
from typing import Dict, Any
|
||||
from typing import Dict, Any, Type
|
||||
from pydantic import BaseModel
|
||||
|
||||
class Person(BaseModel):
|
||||
@@ -8,7 +8,7 @@ class Person(BaseModel):
|
||||
|
||||
class Config:
|
||||
@staticmethod
|
||||
def schema_extra(schema: Dict[str, Any]) -> None:
|
||||
def schema_extra(schema: Dict[str, Any], model: Type['Person']) -> None:
|
||||
for prop in schema.get('properties', {}).values():
|
||||
prop.pop('title', None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user