Custom param convert is very useful. Example it is possible to convert from string to date.
I tried to use decorator extend_schema_field. It is not working.
from drf_spectacular.utils import extend_schema_field
@extend_schema_field({'type': 'integer'})
class NegativeIntConverter:
regex = '-\d+'
def to_python(self, value) -> int:
return int(value)
def to_url(self, value):
return '%d' % value
from django.urls import path, include, register_converter
register_converter(NegativeIntConverter, 'negint')
urlpatterns = [
path('calc/<negint:value>', get_calc)
]
I received warning log:
could not derive type of path parameter "value" because because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:value>) or annotating the parameter type with @extend_schema. Defaulting to "string".
Custom param convert is very useful. Example it is possible to convert from string to date.
I tried to use decorator
extend_schema_field. It is not working.I received warning log:
could not derive type of path parameter "value" because because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:value>) or annotating the parameter type with @extend_schema. Defaulting to "string".