zalando / problem

A Java library that implements application/problem+json
https://zalando.github.io/problem
MIT License
891 stars 83 forks source link

Exclude status code from body #245

Closed esunder closed 3 years ago

esunder commented 3 years ago

Some colleagues of mine are looking into the problem library for our spring boot app. One discussion has come up about the inclusion of the status code in the body, since it is already provided in the header.

This stackoverflow post seems to describe the spirit of our discussion pretty well. https://stackoverflow.com/questions/43850093/should-response-of-rest-api-contain-http-result-code

Detailed Description

Some way to disable the status code from the body and rely only on the header.

I'd actually like to get your opinions on this before it really becomes a feature request. Should the status code be in the body? I know its in RFC 7807 Problem Details, but its also mentioned as advisory. https://tools.ietf.org/html/rfc7807

Thoughts?

whiskeysierra commented 3 years ago

I'd argue that the status property is an essential part of a problem. Same as type, title, detail and instance. Either we make all of them configurable or none. But that to me feels like too many control knobs for this library.

The argument in favor of the status member is that the problem is self-contained. You don't need any other, additional information of the response to process it.

If you want to deviate from RFC 7807, then I'd say this library is not for you.