carlansley / swagger2-koa

Koa 2 middleware for swagger2
MIT License
99 stars 28 forks source link

Schema validation should be reworked/optional #16

Closed dmythro closed 6 years ago

dmythro commented 6 years ago

I have problems with validation and offering to make it optional via parameter at least.

The schema I'm checking is valid, but I did a test and validated like swagger2:

const fs = require('fs');
const jsonValidator = require('is-my-json-valid');
const schemaValidator = jsonValidator(
  JSON.parse(fs.readFileSync(__dirname + '/node_modules/swagger2/src/schema.json', 'utf8')),
  {
    verbose: true
  }
);

And get error:

Errors [ { field: 'data.paths',
    message: 'referenced schema does not match',
    value: 
     { '/login': [Object],
       '/logout': [Object],

       ...

       '/data': [Object] },
    type: undefined } ]

Schema is actually a valid 2.0 schema and works fine. Also passes swagger-tools validate without a notice.

carlansley commented 6 years ago

If the schema is valid and we're failing it, thats a bug we should fix. Can you attach a shareable/minimal version of your schema that exhibits this behavior?

dmythro commented 6 years ago

That was actually a lot of time ago, not sure if it's possible but will check.

carlansley commented 6 years ago

If you get a chance to create the schema, feel free to re-open.