Replies: 1 comment 2 replies
-
Fix:class DjangoFilterBackend(DjangoFilterBackend):
def get_schema_operation_parameters(self, view):
"""
Convert backend filter `name` to JSON:API-style `filter[name]`.
For filters that are relationship paths, rewrite ORM-style `__` to our preferred `.`.
For example: `blog__name__contains` becomes `filter[blog.name.contains]`.
This is basically the reverse of `get_filterset_kwargs` above.
"""
result = super().get_schema_operation_parameters(view)
for res in result:
if "name" in res:
name = format_field_name(res["name"].replace("__", "."))
res["name"] = "filter[{}]".format(name)
return result class AutoSchema(drf_openapi.AutoSchema):
"""
Extend DRF's openapi.AutoSchema for JSON:API serialization.
"""
...
def map_serializer(self, serializer):
...
if field.required:
required.append(format_field_name(field.field_name))
would fix it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
#967 fixes field names in schema based on the
JSON_API_FORMAT_FIELD_NAMES
setting.But there are still 'wrong' field names which causes in mismatching field references:
Filter fields are still snake case:
filter[bbox_lat_lon.icontains]
Required post/patch data fields are still snake case:
It's not really possible to match the required fields with the properties of the object... I think this should be fixed.
Beta Was this translation helpful? Give feedback.
All reactions