-
Notifications
You must be signed in to change notification settings - Fork 303
Open
Description
Describe the bug
I added a test for this bug to a fork. See jennydaman@c124c7a
To Reproduce
import uuid
from django.db import models
from rest_framework import serializers, viewsets
from tests import assert_schema, generate_schema
class Album(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
class Song(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
album = models.ForeignKey(Album, on_delete=models.CASCADE, null=True)
class SongSerializer(serializers.ModelSerializer):
album_id = serializers.ReadOnlyField(source='album.id')
class Meta:
fields = ['id', 'album_id']
model = Song
class SongModelViewset(viewsets.ModelViewSet):
serializer_class = SongSerializer
queryset = Song.objects.none()Expected behavior
The album_id field should be nullable:
components:
schemas:
Song:
type: object
properties:
album_id:
type: string
format: uuid
readOnly: true
nullable: true # <-- expected to be in schema, actually missingMetadata
Metadata
Assignees
Labels
No labels