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:
John Carter
2020-01-07 01:01:03 +13:00
committed by Samuel Colvin
parent e169bd60e4
commit cd8b504568
4 changed files with 39 additions and 4 deletions
+2 -2
View File
@@ -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)