1
votes

I looked at django-rest-swagger project and I want to use it to document api for my project. But there is some questions on how to do it.

  1. How to use help_text attribute on model or serializer? In the documentation it said: "Field help_text property is used to create the description from the serializer or model.". But api documentation contains only field names and field types and there is no default values description (in this example for field colour) e.g.

    Response Class
    CigarSerializer {
      name (string),
      url (url, optional),
      colour (string),
      price (decimal),
      length (integer),
      gauge (integer),
      notes (string),
      id (integer, optional),
      manufacturer (field)
    }
    

    Can I include help_text attribute in api documentation?

  2. Can I include serializer doc string in api documentation?

1
Looking at source, I think that this is not possible - sinitsynsv

1 Answers

3
votes

Your Serializer definition above isn't correct. Here's how you should define your Serializer with help_text:

class CigarSerializer(serializers.ModelSerializer):
    url = fields.URLField(source='get_absolute_url', read_only=True, help_text="this is where you add help text")
    ...

    class Meta:
        model = models.Cigar