You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, first of all, thank you for your work and effort. It’s an incredible library.
Describe the bug
I’m having two problems with filters:
When I define a filter as “integer,” I can’t get it to appear as an integer in the schema (it appears as "number"). Could you guide me on where I should indicate this, please? (type hinting, extend_schema_field...)
class PositiveIntegerFilter(filters.NumberFilter):
field_class = forms.IntegerField
I’ve tried in many places but haven’t been able to achieve it.
I should note that I am applying the filter in a custom way, meaning it doesn’t apply to a specific field of an object (it's a filter for a list that has nothing to do with objects). Maybe that’s why it can’t identify the integer type through model introspection (that’s my theory).
If I specify my filters adding extend_schema_field(OpenApiTypes.XXX), the help_text doesn’t transfer to the description (it gets lost in the schema).
Is this a bug? Any way to propagate the help_text to the description?
Both problems are related for me because I can’t specify the integer type with extend_schema_field since I lose the description 😆 .
Example:
asset_currency = extend_schema_field(OpenApiTypes.STR)(filters.ModelChoiceFilter(
help_text=_('Filter by the currency code of the asset')
))
So regarding point 2: This is by design as you take control of the field schema when using extend_schema_field. Mixing together the detection with the override just creates confusion. Also imagine the case where you try to remove the help_text, which would be very hard when mixing.
Regarding 1: We basically chose to route to ignore the field_class and use the estimated model field instead. If I remember correctly, we did that because the form field_class often did not provide enough information by itself and using both sources seemed quite awkward and opaque.
Could the reason for people bringing this up be that extend_schema_field's name is misleading? I personally would assume that something which "extends" something else adds to it rather than replace it.
Hello, first of all, thank you for your work and effort. It’s an incredible library.
Describe the bug
I’m having two problems with filters:
I’ve tried in many places but haven’t been able to achieve it.
I should note that I am applying the filter in a custom way, meaning it doesn’t apply to a specific field of an object (it's a filter for a list that has nothing to do with objects). Maybe that’s why it can’t identify the integer type through model introspection (that’s my theory).
Is this a bug? Any way to propagate the help_text to the description?
Both problems are related for me because I can’t specify the integer type with extend_schema_field since I lose the description 😆 .
Example:
Result (without description) :
To Reproduce
Define a filter with help_text like this
Expected behavior
expected result (with description=help_text):
Thanks in advance
The text was updated successfully, but these errors were encountered: