Skip to content
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

Newb alert: Error: Unrecognized schema type: undefined #42

Open
shankie-codes opened this issue Jul 5, 2017 · 2 comments
Open

Newb alert: Error: Unrecognized schema type: undefined #42

shankie-codes opened this issue Jul 5, 2017 · 2 comments

Comments

@shankie-codes
Copy link

Everything I do is ending up with the error Error: Unrecognized schema type: undefined. I see where that's happening in the source; however, there is no indication as to what line of the spec it's failing on.

Even if I strip things back to a minimal case, with the normal petstore.json, I have the same problem...

const swaggerMongoose = require('swagger-mongoose');
const fs = require('fs');
const path = require('path');

var swagger = fs.readFileSync(path.join( __dirname, '../swagger/petstore.json'));
var Pet = swaggerMongoose.compile(swagger).models.Pet;

Gets me...

Error: Unrecognized schema type: undefined
 at propertyMap (/usr/src/node_modules/swagger-mongoose/lib/index.js:48:13)
...

Any ideas what I might be doing wrong?

@ThirtyOne34
Copy link

Same here :'(

@oehm-smith
Copy link

I solved this. I can't specifically remember what it was. But what i did to find it was modify the code at one of the files in the stack dump to print more information. Looking back through the terminal:

Its the error - property is: "string"
Error: Unrecognized schema type: undefined
    at propertyMap (/Users/bbos/dev/dhs/bots/bottal-api/bottal-api/node_modules/swagger-mongoose/lib/index.js:49:13)
at getSchemaProperty (/Users/bbos/dev/dhs/bots/bottal-api/bottal-api/node_modules/swagger-mongoose/lib/index.js:231:16)

I went to swagger-mongoose/lib/index.js:49 and it was switching on property.type. The error message I added and can be seen ("Its the error ...") was printing property. So property was meant to be an object. And thus I worked backwards to see that i was using string incorrectly. But yes, if you have lots of string then this won't help pinpoint it. But in which case (since. you don't understand the format), drop back to using a really simple swagger data file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants