mac- / ratify

A Hapi plugin for validating the schema of path, query, request body, and response body params using JSON-schema
MIT License
71 stars 27 forks source link

Is there a reason why response validation requires an object? #9

Closed dschenkelman closed 10 years ago

dschenkelman commented 10 years ago

I believe schemas like this one should be usable:

response: {
    schema: {
        // response payload schema
        type: 'string'
    },
    sample: 100, // percentage of responses to test against the schema
    failAction: 'log' // action to take when schena validation fails. Valid options are; 'log' and 'error'
}

IMO it should be up to the schema whether something is a valid response or not. Thoughts?

https://github.com/mac-/ratify/blob/master/lib/RouteSchemaManager.js#L267-L269

mac- commented 10 years ago

You are right, I can't remember the exact issue I was trying to resolve, but this was the wrong way of going about it. Let me try and fix that.

dschenkelman commented 10 years ago

Great, thought it was a bit weird. Kept seeing log entries failing for string response schemas and couldn't figure out what it was.

dschenkelman commented 10 years ago

Awesome!