【问题标题】:How to convert my custom json to swagger 2.0 json如何将我的自定义 json 转换为 swagger 2.0 json
【发布时间】:2016-09-06 09:35:51
【问题描述】:

我是招摇文档的新手。我们有一个正在开发的 RESTFul Web 服务语言的现有项目。不同的基于资源的 url 以 application/json 格式消费和产生。我们的资源 URL 之一的输入和输出 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格式?

谢谢!

【问题讨论】:

    标签: swagger swagger-2.0


    【解决方案1】:

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

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

    【讨论】:

    • 我已经安装了 api-spec-converter。我正在尝试调用 api-spec-converter http://:/sxapi/rest/sxapirestservice/sxapiicbinlocationmnt --from=api_blueprint --to=swagger_2 swagger.json。但它给出了方法不支持的错误。我们仅支持 POST 请求。如何使用 api-spec-converter 做到这一点?
    • 它不会根据用户的请求将 JSON 转换为 Swagger。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 2020-04-19
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多