Skip to content

Commit

Permalink
fix: ghandic#25 Enums always coerced to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
leobaldock committed May 24, 2022
1 parent d4e5951 commit 0345068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/jsf/schema_types/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ def model(self, context: Dict[str, Any]):
_type = Enum(value=self._get_unique_name(context), type=base, names={str(v): v for v in self.enum})
context["__internal__"][_type.__name__] = _type
return self.to_pydantic(context, _type)

class Config:
smart_union = True
10 changes: 8 additions & 2 deletions src/tests/data/enum.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"enum": ["red", "amber", "green"]
}
"enum": [
"red",
"amber",
"green",
null,
42
]
}

0 comments on commit 0345068

Please sign in to comment.