mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
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:
committed by
Samuel Colvin
parent
94fc64f5e1
commit
d3cec7be56
@@ -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)
|
||||
....................
|
||||
|
||||
@@ -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'}),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user