如何根据JSON模式中的多个条件来制定需要的字段?

发布于 2025-01-21 09:39:47 字数 561 浏览 1 评论 0原文

如何根据2(或更多)其他属性的价值制作所需的属性?

例如,

{
  "properties": {
    "property1": {
      "type": "string"
      },
    "property2": {
      "type": "string"
      }
    "property3":{
      "type": "string"
    }
  }
}

如何根据属性1和属性2的值制作属性3?

似乎就像我需要使用allof,但是

"allOf": [
    {
    "if": {
        ...
    },
    "then": {
        ...
    }},
    "if": {
        ...
    },
    "then": {
        ...
    }
]

当我真正需要的是一个的多个条件时,有多个然后块,然后块。

How can I make a property required based on the value of 2 (or more) other properties?

For instance,

{
  "properties": {
    "property1": {
      "type": "string"
      },
    "property2": {
      "type": "string"
      }
    "property3":{
      "type": "string"
    }
  }
}

How can I make property3 required based on the values of property1 and property2?

It seems like I need to use allOf, but

"allOf": [
    {
    "if": {
        ...
    },
    "then": {
        ...
    }},
    "if": {
        ...
    },
    "then": {
        ...
    }
]

has multiple then blocks when what I really need is multiple conditions for only one then block.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文