drf-yasg
drf-yasg copied to clipboard
Hashid field type incorrect (int instead of str) in the path parameters
This is related https://github.com/axnsan12/drf-yasg/issues/383
However this requires overriding the entire generator get_path_parameters
method in its entirety just to be able to do:
if isinstance(model_field, HashidFieldMixin):
attrs = {'type': openapi.TYPE_STRING}
else:
While I agree HashidField
implementation is somewhere incorrect, it would be great to have something like SWAGGER_BASIC_TYPE_INFO_OVERRIDES
so that get_basic_type_info
would first look there.
Then an easy solution would be:
SWAGGER_BASIC_TYPE_OVERRIDES=[
(HashidFieldMixin, (openapi.TYPE_STRING, None)),
]
Any other ideas how to fix this easier?
Alternatively, somewhere in your project?
from drf_yasg import openapi
from drf_yasg.inspectors.field import model_field_to_basic_type
from hashid_field.field import HashidFieldMixin
model_field_to_basic_type.insert(
0, (HashidFieldMixin, (openapi.TYPE_STRING, None)),
)