如何将我的自定义json转换为swagger 2.0 json

时间:2016-09-06 09:35:52

标签: swagger swagger-2.0

我很擅长招摇文件。我们有一个用于RESTFul Web服务的进展语言开发的现有项目。基于资源的不同URL以application / json格式消耗和生成。我们的资源网址之一的输入和输出json格式如下:

请求:

{
    "request": {
      "companyNumber": 5000,
      "operatorInit": "sys",
      "operatorPassword": "",
      "customerNumber": 101,
      "shipTo": "",
      "warehouse": "01",
      "productCode": "2-001",
      "crossReferenceFlag": false,
      "retrieveFlag": false,
      "tInbinlocation": {
        "t-inbinlocation": [
          {
            "binloc": "",
            "icswbinloc1fl": false,
            "icswbinloc2fl": false,
            "addrecordfl": false,
            "deleterecordfl": false,
            "charuser": "",
            "user1": "",
            "user2": "",
            "user3": "",
            "user4": "",
            "user5": "",
            "user6": 0,
            "user7": 0,
            "user8": null,
            "user9": null
          }
        ]
      },
      "tInfieldvalue": {
        "t-infieldvalue": [
          {
            "level": "",
            "lineno": 0,
            "seqno": 0,
            "fieldname": "",
            "fieldvalue": ""
          }
        ]
      }
    }
}

响应:

{
  "response": {
    "cErrorMessage": "",
    "crossReferenceProduct": "2-001",
    "crossReferenceType": "",
    "tOutbinlocation": {
      "t-outbinlocation": []
    },
    "tOutfieldvalue": {
      "t-outfieldvalue": []
    }
  }
}

如何将上述请求和响应json格式转换为swagger 2.0 json格式?

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试使用api-spec-converter
此工具支持在流行格式之间转换API描述。

  Supported formats:
    * swagger_1
    * swagger_2
    * api_blueprint
    * io_docs
    * google
    * raml
    * wadl