fix: Don't change order of json schema object properties unless prop_order is passed, Closes #1180
This commit is contained in:
parent
5efc45bdfd
commit
d1822fed6b
1 changed files with 9 additions and 6 deletions
|
@ -1471,12 +1471,15 @@ class SchemaConverter:
|
||||||
|
|
||||||
if schema_type == "object" and "properties" in schema:
|
if schema_type == "object" and "properties" in schema:
|
||||||
# TODO: `required` keyword
|
# TODO: `required` keyword
|
||||||
|
if self._prop_order:
|
||||||
prop_order = self._prop_order
|
prop_order = self._prop_order
|
||||||
prop_pairs = sorted(
|
prop_pairs = sorted(
|
||||||
schema["properties"].items(),
|
schema["properties"].items(),
|
||||||
# sort by position in prop_order (if specified) then by key
|
# sort by position in prop_order (if specified) then by key
|
||||||
key=lambda kv: (prop_order.get(kv[0], len(prop_order)), kv[0]),
|
key=lambda kv: (prop_order.get(kv[0], len(prop_order)), kv[0]),
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
prop_pairs = schema["properties"].items()
|
||||||
|
|
||||||
rule = '"{" space'
|
rule = '"{" space'
|
||||||
for i, (prop_name, prop_schema) in enumerate(prop_pairs):
|
for i, (prop_name, prop_schema) in enumerate(prop_pairs):
|
||||||
|
|
Loading…
Reference in a new issue