微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

坚持为REST API创建Swagger文档

如何解决坚持为REST API创建Swagger文档

我正在编写REST API的Swagger文档(方法调用后)。我无法弄清楚如何使用Swagger在结果中写入“ userNode”,“父母”,“祖父母”和“孩子”。

我的REST API响应如下所示:-

{
  "status" : "success","result" : {
    "userNode" : {
      "siblings" : [{
        "user" : {
        "userId" : "12345","name" : "S T Johnson","location" : "Koera",},"childCount" : 0
      }],"person" : {
        "user" : {
        "userId" : "7383","name" : "Samuel","location" : "north Koera","childCount" : 6
      }
    },"parent" : {
      "siblings" : [ {
        "user" : {
        "userId" : "6752","name" : "Abu Salem","location" : "Saint Jones","childCount" : 8
      }],"person" : {
        "user" : {
        "userId" : "1922","name" : "Peter","location" : "Carrebean","childCount" : 10
      }
    },"grandparent" : {
      "siblings" : [ ],"person" : {
        "user" : {
        "userId" : "9001","name" : "Mohan Kapoor","location" : "Kenya","childCount" : 2
      }
    },"children" : [ {
      "user" : {
        "userId" : "102","name" : "Abhraham","location" : "America","childCount" : 0
    },{
      "user" : {
        "userId" : "101","name" : "John","location" : "South Africa","childCount" : 0
    } ]
  },"responseTimeStamp" : "1602134518273","message" : ""
}

如果我扭曲响应对象,则如下所示。

enter image description here

我试图创建Swagger,但是一切都搞砸了:-

"my_response": {
  "type": "object","properties": {
    "status": {
      "type": "string"
    },"result": {
      "type": "object","properties": {
        "userNode": {
          "type": "object","properties" : {
            "siblings" : [
              {
                "user": {
                  "type": "object","properties": {
                    "userId" : {"type": "string"},"name": {"type": "string"},"location": {"type": "string"}
                   }

如果您能帮助我修复它,我将不胜感激。

欢呼

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。