문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top