Skip to content

Commit

Permalink
use enum __iter__ instead of relying on ModelField passed by pydantic f…
Browse files Browse the repository at this point in the history
…ixes #372
  • Loading branch information
aaraney authored and robertbartel committed Jul 10, 2023
1 parent 8957ca7 commit 80ef565
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/lib/core/dmod/core/enum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from enum import Enum
from pydantic.fields import ModelField
from pprint import pformat

from typing import Any, Dict, Union
Expand Down Expand Up @@ -34,11 +33,11 @@ class Appliance(pydantic.BaseModel):
"""

@classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any], field: ModelField) -> None:
def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
"""Method used by pydantic to populate json schema fields and their associated types."""
# display enum field names as field options
if "enum" in field_schema:
field_schema["enum"] = [f.name.upper() for f in field.type_]
field_schema["enum"] = [f.name.upper() for f in cls]
field_schema["type"] = "string"

@classmethod
Expand Down

0 comments on commit 80ef565

Please sign in to comment.