Skip to content

Commit

Permalink
wip: include default if not null
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Oct 14, 2024
1 parent 8b88dca commit 4d1a04c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/Allele.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"type": {
"const": "Allele",
"default": "Allele",
"description": "MUST be \"Allele\"",
"type": "string"
},
Expand Down
4 changes: 3 additions & 1 deletion examples/pydantic_to_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def traverse_and_modify(self, schema):
if len(schema["anyOf"]) == 1:
schema.update(schema.pop("anyOf")[0])

schema.pop("default", None)
default = schema.get("default")
if default is None:
schema.pop("default", None)

enum = schema.get("enum") or []
if len(enum) == 1:
Expand Down

0 comments on commit 4d1a04c

Please sign in to comment.