the drf_yasg swagger generator doesnt take TYPE_ARRAY as a valid parameter type. the implementation is as follows
from drf_yasg import openapi
param1 = openapi.Parameter('param_name',
in_=openapi.IN_QUERY,
description='description of param',
type=openapi.TYPE_ARRAY,
required=True
)
whereas the documentation of drf_yasg suggests that it takes openapi.TYPE_ARRAY as valid type.
the error that the generators throws is
File "/usr/local/lib/python3.6/dist-packages/drf_yasg/codecs.py", line 73, in encode
raise SwaggerValidationError("spec validation failed", errors, spec, self)
drf_yasg.errors.SwaggerValidationError: spec validation failed
is there some configuration that i am missing or something because TYPE_STRING,TYPE_NUMBER works perfectly fine.
A Parameter of TYPE_ARRAY requires the items key:
param1 = openapi.Parameter('param_name',
in_=openapi.IN_QUERY,
description='description of param',
type=openapi.TYPE_ARRAY,
items=openapi.Items(type=openapi.TYPE_STRING) # <------
required=True
)
See the OpenAPI 2.0 specification for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With