JSON 模式中的 JSON 模式类型?

问题描述 投票:0回答:1

我想要一个模式,它描述了一个值,它本身就是一个 JSON 模式,例如

{
  "title": "Schema modification event",
  "description": "Describes and event of modification of another (arbitrary) JSON schema",
  "type": "object",
  "properties": {
    "field_name": {
      "type": "string",
      "format": "json-pointer",
      "description": "Location where change occurred"
    },
    "field_schema": {
      "$ref": "https://json-schema.org/draft-07/schema",
      "description": "New schema of the location"
    }
  },
  "required": [
    "field_name",
    "field_schema"
  ]
}
json jsonschema json-schema-validator
1个回答
0
投票

模式没有类型,但是您对

field_schema
所做的工作应该可以确保
field_schema
是一个 JSON 模式。

您将无法在同一操作中处理

field_name
using
field_schema
中的架构。你必须分几个步骤来做:

  1. 验证有效载荷(上面的模式应该验证什么)
  2. field_name
    指向的任何地方和
    field_schema
    处的模式提取新数据。
  3. 使用
    field_schema
    模式验证新数据。
© www.soinside.com 2019 - 2024. All rights reserved.