error during code generation
jmls opened this issue · 6 comments
I'm getting the following error when trying to generate node code
Error: Expected an identifier and instead saw '='. in Test.prototype.User.exists__head_Users_{id} = function(parameters){ (E030)
at node_modules/swagger-js-codegen/lib/codegen.js:214:23
the only place I can find anything like that in the json file is here
"/Users/{id}": {
"head": {
"tags": ["User"],
"summary": "Check whether a model instance exists in the data source.",
"operationId": "User.exists__head_Users_{id}",
"parameters": [{
"name": "id",
"in": "path",
"description": "Model id",
"required": true,
"type": "string",
"format": "JSON"
}],
"responses": {
"200": {
"description": "Request was successful",
"schema": {
"type": "object"
}
}
},
"deprecated": false
},
the json file passes the online validation at http://bigstickcarpet.com/swagger-parser/www/index.html with no errors or warnings, so I don't quite know where or what the problem is ;)
thanks
Can you send me the swagger file? I will add it to the test suite.
yeah, I've been narrowing things down, and this valid spec
{
"swagger": "2.0",
"info": {
"version": "0.0.0",
"title": "myApp"
},
"basePath": "/api",
"consumes": ["application/json", "application/x-www-form-urlencoded", "application/xml", "text/xml"],
"produces": ["application/json", "application/xml", "text/xml", "application/javascript", "text/javascript"],
"paths": {
"/Users/{id}": {
"head": {
"tags": ["User"],
"summary": "Check whether a model instance exists in the data source.",
"operationId": "User.exists__head_Users_{id}",
"parameters": [{
"name": "id",
"in": "path",
"description": "Model id",
"required": true,
"type": "string",
"format": "JSON"
}],
"responses": {
"200": {
"description": "Request was successful",
"schema": {
"type": "object"
}
}
},
"deprecated": false
}
}
},
"definitions": {
"x-any": {
"properties": {}
},
"ObjectID": {
"type": "string",
"pattern": "^[a-fA-F\\d]{24}$"
},
"User": {
"properties": {
"username": {
"type": "string"
},
"id": {
"type": "number",
"format": "double"
}
},
"additionalProperties": false
}
},
"tags": [{
"name": "User"
}]
}
barfs
I am making an educated guess that the "head" verb is not catered for ... ;)
@jmls The issue is the operationId
parameter which we use as a method name. Would it be possible for you to have a more friendly operationId?
bugger - I'm afraid that this comes from a third-party, so I can't change it. Sorry.
@jmls fixed in 1.1.8 hopefully
certainly seems to work for me! many thanks