huma icon indicating copy to clipboard operation
huma copied to clipboard

Validation of response

Open jceb opened this issue 2 years ago • 0 comments

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 with ctx.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 with ctx.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().

jceb avatar May 05 '22 05:05 jceb