drf-yasg icon indicating copy to clipboard operation
drf-yasg copied to clipboard

[Custom schema generation] for request_body not working

Open BradPrit09 opened this issue 3 years ago • 0 comments

Hi, I was working with custom schema generation for request body. The request are going through. Screenshot from 2021-06-05 21-47-01

I have defined the email field as required but it's not working . The request are sill going through resulting in error. My aim is to through an error {This field is required} if the data is not provided.

    @swagger_auto_schema(
        method='post',
        request_body=openapi.Schema(
            type=openapi.TYPE_OBJECT,
            title="Request OTP",
            required=["email"],
            properties={
                "email": openapi.Schema(
                    title="Email",
                    type=openapi.TYPE_STRING,
                    format=openapi.FORMAT_EMAIL,
                ),
            },
        ),
        responses={
            200: "Success",
            400: "Invalid Request"
        })

Thanks for the help.

BradPrit09 avatar Jun 05 '21 16:06 BradPrit09