Skip to content

Commit

Permalink
feat: add 'format' in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
PrettyWood committed Jul 28, 2020
1 parent 1a688d6 commit 8719225
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pydantic/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def field_singleton_sub_fields_schema(
(IPv6Address, {'type': 'string', 'format': 'ipv6'}),
# Note: We should probably add `pattern: <the regex>` in the schema
# but it would require `.schema()` to be an instance method instead of a class one.
(Pattern, {'type': 'string'}),
(Pattern, {'type': 'string', 'format': 'regex'}),
(str, {'type': 'string'}),
(bytes, {'type': 'string', 'format': 'binary'}),
(bool, {'type': 'boolean'}),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@ class Foobar(BaseModel):
assert Foobar.schema() == {
'type': 'object',
'title': 'Foobar',
'properties': {'pattern': {'type': 'string', 'title': 'Pattern'}},
'properties': {'pattern': {'type': 'string', 'format': 'regex', 'title': 'Pattern'}},
'required': ['pattern'],
}

Expand Down

0 comments on commit 8719225

Please sign in to comment.