foca
foca copied to clipboard
Check for content types accepted by client
API endpoints can serve different content types, e.g., application/json
, text/plain
etc. Clients can ask a service to respond with one or more specific accepted content types.
It would be nice if FOCA implemented a solution (e.g., a decorator) that compares the client's desired content type(s) against the ones that the service offers for the respective endpoint (as defined in the API specs). An appropriate error response should be returned if a client requests a content type that the endpoint cannot deliver. If the client does not explicitly ask for a specific content type (i.e., if the Accept: <content-type>
header is missing), the default response should be given.
Other important points to think about:
- Connexion may already take care of validating
Accept
headers to some extent; on the other hand, it may also be the case that Connexion will complain if JSON-incompatible content types are to be returned - It needs to be checked how content is negotiated between client and server, especially in situations where the client/server accepts/offers multiple content types