drf-spectacular request body schema field description
Asked Answered
T

1

6

I'm struggling to find a way to add a field description to my request body fields, they are picked up by the serializer definion just fine but I would like to add a description line to better explain what the field should be. I can easily do this for query parameters using parameters=[OpenApiParameter()] etc. but I'm not finding any solution to add it for a payload field.

I've tried adding examples, parameter definitions, overriding the serializer with an inline seralizer, adding a @extend_schema_field on the field in the seralizer but that doesn't take a description param, no place seems to allow a field description.

here is an image is showing what is currently loading. As you can see I have also added an example but that doesn't cover what I would like to do. Any help is appreciated

Thirlage answered 4/5, 2023 at 9:0 Comment(0)
M
0

If you put help_text on the fields it will go into the yml file as a description. I just needed to do this myself.

serializers.CharField(read_only=True, help_text='This text becomes the description.')
Moo answered 27/6 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.