Getting "Cannot read property 'parameters' of null" for swagger spec

I have the following JSON that I have generated myself from code. I am basically writing code to generate swagger spec for the UI. I am writing a new one because I still use play 1.3 and the swagger module for that has not been updated in a while. However, I got this JSON from my code generator, but UI hangs at "fetching resource list: http://localhost:9100/resources.json; Please wait." The javascript console shows the error "Getting "Cannot read property 'parameters' of null" for swagger spec". I do not what to make of this and any help would be appreciated.

     {
  "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
}

Upvotes: 5

Views: 8511

Answers (2)

PutoTropical
PutoTropical

Reputation: 123

I was having this issue and it turned out to be related to the JSON formatter in my .NET web api app. I was able to get it resolved by adding this line to the BootStrap class Configure method.

config.Formatters.Clear();

Upvotes: 1

fehguy
fehguy

Reputation: 6824

The issue is the null values. They need to be disabled--null is different than "not present". That said, I believe you need to configure your mapper to not write nulls.

Upvotes: 3

Related Questions