阿诺在 comments 中说,这里有两个独立的问题是正确的.
是否要验证您的规范是否为有效的OpenAPI(fka.Swagger)规范
You can
或者验证此规范的实现是否会生成JSON,这对于您的JSON模式是有效的?
换句话说,这里有一些来自请求或响应体的JSON,对吗?
Swagger relies on another standard called JSON Schema for its schema objects, which are what actually describes the JSON (rather than endpoints or metadata). Swagger uses a subset of JSON Schema (missing: oneOf
, patternProperties
, among others). To that end, you can use a JSON Schema validator. There are 37 listed here; I'll give a shoutout to this online validator that also supports YAML schemas.
但是,当我说Swagger依赖于JSON API的子集时,我撒谎了.在不属于JSON Schema的Swagger中,有几个固定字段具有特殊含义.其中一个是discriminator
,它用于多态性.I am not aware of a Swagger validator that can process 101.有fair number of tools代表大摇大摆,一些人声称要做验证,但许多都是遗弃的软件,意味着旧版本,功能不完整,与其他技术Bundle 在一起,等等.如果我缺少一个成熟且维护良好的图书馆,我很想知道.