swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

Validate that the example value matches to the schema

Open Sweetchuck opened this issue 6 years ago • 1 comments

Currently the example value can have a different data structure that is defined in the schema and the swagger-cli validate doesn't rise an error.

example:
    foo:
        bar: a
        baz: b
type: object
properties:
    foo:
        type: integer
        format: int32
        default: 0

I think it would be very useful if the example value would be validated against the corresponding schema.

Sweetchuck avatar Nov 25 '19 09:11 Sweetchuck

Actually there's already a tool in NPM that does that https://www.npmjs.com/package/openapi-examples-validator?activeTab=readme - so I think can close the request

stueynz avatar Jul 22 '21 03:07 stueynz

That tool or even Spectral could do the job, and lots of other fancy validation on top, so I'll close this.

philsturgeon avatar Jul 28 '23 09:07 philsturgeon