Closed fullstackwebdev closed 7 years ago
also, suggested on #swagger to try this swagger.json: http://petstore.swagger.io/v2/swagger.json?
errors in a completely different area, but a lodash problem as well:
create handlers/store/order/{orderId}.js
create handlers/user.js
create handlers/user/createWithArray.js
create handlers/user/createWithList.js
create handlers/user/login.js
create handlers/user/logout.js
create handlers/user/{username}.js
create models/order.js
create models/user.js
create models/category.js
create models/tag.js
create models/apiresponse.js
create models/pet.js
undefined:44
body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexOf('/') + 1)];
^
TypeError: Cannot read property 'slice' of undefined
at eval (eval at template (/home/fullstack/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:44:52)
at Function.forEach (/home/fullstack/node_modules/lodash/dist/lodash.js:3298:15)
at eval (eval at template (/home/fullstack/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:26:15)
at Function.forEach (/home/fullstack/node_modules/lodash/dist/lodash.js:3298:15)
at eval (eval at template (/home/fullstack/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:13:3)
at underscore [as _engine] (/home/fullstack/node_modules/yeoman-generator/lib/util/engines.js:32:30)
at engine (/home/fullstack/node_modules/yeoman-generator/lib/actions/actions.js:303:10)
at template (/home/fullstack/node_modules/yeoman-generator/lib/actions/actions.js:281:15)
at /home/fullstack/node_modules/generator-swaggerize/app/index.js:372:18
at Array.forEach (native)
the same stack is seen with https://github.com/krakenjs/generator-swaggerize/pull/70 (see https://travis-ci.org/krakenjs/generator-swaggerize/jobs/110177935).
The issue happens because http://petstore.swagger.io/v2/swagger.json contains the following definition:
Pets: {
type: "array",
items: {
$ref: "#/definitions/Pet"
}
},
this model is an array of another model the properties are defined in the Pet
model while the _model template used by swaggerize expects properties to be defined.
I don't know this project well enough to fix the _model template.
Published generator-swaggerize - v2.0.2
@subeeshcbabu I'm still getting the aforementioned
body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexOf('/') + 1)];
TypeError: Cannot read property 'slice' of undefined
error.
@Kitanotori - Can you share the version of the generator and the api file?
Its the same Petstore schema - http://petstore.swagger.io/v2/swagger.json
full stack:
$ yo swaggerize
Swaggerize Generator
? What would you like to call this project: test
? Your name:
? Your github user name:
? Your email:
? Path (or URL) to swagger document: http://petstore.swagger.io/v2/swagger.json
? Express, Hapi or Restify: hapi
create .jshintrc
create .gitignore
create .npmignore
create server.js
create package.json
create README.md
create config/swagger.json
create handlers/pet.js
create handlers/pet/findByStatus.js
create handlers/pet/findByTags.js
create handlers/pet/{petId}.js
create handlers/pet/{petId}/uploadImage.js
create handlers/store/inventory.js
create handlers/store/order.js
create handlers/store/order/{orderId}.js
create handlers/user.js
create handlers/user/createWithArray.js
create handlers/user/createWithList.js
create handlers/user/login.js
create handlers/user/logout.js
create handlers/user/{username}.js
create models/order.js
create models/category.js
create models/user.js
create models/tag.js
create models/pet.js
create models/apiresponse.js
undefined:44
body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexOf('/') + 1)];
^
TypeError: Cannot read property 'slice' of undefined
at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:44:52)
at Function.forEach (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:3298:15)
at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:26:15)
at Function.forEach (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:3298:15)
at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:13:3)
at underscore [as _engine] (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/lib/util/engine
I had to uninstall and npm cache clean
my older generator-swaggerize
versions and then install the 2.0.2
to get the fix for the above issue. I am wondering if that is the same case for you as well.
In my local, I am able to scaffold the project from http://petstore.swagger.io/v2/swagger.json using 2.0.2
version.
I've not had any prior version installed. Reinstalling doesn't help.
Please note that express generator works, but not hapi - my stack above is for hapi.
ah that makes sense. The automates unit tests for hapi
somehow passes and that may need a fix too. The fix for express need to be copied over to other framework options as well.
I'm also getting this error and identified my case: I have a Map/Dictionary definition in my swagger.yaml as follows:
Map:
type: object
additionalProperties:
type: string
Since this object doesn't have "properties" it's failing. If I add "properties" it would work. I'm trying to model a Map/Dictionary as described in the Model with Map/Dictionary Properties section of Open API Specification. Anyway, since the error raises when generating the models, I don't even know if it would make sense to generate that model without properties. Maybe the generator could skip this cases?
Working on the version generator version 3 release which will address all these open issues and implement missing features from Swagger 2.0 spec. - https://github.com/krakenjs/generator-swaggerize/milestones/v3.0.0.
Yes. the model generator should skip if no properties
found.
Upcoming generator release is going to replace the model concept with mocks
and `data.
Please check the latest version generator-swaggerize@3.0.0
. This should be resolved.
running
on the petstore-simple.json interface (https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-simple.json)
does not run on my local machine, or other servers I tried.
I get a lodash error
Upgrading lodash to version 3 doesn't fix this -- nor does updating the package Yeoman Generator to latest (0.22.5). ( I thought that might help..)
Strange?