I want Thingifier to parse and apply Accept headers correctly for JSON, XML, wildcards, quality values, and structured +json media types, so API responses use a supported representation and reject unsupported JSON-shaped media types such as application/problem+json.
Background
Thingifier currently supports standard API representations such as application/json and application/xml. Some Accept headers can still be JSON-related without being application/json, e.g. application/*+json, application/problem+json, or vendor types like application/vnd.api+json. These should not automatically be treated as supported unless Thingifier has an explicit representation writer for them.
Required Behavior
Accept: application/json returns JSON with Content-Type: application/json.
- Missing
Accept or Accept: */* returns the existing default representation, normally application/json.
Accept: application/xml returns XML when the endpoint supports XML.
Accept headers with multiple values must respect q values.
q=0 means “not acceptable” and must not be selected.
- Unsupported media types must be ignored when a supported alternative is present.
- If no acceptable supported representation exists, return
406 Not Acceptable.
Structured JSON Rules
- Do not treat every
+json media type as application/json.
application/problem+json, application/vnd.api+json, application/hal+json, and similar types should return 406 Not Acceptable unless Thingifier explicitly supports that exact representation.
Accept: application/*+json means the client accepts structured +json media types. It should not match plain application/json.
- If Thingifier later adds a concrete
+json representation, e.g. application/problem+json, then application/*+json may match that supported concrete type.
Examples
Accept: application/json, application/problem+json returns application/json.
Accept: application/problem+json, application/json;q=0.5 returns application/json.
Accept: application/problem+json returns 406.
Accept: application/*+json returns 406 unless a supported +json representation exists.
Accept: application/json;q=0, application/xml returns XML.
Accept: application/json;q=0 returns 406.
Acceptance Criteria
- Add an
Accept header parser that handles comma-separated media ranges, parameters, and q values.
- Add content negotiation tests for exact matches, wildcards, unsupported media types,
+json suffix types, and q=0.
- Keep existing default JSON behavior for no
Accept and */*.
- Ensure
application/problem+json is rejected until explicitly implemented.
- Ensure chosen response
Content-Type matches a representation Thingifier can actually serialize.
I want Thingifier to parse and apply
Acceptheaders correctly for JSON, XML, wildcards, quality values, and structured+jsonmedia types, so API responses use a supported representation and reject unsupported JSON-shaped media types such asapplication/problem+json.Background
Thingifier currently supports standard API representations such as
application/jsonandapplication/xml. SomeAcceptheaders can still be JSON-related without beingapplication/json, e.g.application/*+json,application/problem+json, or vendor types likeapplication/vnd.api+json. These should not automatically be treated as supported unless Thingifier has an explicit representation writer for them.Required Behavior
Accept: application/jsonreturns JSON withContent-Type: application/json.AcceptorAccept: */*returns the existing default representation, normallyapplication/json.Accept: application/xmlreturns XML when the endpoint supports XML.Acceptheaders with multiple values must respectqvalues.q=0means “not acceptable” and must not be selected.406 Not Acceptable.Structured JSON Rules
+jsonmedia type asapplication/json.application/problem+json,application/vnd.api+json,application/hal+json, and similar types should return406 Not Acceptableunless Thingifier explicitly supports that exact representation.Accept: application/*+jsonmeans the client accepts structured+jsonmedia types. It should not match plainapplication/json.+jsonrepresentation, e.g.application/problem+json, thenapplication/*+jsonmay match that supported concrete type.Examples
Accept: application/json, application/problem+jsonreturnsapplication/json.Accept: application/problem+json, application/json;q=0.5returnsapplication/json.Accept: application/problem+jsonreturns406.Accept: application/*+jsonreturns406unless a supported+jsonrepresentation exists.Accept: application/json;q=0, application/xmlreturns XML.Accept: application/json;q=0returns406.Acceptance Criteria
Acceptheader parser that handles comma-separated media ranges, parameters, andqvalues.+jsonsuffix types, andq=0.Acceptand*/*.application/problem+jsonis rejected until explicitly implemented.Content-Typematches a representation Thingifier can actually serialize.