krakenjs / generator-swaggerize

Yeoman generator for design-driven apis with swagger 2.0 and krakenjs/swaggerize tools.
Other
70 stars 34 forks source link

model parsing issue #12

Closed b3ll4t0r closed 8 years ago

b3ll4t0r commented 9 years ago
undefined:47
            body = models[param.schema.$ref.slice(param.schema.$ref.lastIndexO
                                                                    ^
TypeError: Cannot call method 'lastIndexOf' of undefined
    at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:6305:22), <anonymous>:47:77)
    at Function.forEach (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:3297:15)
    at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:6305:22), <anonymous>:29:15)
    at Function.forEach (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:3297:15)
    at eval (eval at template (/usr/local/lib/node_modules/generator-swaggerize/node_modules/yeoman-generator/node_modules/lodash/dist/lodash.js:6305:22), <anonymous>:16:3)
    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:347:18
    at Array.forEach (native)
tlivings commented 9 years ago

Yeah, this assumes you are using $ref from you body's schema definition. The reason for this is that models are generated from the api document's definitions section (by convention used for models in Swagger).

If you don't have a definitions section for models, then the generator won't create models for them, and the tests won't know how to stub data.

MattiSG commented 9 years ago

If it wontfix, perhaps should it be closed? :)

aredridel commented 9 years ago

Also it could be robust to this and not just bomb.

tlivings commented 9 years ago

Yeah will be adding more robust checks in general. Added wontfix tag to indicate that the root cause won't be fixed.

subeeshcbabu-zz commented 8 years ago

Closing as per #62