PolymorphicSerializerExtension drops serializers without writable fields #1029
Labels
bug
Something isn't working
fix confirmation pending
issue has been fixed and confirmation from issue reporter is pending
Describe the bug
PolymorphicSerializerExtension does not recognize polymorphic child serializers without writable fields as valid serializers for write operations despite django-rest-polymorphic library adding one writable field called
resourcetype
.As far as I can understand, this bug occurs in this line because child serializer does not yet have
resourcetype
field and is treated as an empty schema and deleted.Library versions
Django==4.2.3
django-polymorphic==3.1.0
django-rest-polymorphic==0.1.10
djangorestframework==3.14.0
drf-spectacular==0.26.3
To Reproduce
I have an app that uses polymorphic models to create asynchonous tasks of different types. Some of those types of tasks require some input from the user to create, but some only require to provide the type of task. The latter causes the problem where drf-spectacular does not generate schema for POST request, despite it having one valid writable field (
resourcetype
).The following code snippets show example of this problem:
models.py
serializers.py
Generated schema (note that
PolymorphicTasksRequest
only has one choice, whilePolymorphicTasks
has two)Expected behavior
Serializer without writable fields is added to schema with a single field
resourcetype
.The text was updated successfully, but these errors were encountered: