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

drf-spectacular not recognizing complex objects #1284

Open
peterkronenberg opened this issue Sep 4, 2024 · 0 comments
Open

drf-spectacular not recognizing complex objects #1284

peterkronenberg opened this issue Sep 4, 2024 · 0 comments

Comments

@peterkronenberg
Copy link

I'm running Django with drf_spectacular

I have a serializer that looks something like this (greatly simplified)

class MySerializer(serializers.Serializer):
     parameters = Parameters(many=True, default=[])



class Parameters(BaseSerializer):
    param_name = serializers.CharField(required=True, allow_blank=False)
    param_count = serializers.IntegerField(required=True)

The drf_spectacular annotations are

@extend_schema(
    request=None,
    responses={
        200: MySerializer,
        400: ErrorResponseSerializer,
        500: ErrorResponseSerializer
    },
    description="Load all data"
)

The swagger that is being generated for the parameters field is

  "parameters": [],

How can I get it to generate the contents of the list with a sample parameter object. Why isn't drf_spectacular picking it up from the serializers?

For example, I would expect something like this

   "parameters": [
       {
         "string",
         "int"
        }
    ]
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