Merge pull request #50 from fredsonnenwald/string_format
Fix Field deprecation warning resulting from building models with formatted strings
This commit was merged in pull request #50.
This commit is contained in:
@@ -19,7 +19,6 @@ class StringTypeParser(GenericTypeParser):
|
|||||||
"maxLength": "max_length",
|
"maxLength": "max_length",
|
||||||
"minLength": "min_length",
|
"minLength": "min_length",
|
||||||
"pattern": "pattern",
|
"pattern": "pattern",
|
||||||
"format": "format",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
format_type_mapping = {
|
format_type_mapping = {
|
||||||
@@ -63,4 +62,8 @@ class StringTypeParser(GenericTypeParser):
|
|||||||
if format_type in self.format_pattern_mapping:
|
if format_type in self.format_pattern_mapping:
|
||||||
mapped_properties["pattern"] = self.format_pattern_mapping[format_type]
|
mapped_properties["pattern"] = self.format_pattern_mapping[format_type]
|
||||||
|
|
||||||
|
if "json_schema_extra" not in mapped_properties:
|
||||||
|
mapped_properties["json_schema_extra"] = {}
|
||||||
|
mapped_properties["json_schema_extra"]["format"] = format_type
|
||||||
|
|
||||||
return mapped_type, mapped_properties
|
return mapped_type, mapped_properties
|
||||||
|
|||||||
Reference in New Issue
Block a user