cranetm / yii2-json-rpc-2.0

Other
26 stars 18 forks source link

Validation returns null on non-conformance with DTO instead of raising an exception #21

Open cboulanger opened 6 years ago

cboulanger commented 6 years ago

Maybe I am doing something wrong, but if I declare a @return \myapp\dto\MySpecialDto in the action comments, and the result doesn't match that DTO, the response is null. Shouldn't it raise an exception instead which explains what's wrong?

cranetm commented 6 years ago

The most reasonable here is log warning in application.log. Null result is logical, because value does not meet the DTO. Thats development issue and exists only in dev process. DTO's are only to help you organize your interfaces. If you have mess in code and do not know result, you can skip validation. Just remove @return DtoClass.

cranetm commented 6 years ago

Maybe throwing exception in DEV environment makes sense. But in PRODUCTION it should be just warning.

cboulanger commented 6 years ago

Ok. I'd be happy if you could add it for DEV mode!