localmed / api-mock

Creates a mock server based on an API Blueprint
MIT License
496 stars 58 forks source link

api-mock does not work with blueprint schema validations #24

Open JemiloII opened 9 years ago

JemiloII commented 9 years ago

Pretty cool so far, just api-mock doesn't understand schema and will send a response regardless of the schema.

### Method [POST]

+ Request 200 (application/json)

    + Schema

        {
            "type": "object",
            "required": true,
            "properties": {
                "name": {
                    "type": "string",
                    "required": true
                }
            }
        }
ecordell commented 9 years ago

api-mock [...] will send a response regardless of the schema.

What behavior are you seeing, and what did you expect/want? api-mock does its "mocking" (stubbing if you want to be picky) by returning the example bodies. Do you want it to generate a body based on the schema? I think that could work in most cases.

JemiloII commented 9 years ago

I was looking for api-mock to validate incoming parameters.

So with the above Schema, if I omitted the name property, I would get a required error. If name wasn't a string, then I would get an Error saying Name must be a string.

Thanks for looking into it.