Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help_text on a SerializerMethodField not displayed if list type #838

Open
khameeteman opened this issue Feb 21, 2023 · 1 comment
Open

Comments

@khameeteman
Copy link

khameeteman commented Feb 21, 2023

Bug Report

Description

Help text is not displayed in the following case:

class Serializer(serializers.ModelSerializer):
    field = serializers.SerializerMethodField('_field', help_text="field info")

    def _field(self, obj) -> list[dict]:
        return []

generates openapi.yml:

field:
  description: field info
  type: array
  items:
    type: object

The description key is missing in the items dict.

Is this a regression?

Don't know

Minimal Reproduction


Stack trace / Error message


Your Environment


@khameeteman
Copy link
Author

khameeteman commented Feb 21, 2023

As a workaround, the following seems to work:

    @swagger_serializer_method(serializers.ListField(
        child=serializers.JSONField(help_text="field info"),  # or `help_text=field.help_text`
    ))
    def _field(self, obj) -> list[dict]:
        return []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant