- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试验证一个对象,该对象可以具有任意键,其值是一个如下所示的对象:
{ "href": "some string" }
或包含与上述匹配的对象的数组。
这是我目前拥有但不起作用的内容:
{
"$schema": "http://json-schema.org/schema#",
"id": "https://turnstyle.io/schema/links.json",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "object",
"required": "href"
},
{
"type": "array",
"items": {
"type": "object",
"required": "href"
}
}
]
}
}
Passing example:
{
"customer": { "href": "/customer/1" },
"products": [
{ "href": "/product/1" },
{ "href": "/product/2" }
]
}
Failing example:
{
"customer": { "wrongKey": "/customer/1" },
"products": "aString"
}
oneOf|anyOf|allOf
中的传递模式的
additionalProperties
必须适用于属于
additionalProperties
的所有 key .
最佳答案
"required"应该是 v4 中强制的属性数组.
或“必需”:真(或假)作为 v3 中属性的一部分。
尝试这个:
{
"$schema": "http://json-schema.org/schema#",
"id": "https://turnstyle.io/schema/links.json",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "object",
"properties": {
"href": {"type": "string"}
},
"required": ["href"]
},
{
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {"type": "string"}
},
"required": ["href"]
}
}
]
}
}
关于JSON Schema : Using anyOf, oneOf, allOf 在 additionalProperties 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41107693/
我正在尝试验证我的 JSON 架构并使用 additionalProperties: false 来确认没有其他属性。我的 responseBody 看起来像这样: [ { "id": 1
所以我有一个 JSON 架构,其中 additionalProperties 规则设置为 false 之类的。 { "type": "object", "properties": {
所以我有一个 JSON 架构,其中 additionalProperties 规则设置为 false 之类的。 { "type": "object", "properties": {
假设我们有模式跟随模式(来自教程 here): { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {
本文整理了Java中com.linecorp.centraldogma.server.ZooKeeperReplicationConfig.additionalProperties()方法的一些代码示
考虑这个例子: "allOf": [ {"$ref": "test-address-prefix-types-base.json#"}, { "properties":
我在通过 Velero CLI 将 Valero 安装到 AWS Kubernetes 集群时遇到以下问题。 velero install \ --provider aws \ -
在JSON Schema ,additionalProperties 和 additionalItems 之间有什么区别,正如我所见,两者的示例都用于指定包含未在模式中定义的元素的文档是否应被视为有效
我正在尝试验证一个对象,该对象可以具有任意键,其值是一个如下所示的对象: { "href": "some string" } 或包含与上述匹配的对象的数组。 这是我目前拥有但不起作用的内容: {
规范链接:http://json-schema.org/latest/json-schema-validation.html#anchor64 第 5.4.4.2 节规定: Successful va
我正在使用 JSON.NET JSchema 生成器创建基于用数据注释属性修饰的类的模式。我正在使用这样的生成器: var generator = new JSchemaGenerator(); ge
虽然我看过OpenAPI spec中的例子: type: object additionalProperties: $ref: '#/definitions/ComplexModel' 对我来说,
我是一名优秀的程序员,十分优秀!