如何限制在Jsonschema中应用补丁的操作?
当前,我们有一个JSonschema的补丁端点,现在我们要限制应用程序时可以执行的操作。
补丁端点看起来像这样:
def patch(self, name, version):
...
schema = Schema.get(name, version)
serialized_schema = schema.patch_serialize()
...
data = request.get_json()
patched_schema = apply_patch(serialized_schema, data)
serialized_data, errors = update_schema_serializer.load(
patched_schema, partial=True)
...
数据示例:
[
{ "op": "replace", "path": "/config/notifications/", "value": "foo" },
{ "op": "add", "path": "/config/", "value": {} },
{ "op": "remove", "path": "/config/notifications/"}
]
在这里,我们只需要add
,remove
和替换
操作。有什么方法可以仅适用这些操作,而不是复制
,移动和test
?
Currently, we have have a patch endpoint for jsonschema and now we want to limit the operation that we can do while applying the patch.
The patch endpoint looks like this:
def patch(self, name, version):
...
schema = Schema.get(name, version)
serialized_schema = schema.patch_serialize()
...
data = request.get_json()
patched_schema = apply_patch(serialized_schema, data)
serialized_data, errors = update_schema_serializer.load(
patched_schema, partial=True)
...
data example:
[
{ "op": "replace", "path": "/config/notifications/", "value": "foo" },
{ "op": "add", "path": "/config/", "value": {} },
{ "op": "remove", "path": "/config/notifications/"}
]
Here we want to only have add
, remove
and replace
operation. Is there any way to only apply patch for these operation and not for copy
, move
and test
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的模式定义中,将OP定义为仅具有您想要的选项的枚举
In your schema definition, define op as an enum with only the options that you want