krakenjs / swaggerize-express

Design-driven apis with swagger 2.0 and express.
Other
355 stars 81 forks source link

PetStore example fails with latest generator #94

Closed dcolens closed 8 years ago

dcolens commented 8 years ago
$ node -v
v4.3.1

$ npm -v
3.7.2

$ yo swaggerize
Swaggerize Generator
? What would you like to call this project: p
? Your name: 
? Your github user name: 
? Your email: 
? Path (or URL) to swagger document: https://raw.githubusercontent.com/wordnik/swagger-spec/master/examples/v2.0/json/petstore.json
? Express, Hapi or Restify: express
identical .jshintrc
identical .gitignore
identical .npmignore
identical server.js
identical package.json
identical README.md
identical config/petstore.json
undefined:11
_.forEach(Object.keys(properties), function (prop) {;
                      ^

ReferenceError: properties is not defined
    at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/lodash/dist/lodash.js:6306:22), <anonymous>:11:23)
    at underscore [as _engine] (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/lib/util/engines.js:32:30)
    at engine (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/lib/actions/actions.js:303:10)
    at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/lib/actions/actions.js:281:15)
    at /usr/local/lib/node_modules/generator-swaggerize/app/index.js:287:18
    at Array.forEach (native)
    at yeoman.generators.Base.extend.models (/usr/local/lib/node_modules/generator-swaggerize/app/index.js:276:49)
    at /usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/lib/base.js:341:43
    at /usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/async/lib/async.js:551:21
    at /usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/async/lib/async.js:227:13

Travis seems to have the same issue: https://travis-ci.org/krakenjs/generator-swaggerize/jobs/110153740

tlivings commented 8 years ago

It should. It sounds like something is missing in your api spec. This shouldn't error, but that's why it is choking.

dcolens commented 8 years ago

Maybe it was not obvious but the example above is not "my API spec" it is the example from the swaggerize homepage: https://raw.githubusercontent.com/wordnik/swagger-spec/master/examples/v2.0/json/petstore.json

Also note I tried with the latest node 0.12 and 4.x and they both fail in the same manner.

subeeshcbabu-zz commented 8 years ago

I think this is related to the issue resolved by this PR - https://github.com/krakenjs/generator-swaggerize/pull/70 Pets: { type: "array", items: { $ref: "#/definitions/Pet" } },

The current generator version was lacking support for models with schema type array. This change is yet to get published.

Also one more point to note is that, the current version of generator expects the definition to have the properties and lack support for external $ref - https://github.com/krakenjs/generator-swaggerize/issues/61

dcolens commented 8 years ago

Duplicate of https://github.com/krakenjs/generator-swaggerize/issues/73