Use PrimaryKeyRelatedField pkfield in openapi by wnd-ft · Pull Request #8315 · encode/django-rest-framework (original) (raw)
Note: Before submitting this pull request, please review our contributing guidelines.
Description
As per the unit test, changed to use pk_field
argument when creating schema of PrimaryKeyRelatedField
.
This fix isn't the perfect solution, but I couldn't come up with another best idea.
I'm sorry that my English isn't very good.
Ex,
class SampleSerializer(Serializer):
user_id = serializers.PrimaryKeyRelatedField(queryset=User.objects.all())
user_id_with_pk_field = serializers.PrimaryKeyRelatedField(queryset=User.objects.all(), pk_field=serializers.UUIDField())
# in docs
Sample:
type: object
properties:
user_id:
type: integer (or string)
user_id_with_pk_field:
type: string
format: uuid