问题标签 [anyof]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
644 浏览

swagger - 如何将多个示例添加到 Swagger 模式?

我将 Swagger 与 OAS3 一起使用,因为我需要anyOf支持。我有一个 API 调用可以采用两种可能的模式之一,一个account或一个address. 该模式在 Swagger 中运行良好:它显示并验证。但该example值仅显示第一个模式。我根据文档创建了一个examples数组,但我不知道在哪里添加它:

我应该在哪里添加examples数组,还是有更好的方法向用户显示 UI 中的 2 个可能的模式?

0 投票
1 回答
31 浏览

json - OpenAPI 3.0 中属性的交叉依赖

我需要为搜索 API 定义 swagger/OpenAPI v 3.0 文件。我的请求可以指定地理空间坐标(经度和纬度)或(邮政编码和国家/地区代码)或(城市和州以及国家/地区代码)。除了这些,我还有一些更多的强制性属性,比如distancedistanceUnits

我知道如何在 JSON 模式中做到这一点

但我在大摇大摆地定义它时遇到了麻烦。OpenAPI 3.0 允许oneOfanyOf构造,但如果我试图在所需部分使用它,swagger 编辑器会给我一个错误。

任何帮助将不胜感激。

0 投票
0 回答
55 浏览

reactjs - Don't render select options on react-jsonschema-form oneOf, anyOf

are there any ways to hide the select dropdown and implicitly validate when using oneOf, anyOf? Here is my playground sample

My expectation is that it only display "text", "text1", "text2" field with the validate that requires "text" and at least one of "text1" and "text2" without the dropdown at the end.