Skip to content

Swagger java.lang.NullPointerException - java code gen - 2.1.2 #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sundriver opened this issue Jun 23, 2015 · 8 comments
Closed

Swagger java.lang.NullPointerException - java code gen - 2.1.2 #906

sundriver opened this issue Jun 23, 2015 · 8 comments
Milestone

Comments

@sundriver
Copy link

Hi Swagger-Codegen team,
I just updated my local copy to the latest version, 2.1.2 and I am receiving the following error:

....
writing file /Users/ali/IdeaProjects/sensorfront-java-client2/src/main/java/io/swagger/client/model/SensorCreateUpdateRequest.java
writing file /Users/ali/IdeaProjects/sensorfront-java-client2/src/main/java/io/swagger/client/model/SensorDataAggregation.java
writing file /Users/ali/IdeaProjects/sensorfront-java-client2/src/main/java/io/swagger/client/model/SensorSummary.java
java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
    at java.util.regex.Matcher.reset(Matcher.java:308)
    at java.util.regex.Matcher.<init>(Matcher.java:228)
    at java.util.regex.Pattern.matcher(Pattern.java:1088)
    at io.swagger.codegen.DefaultCodegen.camelize(DefaultCodegen.java:1237)
    at io.swagger.codegen.DefaultCodegen.camelize(DefaultCodegen.java:1212)
    at io.swagger.codegen.languages.JavaClientCodegen.toModelName(JavaClientCodegen.java:179)
    at io.swagger.codegen.languages.JavaClientCodegen.getSwaggerType(JavaClientCodegen.java:215)
    at io.swagger.codegen.DefaultCodegen.getTypeDeclaration(DefaultCodegen.java:490)
    at io.swagger.codegen.languages.JavaClientCodegen.getTypeDeclaration(JavaClientCodegen.java:200)
    at io.swagger.codegen.languages.JavaClientCodegen.getTypeDeclaration(JavaClientCodegen.java:193)
    at io.swagger.codegen.languages.JavaClientCodegen.getTypeDeclaration(JavaClientCodegen.java:193)
    at io.swagger.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:606)
    at io.swagger.codegen.DefaultCodegen.addVars(DefaultCodegen.java:1191)
    at io.swagger.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:540)
    at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.java:451)
    at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:125)
    at io.swagger.codegen.cmd.Generate.run(Generate.java:124)
    at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)

Here is the swagger json for SensorSummary

{ "apiVersion" : "1.0.0",
  "apis" : [ { "operations" : [ { "deprecated" : false,
              "method" : "POST",
              "nickname" : "DownloadAggregatedData",
              "notes" : "Maximum body size is 1MB (1024KB). Timestamp is in UTC format (number if milliseconds since epoch).",
              "parameters" : [ { "description" : "Download Request",
                    "name" : "body",
                    "paramType" : "body",
                    "required" : true,
                    "type" : "DownloadAggregatedDataRequest"
                  } ],
              "position" : 0,
              "responseMessages" : [ { "code" : 200,
                    "message" : "OK"
                  },
                  { "code" : 400,
                    "message" : "One or more security tokens are invalid (badly formatted or don't exist any more)"
                  }
                ],
              "summary" : "This API call is used for retrieving aggregated data of one or more sensors The request body must be in application/json format. ",
              "type" : "DownloadAggregatedDataResponse"
            } ],
        "path" : "/rest/data/download/aggregate"
      },
      { "operations" : [ { "deprecated" : false,
              "method" : "POST",
              "nickname" : "DownloadRawData",
              "notes" : "Maximum body size is 1MB (1024KB). Timestamp is in UTC format (number if milliseconds since epoch).",
              "parameters" : [ { "description" : "Download Request",
                    "name" : "body",
                    "paramType" : "body",
                    "required" : true,
                    "type" : "DownloadRawDataRequest"
                  } ],
              "position" : 0,
              "responseMessages" : [ { "code" : 200,
                    "message" : "OK"
                  },
                  { "code" : 400,
                    "message" : "One or more security tokens are invalid (badly formatted or don't exist any more)"
                  }
                ],
              "summary" : "This API call is used for retrieving raw data and tags from one or more sensors The request body must be in application/json format. ",
              "type" : "DownloadRawDataResponse"
            } ],
        "path" : "/rest/data/download/raw"
      },
      { "operations" : [ { "deprecated" : false,
              "method" : "POST",
              "nickname" : "DownloadSummarizedData",
              "notes" : "Maximum body size is 1MB (1024KB). Timestamp is in UTC format (number if milliseconds since epoch).",
              "parameters" : [ { "description" : "Download Request",
                    "name" : "body",
                    "paramType" : "body",
                    "required" : true,
                    "type" : "DownloadSummarizedDataRequest"
                  } ],
              "position" : 0,
              "responseMessages" : [ { "code" : 200,
                    "message" : "OK"
                  },
                  { "code" : 400,
                    "message" : "One or more security tokens are invalid (badly formatted or don't exist any more)"
                  }
                ],
              "summary" : "This API call is used for retrieving summarized aggregated data (merged aggregated data into one aggregation point)of one or more sensors The request body must be in application/json format. ",
              "type" : "DownloadSummarizedDataResponse"
            } ],
        "path" : "/rest/data/download/summary"
      },
      { "operations" : [ { "deprecated" : false,
              "method" : "POST",
              "nickname" : "UploadData",
              "notes" : "Maximum body size is 1MB (1024KB). Timestamp is in UTC format (number if milliseconds since epoch).",
              "parameters" : [ { "description" : "Upload Request",
                    "name" : "body",
                    "paramType" : "body",
                    "required" : true,
                    "type" : "UploadDataRequest"
                  } ],
              "position" : 0,
              "responseMessages" : [ { "code" : 200,
                    "message" : "OK"
                  },
                  { "code" : 400,
                    "message" : "Bad request sent to server."
                  }
                ],
              "summary" : "This API call is used for uploading data into SensorFront. Each request can be at most 1MB in size. Split larger requests into 1MB (or smaller) requests. You can use this API to upload data for multiple sensors at the same time. ",
              "type" : "void"
            } ],
        "path" : "/rest/data/upload"
      }
    ],
  "basePath" : "http://localhost:8080",
  "consumes" : [ "application/json" ],
  "models" : { "DataAggregation" : { "id" : "DataAggregation",
          "name" : "DataAggregation",
          "properties" : { "t" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "v" : { "items" : { "format" : "double",
                      "type" : "number"
                    },
                  "position" : 0,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DataAggregation",
          "required" : [ "t",
              "v"
            ]
        },
      "DataPoint" : { "id" : "DataPoint",
          "name" : "DataPoint",
          "properties" : { "t" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "v" : { "format" : "double",
                  "position" : 0,
                  "type" : "number"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DataPoint",
          "required" : [ "t" ]
        },
      "DataPointTag" : { "id" : "DataPointTag",
          "name" : "DataPointTag",
          "properties" : { "t" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "v" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array",
                  "uniqueItems" : true
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DataPointTag",
          "required" : [ "t",
              "v"
            ]
        },
      "DataPointTags" : { "id" : "DataPointTags",
          "name" : "DataPointTags",
          "properties" : { "id" : { "position" : 0,
                  "type" : "string"
                },
              "tags" : { "items" : { "$ref" : "DataPointTag" },
                  "position" : 0,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DataPointTags",
          "required" : [ "id",
              "tags"
            ]
        },
      "DownloadAggregatedDataRequest" : { "id" : "DownloadAggregatedDataRequest",
          "name" : "DownloadAggregatedDataRequest",
          "properties" : { "from" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "includeAverage" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeCount" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMaxTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMaximum" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMinTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMinimum" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeStandardDev" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeValueForMaxTsOfEachBucket" : { "description" : "Default is true.",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeValueForMinTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "level" : { "description" : "Set the aggregation level for downloading summarized data",
                  "enum" : [ "OneYear",
                      "OneMonth",
                      "OneDay",
                      "OneHour",
                      "FifteenMinutes",
                      "OneMinute"
                    ],
                  "position" : 0,
                  "type" : "string"
                },
              "sensors" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array",
                  "uniqueItems" : true
                },
              "to" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "user_read_token" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadAggregatedDataRequest",
          "required" : [ "level",
              "sensors",
              "includeMinimum",
              "includeMaximum",
              "includeAverage",
              "includeStandardDev",
              "includeCount",
              "includeMinTsOfEachBucket",
              "includeMaxTsOfEachBucket",
              "includeValueForMinTsOfEachBucket",
              "includeValueForMaxTsOfEachBucket"
            ]
        },
      "DownloadAggregatedDataResponse" : { "id" : "DownloadAggregatedDataResponse",
          "name" : "DownloadAggregatedDataResponse",
          "properties" : { "headers" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array"
                },
              "summary" : { "items" : { "$ref" : "SensorDataAggregation" },
                  "position" : 1,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadAggregatedDataResponse",
          "required" : [ "headers",
              "summary"
            ]
        },
      "DownloadRawDataRequest" : { "id" : "DownloadRawDataRequest",
          "name" : "DownloadRawDataRequest",
          "properties" : { "from" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "includeData" : { "description" : "Default is false",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeTags" : { "description" : "Default is false",
                  "position" : 0,
                  "type" : "boolean"
                },
              "sensors" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array",
                  "uniqueItems" : true
                },
              "to" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "user_read_token" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadRawDataRequest",
          "required" : [ "includeData",
              "includeTags",
              "sensors"
            ]
        },
      "DownloadRawDataResponse" : { "id" : "DownloadRawDataResponse",
          "name" : "DownloadRawDataResponse",
          "properties" : { "data" : { "items" : { "$ref" : "SensorData" },
                  "position" : 0,
                  "type" : "array"
                },
              "tags" : { "items" : { "$ref" : "DataPointTags" },
                  "position" : 0,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadRawDataResponse",
          "required" : [ "data" ]
        },
      "DownloadSummarizedDataRequest" : { "id" : "DownloadSummarizedDataRequest",
          "name" : "DownloadSummarizedDataRequest",
          "properties" : { "from" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "includeAverage" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeCount" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMaxTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMaximum" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMinTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeMinimum" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeStandardDev" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeValueForMaxTsOfEachBucket" : { "description" : "Default is true.",
                  "position" : 0,
                  "type" : "boolean"
                },
              "includeValueForMinTsOfEachBucket" : { "description" : "Default is true",
                  "position" : 0,
                  "type" : "boolean"
                },
              "level" : { "description" : "Set the aggregation level for downloading summarized data",
                  "enum" : [ "OneYear",
                      "OneMonth",
                      "OneDay",
                      "OneHour",
                      "FifteenMinutes",
                      "OneMinute"
                    ],
                  "position" : 0,
                  "type" : "string"
                },
              "sensors" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array",
                  "uniqueItems" : true
                },
              "to" : { "format" : "int32",
                  "position" : 0,
                  "type" : "integer"
                },
              "user_read_token" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadSummarizedDataRequest",
          "required" : [ "level",
              "sensors",
              "includeMinimum",
              "includeMaximum",
              "includeAverage",
              "includeStandardDev",
              "includeCount",
              "includeMinTsOfEachBucket",
              "includeMaxTsOfEachBucket",
              "includeValueForMinTsOfEachBucket",
              "includeValueForMaxTsOfEachBucket"
            ]
        },
      "DownloadSummarizedDataResponse" : { "id" : "DownloadSummarizedDataResponse",
          "name" : "DownloadSummarizedDataResponse",
          "properties" : { "headers" : { "items" : { "type" : "string" },
                  "position" : 0,
                  "type" : "array"
                },
              "summary" : { "items" : { "$ref" : "SensorSummary" },
                  "position" : 1,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.DownloadSummarizedDataResponse",
          "required" : [ "headers",
              "summary"
            ]
        },
      "SensorData" : { "id" : "SensorData",
          "name" : "SensorData",
          "properties" : { "data" : { "items" : { "$ref" : "DataPoint" },
                  "position" : 0,
                  "type" : "array"
                },
              "id" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.SensorData",
          "required" : [ "id",
              "data"
            ]
        },
      "SensorDataAggregation" : { "id" : "SensorDataAggregation",
          "name" : "SensorDataAggregation",
          "properties" : { "data" : { "items" : { "$ref" : "DataAggregation" },
                  "position" : 1,
                  "type" : "array"
                },
              "id" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.SensorDataAggregation",
          "required" : [ "id",
              "data"
            ]
        },
      "SensorSummary" : { "id" : "SensorSummary",
          "name" : "SensorSummary",
          "properties" : { "id" : { "position" : 0,
                  "type" : "string"
                },
              "v" : { "items" : { "format" : "double",
                      "type" : "number"
                    },
                  "position" : 0,
                  "type" : "array"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.SensorSummary",
          "required" : [ "id",
              "v"
            ]
        },
      "UploadDataRequest" : { "id" : "UploadDataRequest",
          "name" : "UploadDataRequest",
          "properties" : { "data" : { "items" : { "$ref" : "SensorData" },
                  "position" : 0,
                  "type" : "array"
                },
              "tags" : { "items" : { "$ref" : "DataPointTags" },
                  "position" : 0,
                  "type" : "array"
                },
              "write_token" : { "position" : 0,
                  "type" : "string"
                }
            },
          "qualifiedType" : "com.sensorfront.backend.rest.protocols.UploadDataRequest",
          "required" : [ "write_token",
              "data",
              "tags"
            ]
        }
    },
  "produces" : [ "application/json" ],
  "protocols" : [ "http" ],
  "resourcePath" : "/rest/data",
  "swaggerVersion" : "1.2"
}

I don't know if it matters or not, I am using Scalatra 2.4, Scala 2.11.6.

I appreciate your advise,
Ali

@sundriver sundriver changed the title Swagger java.lang.NullPointerException - 2.1.2 Swagger java.lang.NullPointerException - java code gen - 2.1.2 Jun 23, 2015
@wing328
Copy link
Contributor

wing328 commented Jun 23, 2015

I couldn't repeat the issue in my machine (mac os x, java7). Did you do a mvn clean && mvn install before generating the code?

@sundriver
Copy link
Author

I did further check, The error is actually from this swagger json:

{
   "apiVersion":"1.0.0",
   "swaggerVersion":"1.2",
   "resourcePath":"/rest/groups",
   "produces":[
      "application/json"
   ],
   "consumes":[
      "application/json"
   ],
   "protocols":[
      "http"
   ],
   "apis":[
      {
         "path":"/rest/groups/",
         "operations":[
            {
               "method":"POST",
               "summary":"Creating a new group",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"CreateGroup",
               "parameters":[
                  {
                     "name":"body",
                     "description":"New Group",
                     "required":true,
                     "paramType":"body",
                     "type":"GroupCreateUpdateRequest"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"Returning the newly created group"
                  },
                  {
                     "code":401,
                     "message":"Create failed, error message is provided in the body response"
                  }
               ],
               "type":"GroupResponse"
            },
            {
               "method":"GET",
               "summary":"Getting the list of all groups defined by a specific user",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"ListGroups",
               "parameters":[
                  {
                     "name":"id",
                     "description":"Id of the user from whom we are retrieving the list of groups",
                     "required":true,
                     "paramType":"path",
                     "type":"string"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"List of groups delivered"
                  }
               ],
               "type":"array",
               "items":{
                  "$ref":"GroupResponse"
               }
            }
         ]
      },
      {
         "path":"/rest/groups/user/{id}",
         "operations":[
            {
               "method":"GET",
               "summary":"Getting the list of all groups owned by a user",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"ListUserGroups",
               "parameters":[
                  {
                     "name":"id",
                     "description":"Id of the user",
                     "required":true,
                     "paramType":"path",
                     "type":"string"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"List of all groups owned by a user delivered"
                  }
               ],
               "type":"array",
               "items":{
                  "$ref":"GroupResponse"
               }
            }
         ]
      },
      {
         "path":"/rest/groups/{id}",
         "operations":[
            {
               "method":"DELETE",
               "summary":"Delete a group using user id ad group id",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"DeleteGroup",
               "parameters":[
                  {
                     "name":"id",
                     "description":"Id of the group to be deleted",
                     "required":true,
                     "paramType":"path",
                     "type":"string"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"Group is deleted successfully"
                  },
                  {
                     "code":401,
                     "message":"Delete failed, error message is provided in the body response"
                  }
               ],
               "type":"void"
            },
            {
               "method":"GET",
               "summary":"Get a group using user id and group id",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"GetGroup",
               "parameters":[
                  {
                     "name":"id",
                     "description":"Id of the group to be retrieved",
                     "required":true,
                     "paramType":"path",
                     "type":"string"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"Successfully returning the group"
                  },
                  {
                     "code":401,
                     "message":"Retrieval failed, error message is provided in the body response"
                  }
               ],
               "type":"GroupResponse"
            },
            {
               "method":"PUT",
               "summary":"Update a group data",
               "position":0,
               "notes":"",
               "deprecated":false,
               "nickname":"UpdateGroup",
               "parameters":[
                  {
                     "name":"body",
                     "description":"Updated group fields",
                     "required":true,
                     "paramType":"body",
                     "type":"GroupCreateUpdateRequest"
                  },
                  {
                     "name":"id",
                     "description":"Id of the group to be updated",
                     "required":true,
                     "paramType":"path",
                     "type":"string"
                  }
               ],
               "responseMessages":[
                  {
                     "code":200,
                     "message":"Updated is applied successfully. Returning the updated group"
                  },
                  {
                     "code":401,
                     "message":"Retrieval failed, error message is provided in the body response"
                  }
               ],
               "type":"GroupResponse"
            }
         ]
      }
   ],
   "models":{
      "GroupCreateUpdateRequest":{
         "id":"GroupCreateUpdateRequest",
         "name":"GroupCreateUpdateRequest",
         "qualifiedType":"com.sensorfront.backend.rest.protocols.GroupingProtocol$GroupCreateUpdateRequest",
         "required":[
            "name",
            "sensor_ids",
            "geo_area"
         ],
         "properties":{
            "name":{
               "position":0,
               "type":"string"
            },
            "sensor_ids":{
               "position":0,
               "type":"array",
               "items":{
                  "type":"string"
               },
               "uniqueItems":true
            },
            "website":{
               "position":0,
               "type":"string"
            },
            "description":{
               "position":0,
               "type":"string"
            },
            "geo_area":{
               "position":2,
               "type":"array",
               "items":{
                  "type":"array",
                  "items":{
                     "$ref":"Object"
                  }
               }
            }
         }
      },
      "GroupResponse":{
         "id":"GroupResponse",
         "name":"GroupResponse",
         "qualifiedType":"com.sensorfront.backend.rest.protocols.GroupingProtocol$GroupResponse",
         "required":[
            "id",
            "name",
            "user_id",
            "sensor_ids",
            "geo_area",
            "updated_at",
            "created_at"
         ],
         "properties":{
            "id":{
               "position":0,
               "type":"string"
            },
            "website":{
               "position":0,
               "type":"string"
            },
            "description":{
               "position":0,
               "type":"string"
            },
            "name":{
               "position":1,
               "type":"string"
            },
            "user_id":{
               "position":2,
               "type":"string"
            },
            "sensor_ids":{
               "position":3,
               "type":"array",
               "items":{
                  "type":"string"
               },
               "uniqueItems":true
            },
            "geo_area":{
               "position":4,
               "type":"array",
               "items":{
                  "type":"array",
                  "items":{
                     "$ref":"Object"
                  }
               }
            },
            "updated_at":{
               "position":7,
               "type":"string",
               "format":"date-time"
            },
            "created_at":{
               "position":8,
               "type":"string",
               "format":"date-time"
            }
         }
      }
   },
   "basePath":"http://localhost:8080"
}

Could you please try this one.

@wing328
Copy link
Contributor

wing328 commented Jun 23, 2015

Seems to me it's due to the following:

            "geo_area":{
               "position":2,
               "type":"array",
               "items":{
                  "type":"array",
                  "items":{
                     "$ref":"Object"
                  }
               }
            }

Is that expected - an array of array of Object ? Null pointer exception is gone after removing the nested array (replaced with just "$ref":"Object")

and "Object" (model) is not defined, is that supposed to have at least one property ?

How do you obtain the Swagger Spec ?

@sundriver
Copy link
Author

Thanks for looking into this, don't know why scalatra generated that swagger spec with Object in it. Anyways, after changing my model, I noticed I am getting the same error with:

"geo_area":{
               "position":2,
               "type":"array",
               "items":{
                  "type":"array",
                  "items":{
                     "type":"number"
                  }
               }
            }

@wing328
Copy link
Contributor

wing328 commented Jun 27, 2015

@sundriver can you please given an an example of what geo_area looks like ?

@webron
Copy link
Contributor

webron commented Jul 5, 2015

FWIW, the output @sundriver presented is Swagger 1.2, where there was no support for nested arrays. The conversion to 2.0 may fail on that or produce something unexpected which would lead to the failure experienced.

@vijayrcse
Copy link

Hi Could you please help how this exception is resolved?
I am also trying to have a List of List String ( array of array ) representation in my json file

Would like to know the corrrect schema declaration for this ? I am using swagger2.0

related issue raised by me
#989

@fehguy
Copy link
Contributor

fehguy commented Oct 26, 2015

The swagger-parser now has fallbacks for malformed types. Please give master a try.

@fehguy fehguy closed this as completed Oct 26, 2015
@fehguy fehguy modified the milestone: v2.1.4 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants