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

Question: How can I validate response serializer for OpenApiResponse example value? #1363

Open
MinYn opened this issue Jan 13, 2025 · 0 comments

Comments

@MinYn
Copy link

MinYn commented Jan 13, 2025

Describe the bug

Hi, I am using OpenApiResponse and have specified Response Serializer. However, when specifying a value to OpenApiResponse, I specify an example value in dict format and I don't know if the example value specified with Response Serializer is valid. How can I solve this?

To Reproduce

I applied it to the view as follows.

@extend_schema_view(
    perform=extend_schema(
        parameters=[ParamSerializer, ],
        responses={
            200: OpenApiResponse(
                response=ResponseSerializer,
                examples=[
                    OpenApiExample(
                        'example name',
                        response_only=True,
                        description="""- description""",
                        value={
                            "message": "success",
                            "detail": None,
                            "result": [{...}]
                        },
                    ),
                ],
            ),
        }
    )
)

Expected behavior

If a response serializer is specified, it would be nice if validation could be optionally set to True.

@MinYn MinYn changed the title Question: How can I validate response serializer for <code>OpenApiResponse</code> example value? Question: How can I validate response serializer for OpenApiResponse example value? Jan 13, 2025
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