axnsan12 / drf-yasg

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
https://drf-yasg.readthedocs.io/en/stable/
Other
3.42k stars 439 forks source link

Showing the read_only fields in the serializer in the post /swagger template in (ForignKeyFields) #877

Open SamiTalebian opened 11 months ago

SamiTalebian commented 11 months ago

class MatchSerializer(serializers.ModelSerializer): winner = AthleteWinnerSerializer(read_only=True) class Meta: model = Match fields = ['uid', 'round_one', 'round_two', 'round_three', 'winner']

In this example the winner is generated in the body of the post api like the example below :

{ "round_one": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "round_two": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "round_three": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "winner": { "username": "string" } }