首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有警告的Swagger文件

带有警告的Swagger文件
EN

Stack Overflow用户
提问于 2016-12-07 15:36:55
回答 1查看 260关注 0票数 0

Swagger文件正在与warnig一起正常工作。

代码语言:javascript
复制
{
  'swagger': "2.0",
  "info": {
    "version": "3.0",
    "title": "Sample Service",
  },
  "schemes": [ "http" ],
  "host": "sampleservice.azurewebsites.net",
  "paths": {
    "/": {
      "post": {
        "summary": "Sample service",
        "description": "sample service",
        "parameters": [
          {
            "name": "Input",
            "in": "body",
            "description": "valid input",

            "schema": {
              "type": "object",
              "properties": {
                "MainAttr-1": {
                  "required": [ "Attr-1" ],
                  "type": "object",
                  "properties": {
                    "Attr-1": {
                      "description": "Attr-1",
                      "required": true,
                      "type": "string"
                    },
                    "Attr-2": {
                      "description": "Attr-2",
                      "required": false,
                      "type": "string"
                    },
                    "Attr-3": {
                      "description": "Attr-3",
                      "required": false,
                      "type": "boolean"
                    },
                    "Attr-4": {
                      "description": "Attr-4",
                      "required": false,
                      "type": "boolean"
                    },
                    "Attr-5": {
                      "description": "Attr-5",
                      "required": false,
                      "type": "string"
                    }
                  }
                },
                "MainAttr-2": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [ "Attr-1", "Attr-3", "Attr-5", "Attr-8" ],
                    "properties": {
                      "Attr-1": {
                        "description": "Attr-1",
                        "required": true,
                        "type": "string"
                      },
                      "Attr-2": {
                        "description": "Attr-2",
                        "required": false,
                        "type": "string"
                      },
                      "Attr-3": {
                        "description": "Attr-3",
                        "required": true,
                        "type": "boolean"
                      },
                      "Attr-4": {
                        "description": "Attr-4",
                        "required": false,
                        "type": "boolean"
                      },
                      "Attr-5": {
                        "description": "Attr-5",
                        "required": true,
                        "type": "string"
                      },

                      "Attr-6": {
                        "description": "Attr-6",
                        "required": false,
                        "type": "string"
                      },
                      "Attr-7": {
                        "description": "Attr-7",
                        "required": false,
                        "type": "string"
                      },
                      "Attr-8": {
                        "description": "Attr-8",
                        "required": true,
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "success"
          }
        }
      }
    }
  }
}

问题-1)应删除警告。

问题-2) "MainAttr-2“中的Attr-3是布尔型属性,是必需的。但是当我从下拉列表中选择'false‘时,它被视为无效输入。它只将“true”视为有效输入。(所需的任何布尔属性都是这样的)

由于这个警告,我无法传递代码。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-07 16:08:04

  1. 在开始时,将'swagger'更改为"swagger"。JSON需要字符串周围的双引号。
  2. 删除以下结尾处的额外逗号: “标题”:“样本服务”,
  3. required属性从所有属性定义(Attr-1Attr-8)中删除,并在对象级别使用required列表(在MainAttr-1MainAttr-2下)。 "MainAttr-1":{“必需”:"Attr-1",<-列出此数组中所需的属性"type":"object"," properties ":{ "Attr-1":{ "description":"Attr-1“," required ":true,<--删除"type":"string“},

除此之外,你的规格没问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41021488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档