向JSON模式招摇过市

向JSON模式招摇过市,json,swagger,jsonschema,Json,Swagger,Jsonschema,我正在寻找一种方法,将在swagger中定义的模式转换为JSON模式 例如,我大摇大摆地说: "definitions" : { "response" : { "properties" : { "responseContent" : { "$ref" : "#/definitions/objectResponse" } } }, "objectResponse

我正在寻找一种方法,将在swagger中定义的模式转换为JSON模式

例如,我大摇大摆地说:

"definitions" : {
    "response" : {
        "properties" : {
            "responseContent" : {
                "$ref" : "#/definitions/objectResponse"
            }
        }
    },

    "objectResponse" : {
        "description" : "response",
        "properties" : {
            "idResponse" : {
                "type"        : "string",
                "description" : "Response",
                "minLength"   : 0,
                "maxLength"   : 255
            }
        }
    }
}
我想:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {},
  "id": "http://example.com/example.json",
  "properties": {
    "responseContent": {
      "id": "/properties/responseContent",
      "properties": {
        "idResponse": {
          "id": "/properties/responseContent/properties/idResponse",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}
目前,我找到了一个解决方案:

  • 基于招摇过市(例如使用apimatic.io)生成响应
  • 使用jsonschema.net转换响应
但在这个过程中,我失去了限制,我依赖于外部工具

谢谢你的帮助

PS:我是API界的新手,请毫不犹豫地深入解释我很好奇

皮尔

在找类似的东西吗?(以前从未使用过,我只是在谷歌上搜索过。)“模式定义在一个招摇过市者里面”——为了澄清,招摇过市者遵循的是。您只需在两种JSON格式之间进行转换。相关: