Fix schema generation for fields annotated as : dict (#331)

* #330 Fix schema generation for fields annotated as `: dict`

* #330 update history.rst

* #330 format on linter's advice
This commit is contained in:
Никита Конин
2018-12-27 12:48:11 +03:00
committed by Samuel Colvin
parent 94fc64f5e1
commit d3cec7be56
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -9,6 +9,7 @@ v0.17.0 (unreleased)
* prevent validators being called repeatedly after inheritance, #327 by @samuelcolvin
* prevent duplicate validator check in ipython, fix #312 by @samuelcolvin
* add "Using Pydantic" section to docs, #323 by @tiangolo & #326 by @samuelcolvin
* fix schema generation for fields annotated as ``: dict``, #330 by @nkonin
v0.16.1 (2018-12-10)
....................
+1
View File
@@ -558,6 +558,7 @@ field_class_to_schema_enum_enabled = (
(UUID5, {'type': 'string', 'format': 'uuid5'}),
(UUID, {'type': 'string', 'format': 'uuid'}),
(NameEmail, {'type': 'string', 'format': 'name-email'}),
(dict, {'type': 'object'}),
)
+12
View File
@@ -308,6 +308,18 @@ def test_bool():
}
def test_dict():
class Model(BaseModel):
a: dict
assert Model.schema() == {
'title': 'Model',
'type': 'object',
'properties': {'a': {'title': 'A', 'type': 'object'}},
'required': ['a'],
}
class Foo(BaseModel):
a: float