Skip to content

Commit 7547d88

Browse files
Fall back to the schema type if the format type is unrecognized. (#2066)
1 parent 2fbece2 commit 7547d88

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.generator/src/generator/formatter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def format_uuid(x):
302302
result = repr(UUID(x))
303303
return result
304304

305-
formatter = {
305+
formatters = {
306306
"double": lambda s: repr(float(s)),
307307
"int32": lambda s: repr(int(s)),
308308
"int64": lambda s: repr(int(s)),
@@ -312,7 +312,9 @@ def format_uuid(x):
312312
"email": repr,
313313
"uuid": format_uuid,
314314
None: repr,
315-
}[schema.get("format")]
315+
}
316+
schema_type = schema.get("type")
317+
formatter = formatters.get(schema.get("format", schema_type), formatters.get(schema_type)) or repr
316318

317319
# TODO format date and datetime
318320
parameters = formatter(data)

0 commit comments

Comments
 (0)