JsonSchema如何对数组使用只读

问题描述

我阅读了规范。但是,我没有找到有关如何使用Array的readOnly的任何信息。而且,单个readonly属性不足以涵盖不同的情况。

示例数组模式如下:

{
    "$schema": "http://json-schema.org/draft-07/schema#","$id": "http://example.com/product.schema.json","title": "Products","type": "array","items": {
        "type": "object","properties": {
            "productId": {
                "description": "The unique identifier for a product","type": "integer"
            },"productName": {
                "description": "Name of the product","type": "string"
            },"price": {
                "description": "The price of the product","type": "number"
            }
        }
    }
}

是否可以实现以下目标?

  1. 不允许数组添加/删除数组的任何项目。但是,允许更新数组的任何项目。
  2. 不允许数组更新数组的任何项目。但是,允许添加/删除数组的项目。将项目添加到数组后,我唯一可以执行的操作是“删除”。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)