swagger - 获取 "Cannot read property ' 参数为 null”的 swagger 规范

标签 swagger swagger-ui swagger-2.0 swagger-editor

我有以下我自己从代码生成的 JSON。我基本上是在编写代码来生成 UI 的 swagger 规范。我正在编写一个新的,因为我仍然使用 play 1.3 并且其 swagger 模块已经有一段时间没有更新了。但是,我从代码生成器中获取了此 JSON,但 UI 卡在“正在获取资源列表:http://localhost:9100/resources.json;请稍候”。 JavaScript 控制台显示错误“针对 swagger 规范获取“无法读取 null 的属性‘参数’”。我不知道该怎么做,任何帮助将不胜感激。

     {
  "swagger": "2.0",
  "info": null,
  "host": null,
  "basePath": null,
  "tags": [
    {
      "name": "payments",
      "description": null,
      "externalDocs": null
    }
  ],
  "schemes": null,
  "consumes": null,
  "produces": null,
  "paths": {
    "/": {
      "get": {
        "tags": [
          "payments"
        ],
        "summary": "/payment_methods",
        "description": "",
        "operationId": "paymentMethods",
        "schemes": null,
        "consumes": null,
        "produces": [
          "application/json"
        ],
        "parameters": [],
        "responses": {
          "default": {
            "description": "successful operation",
            "schema": null,
            "examples": null,
            "headers": null
          }
        },
        "security": null,
        "externalDocs": null,
        "deprecated": null
      },
      "head": null,
      "post": {
        "tags": [
          "payments"
        ],
        "summary": null,
        "description": null,
        "operationId": "addPaypalAccount",
        "schemes": null,
        "consumes": null,
        "produces": null,
        "parameters": [],
        "responses": {
          "default": {
            "description": "successful operation",
            "schema": null,
            "examples": null,
            "headers": null
          }
        },
        "security": null,
        "externalDocs": null,
        "deprecated": null
      },
      "put": null,
      "delete": {
        "tags": [
          "payments"
        ],
        "summary": null,
        "description": null,
        "operationId": "deletePaypalAccount",
        "schemes": null,
        "consumes": null,
        "produces": null,
        "parameters": [],
        "responses": {
          "default": {
            "description": "successful operation",
            "schema": null,
            "examples": null,
            "headers": null
          }
        },
        "security": null,
        "externalDocs": null,
        "deprecated": null
      },
      "options": null,
      "patch": null,
      "parameters": null
    }
  },
  "securityDefinitions": null,
  "definitions": null,
  "parameters": null,
  "responses": null,
  "externalDocs": null,
  "securityRequirement": null
}

最佳答案

问题在于 null 值。它们需要被禁用——null 与“不存在”不同。也就是说,我相信您需要将映射器配置为不写入空值。

关于swagger - 获取 "Cannot read property ' 参数为 null”的 swagger 规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34403058/

相关文章:

spring - 带有 Java9 的 Swagger UI(spring boot 2.0)

Swagger:支持可选路由

scala - 如何在swagger中隐藏参数?

xml - 在 OpenAPI 中,如何定义具有属性和内容的 XML 元素?

swagger - 如何防止 Swagger-ui 中的 xml-wrapper 元素

java - swagger @ApiParam 忽略某些属性

django-rest-swagger 似乎对我不起作用。我无法让它记录除标题之外的任何内容

go - 如何在云函数中提供静态文件,如 swagger ui

php - SwaggerUI 传递参数

c# - 如何为类生成 JSON 示例值,就像 Swagger 所做的示例响应一样?