- Notifications
You must be signed in to change notification settings - Fork302
-
#967 fixes field names in schema based on the But there are still 'wrong' field names which causes in mismatching field references: Filter fields are still snake case:
Required post/patch data fields are still snake case:"post": {"operationId":"create/api/v1/registry/wms/",..."requestBody": {"content": {"application/vnd.api+json": {"schema": {"required": ["data" ],"properties": {"data": {..."attributes": {"type":"object","properties": {"getCapabilitiesUrl": {"type":"string","format":"uri","pattern":"^(?:[a-z0-9.+-]*)://(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?(?:(?:0|25[0-5]|2[0-4]\\d|1\\d?\\d?|[1-9]\\d?)(?:\\.(?:0|25[0-5]|2[0-4]\\d|1\\d?\\d?|[1-9]\\d?)){3}|\\[[0-9a-f:.]+\\]|([a-z\u00a1-\uffff0-9](?:[a-z\u00a1-\uffff0-9-]{0,61}[a-z\u00a1-\uffff0-9])?(?:\\.(?!-)[a-z\u00a1-\uffff0-9-]{1,63}(?<!-))*\\.(?!-)(?:[a-z\u00a1-\uffff-]{2,63}|xn--[a-z0-9]{1,59})(?<!-)\\.?|localhost))(?::\\d{2,5})?(?:[/?#][^\\s]*)?\\z" },..."required": ["get_capabilities_url" ] } } It's not really possible to match the required fields with the properties of the object... I think this should be fixed. |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 2 replies
-
Fix:classDjangoFilterBackend(DjangoFilterBackend):defget_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)forresinresult:if"name"inres:name=format_field_name(res["name"].replace("__","."))res["name"]="filter[{}]".format(name)returnresult classAutoSchema(drf_openapi.AutoSchema):""" Extend DRF's openapi.AutoSchema for JSON:API serialization. """ ...defmap_serializer(self,serializer): ...iffield.required:required.append(format_field_name(field.field_name)) would fix it. |
BetaWas this translation helpful?Give feedback.
All reactions
2 replies
-
Thanks for reporting. Those two spots were missed indeed in the fix of#967. A PR is very welcome. |
BetaWas this translation helpful?Give feedback.
All reactions
-
done#1048 |
BetaWas this translation helpful?Give feedback.
All reactions
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment