如何在JSON模式中引用其他属性值? [英] How do you reference other property values in JSON schema?

查看:252
本文介绍了如何在JSON模式中引用其他属性值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有2个属性(minimumTolerance和maximumTolerance)的JSON模式.我需要确保maximumTolerance的值不小于minimumTolerance&反之亦然.在JSON模式中有可能吗?

I have a JSON schema with 2 properties, minimumTolerance and maximumTolerance. I need to make sure that the value of maximumTolerance is not smaller than minimumTolerance & vice versa. Is this possible in JSON schema?

以下是我想做的一个例子:

Here is an example of what I'd like to be able to do:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "title": "MinMax",
  "description": "Minum & Maximum",
  "type": "object",
  "properties": {
    "minimumTolerance":{
      "type": "number"
      "maximum":{
        "$ref":"maximumTolerance"
      }
    }
    "maximumTolerance":{
      "type": "number"
      "minumum": {
        "$ref":"minimumTolerance"
      }
    }
}

推荐答案

从规范草案7开始,无法使用JSON模式进行此操作.

As of Draft-7 of the specification there is no way to do this with JSON Schema.

这篇关于如何在JSON模式中引用其他属性值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆