huma
huma copied to clipboard
Validation of response
I noticed that there are ways to return results that have not been defined for an endpoint:
- ❌
ctx.Write()
seems to always get through and is not compared to what has been defined - ❌
ctx.WriteHeader()
allows me to return a status code that has not been defined - ❌
ctx.Header().Set()
allows me to change the content type to something that has not been defined - ✅
ctx.Header().Set()
combined withctx.WriteHeader()
is validated and fails as expected when the result has not been defined - ✅
ctx.WriteModel()
is validated and fails as expected when the result has not been defined- ❌
ctx.WriteModel()
combined withctx.Write()
is not validated as pointed out above
- ❌
What would be a good way of dealing with these inconsistencies? ctx.Write()
sounds like a wildcard, documentation could cover its behavior. ctx.WriteHeader()
should be verified. I'm not sure about ctx.Header().Set()
.