-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Comments
I couldn't repeat the issue in my machine (mac os x, java7). Did you do a |
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. |
Seems to me it's due to the following:
Is that expected - an array of array of Object ? Null pointer exception is gone after removing the nested array (replaced with just and "Object" (model) is not defined, is that supposed to have at least one property ? How do you obtain the Swagger Spec ? |
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"
}
}
} |
@sundriver can you please given an an example of what |
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. |
Hi Could you please help how this exception is resolved? Would like to know the corrrect schema declaration for this ? I am using swagger2.0 related issue raised by me |
The swagger-parser now has fallbacks for malformed types. Please give master a try. |
Hi Swagger-Codegen team,
I just updated my local copy to the latest version, 2.1.2 and I am receiving the following error:
Here is the swagger json for SensorSummary
I don't know if it matters or not, I am using Scalatra 2.4, Scala 2.11.6.
I appreciate your advise,
Ali
The text was updated successfully, but these errors were encountered: