Question

I've been using Guzzle models with some success. Response data is unserialized just fine, and I can augment the data with other values not in the original JSON response.

However, all my models are missing their validation structure. I don't get any validation errors when I return unexpected keys or values of the wrong type. Either I'm doing something wrong or I misunderstand what's supposed to happen.

Here's my example code in the form of a test case:
https://gist.github.com/timwhitlock/8511971

Note particularly the last assertion. The lack of validation errors might be explained by the missing structure. But why is it missing?

Was it helpful?

Solution

The author of Guzzle has answered my question via a Gist comment. https://gist.github.com/timwhitlock/8511971#comment-990206

By default, response models are allowed to pick up additional (undeclared) properties in the response, but you can set additionalProperties to false to prevent it.

The original schema used to generate a response model is not present by default as most use-cases don't require it and it makes debugging messier when present.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top