Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Showing write_only field in GET method when it should show only POST method. #91

Description

@fernandolins
  • DRF OpenAPI version: 1.0.0
  • Python version: 3.6.3
  • Operating System: OS X

Description

I have a serializer which has a write_only field and it is appearing to GET method.

models.py

class Template(models.Model):
    name = models.CharField(
        verbose_name=_('Name'), max_length=200, blank=False, null=False, unique=True,
        help_text=_('A string describing the template name.'))
    user = models.ForeignKey(
        User, verbose_name=_('User'), blank=True,
        null=True, related_name='templates')

serializers.py

class TemplateSerializer(serializers.ModelSerializer):

    class Meta:
        model = Template
        extra_kwargs = {'user': {'write_only': True}}
        fields = '__all__'

Current behavior

GET /api/templates

{
  "count": 0,
  "next": "string",
  "previous": "string",
  "results": [
    {
      "id": 0,
      "name": "string",
      "user": "string"
    }
  ]
}

Expected behavior

GET /api/templates

{
  "count": 0,
  "next": "string",
  "previous": "string",
  "results": [
    {
      "id": 0,
      "name": "string",
    }
  ]
}

This expected behavior is the real behavior of DRF but the drf_openapi hasn't this behavior.

Is there a way to drf_openapi to have the same behavior as drf?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions