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

Some datatypes in a custom schema not being validated when making sample requests

Open accornition opened this issue 4 years ago • 2 comments

I read the docs regarding generating custom schemas. So when I tried using a parameter type with a custom datatype (openapi.FORMAT_UUID for uuid fields), the application is not able to make an example request using the Swagger docs.

With basic datatypes like string, this is not a problem. I am able to make a request using the "Try it out" button on the Swagger docs. Basically, the uuid field is not being validated when I put a sample value on the parameter box.

I am using a class based APIView style of code, at the request endpoint api/<uuid:uid>

class TemplateAPI(APIView):
    uuid_param = openapi.Parameter(
        name='uuid_param', in_=openapi.IN_QUERY,
        required=True,
        description="UUID", type=openapi.FORMAT_UUID,
    )

    @swagger_auto_schema(
        manual_parameters=[uuid_param,],
        responses={200: json.dumps(example_object)},
        tags=['Template Tag'],
    )
    def get(self, request, uid):
        pass

The fields are rendered correctly, but I'm not able to make a request for this particular API. If I change UUID to String, however, I'm able to successfully make a request and get the response!

Is this an issue with drf-yasg, or am I missing something from my side?

Thanks

accornition avatar Jul 11 '20 15:07 accornition

has the same issue

HuangLiPang avatar Mar 02 '22 15:03 HuangLiPang

same issue

amirhoseinbidar avatar Aug 02 '22 15:08 amirhoseinbidar