Hi DRFers,
I have a model like this:
class Job(Model):
class JobState(IntEnum):
RECEIVED = 0
PROCESSING = 1
DONE = 2
FAILED = 3
@classmethod
def choices(cls: Any) -> List[Tuple[int, str]]:
return [(key.value, key.name) for key in cls]
state = IntegerField(
choices=JobState.choices(),
default=JobState.RECEIVED,
)
I have a ModelSerializer:
class JobSerializer(serializers.ModelSerializer):
class Meta:
model = Job
fields = [
"state",
]
How do I get the OpenAPI schema to show the _names_ of the fields, not the
enum values?
My schema generates to:
"state": {
"enum": [
0,
1,
2,
3
],
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
},
Any ideas on how to make the enum use the name, not the value?
Thanks!
-Adam
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-rest-framework/CAEP43uOWYYhQ8hH7xt0qqOk9E4D9rW0Z0OzDyYqKvnE0pg2jSQ%40mail.gmail.com.