1
3
编辑-2:5月22日
我一直在进一步挖掘,结果发现问题是因为你的高层转换为
你不应该这么做,一切都会成功的
所以这似乎不是一个bug,只是一个错误的用法。如果你只是删除
编辑-1
要修复原始代码,需要更新
这肯定会处理您的用例,但如果您不喜欢更改依赖项中的代码,请使用我的原始答案 原始答案
该库有一个缺陷/限制
再运行一次,我得到了所需的异常
您要么需要修复
|
2
3
编辑: 这里重要的是,提供的模式文档是Swagger模式的实例,它采用 extended subset of JSON Schema 定义一些请求和响应案例。Swagger 2.0模式本身可以通过其 JSON Schema ,但它不能直接作为API响应结构的JSON模式。
如果实体模式与标准JSON模式兼容,您可以使用通用验证器执行验证,但您必须提供所有相关定义,当您有绝对引用时,这很容易,但对于以
这里的问题是,您试图使用从解析范围分离的模式引用。我添加了
下面的代码运行良好。
|
3
0
我不确定我是否完全理解您的代码,但我有一个基于一些假设的想法。
假设
这个
这意味着您只验证数组中的第一项。
https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.4.1 |
4
0
jsonValidator不喜欢对象和数组关联的混合, 您可以使用:
或
|
MyPan · 从json格式提取项目 2 年前 |
Ceilingfish · JSON问题。net anyOf架构验证 6 年前 |
spring · 在与羊驼的阵列中使用颜色选择器? 6 年前 |
orzel · JSON模式-具有相同数据类型的对象 6 年前 |
Freid001 · 根据一组灵活的规则验证JSON对象? 6 年前 |
mpen · 如何从AJV错误中获取“标题”? 6 年前 |