Skip to content

feat: JSON:API 1.1 compliance (v2.1.0)#134

Open
treere wants to merge 1 commit into
lucacorti:mainfrom
treere:jsonapi1.1
Open

feat: JSON:API 1.1 compliance (v2.1.0)#134
treere wants to merge 1 commit into
lucacorti:mainfrom
treere:jsonapi1.1

Conversation

@treere
Copy link
Copy Markdown
Collaborator

@treere treere commented May 25, 2026

Hi! A small big change but this should complete the support of jsonapi 1.1

Adds JSON:API 1.1 compliance to jsonapi_plug, bumping the library to v2.1.0.
The changes are backward-compatible with JSON:API 1.0 and are opt-in via API configuration.

Changes

API Configuration

  • Added version: :"1.1", extensions, and profiles options to the API module config.

Content-Type Negotiation

  • ContentTypeNegotiation plug now accepts ext and profile parameters in Content-Type and Accept headers per the 1.1 spec.
  • Returns 415 Unsupported Media Type when an unsupported extension URI is requested.
  • Returns 406 Not Acceptable when all Accept entries are unsupported.
  • Fixed: Content-Type with multiple entries is now correctly accepted if at least one entry is a valid JSON:API media type, regardless of order.

Response Content-Type

  • ResponseContentType plug emits ext and profile parameters in the Content-Type response header when extensions/profiles are configured.
  • Adds Vary: Accept header when extensions or profiles are configured.

JSON:API Object

  • JSONAPIObject gains ext and profile fields.
  • Fields are populated from API config at render time.
  • Emits "version": "1.1" in the top-level jsonapi member when configured.

Link Object

  • LinkObject gains rel, describedby, title, type, and hreflang fields as per the 1.1 link object spec.

Error Object

  • ErrorObject passes through the links.type key, which is a 1.1 addition.

Document Deserialization

  • Silently drops @-prefixed keys from attributes, relationships, and meta during deserialization, as required by the 1.1 spec.

Version

Bumps library version to 2.1.0.

@treere treere requested a review from lucacorti May 25, 2026 09:37
- API config: add version: :"1.1", extensions and profiles options
- ContentTypeNegotiation: accept ext/profile params per 1.1 spec;
  415 on unsupported ext URI, 406 when all Accept entries unsupported
- ResponseContentType: emit ext/profile params in Content-Type and
  add Vary: Accept header when extensions/profiles configured
- JSONAPIObject: add ext and profile fields; populate from API config
  on render; emit version 1.1 when configured
- LinkObject: add rel, describedby, title, type, hreflang fields
- ErrorObject: pass through links.type key (1.1 addition)
- Document: silently drop @-prefixed keys from attributes,
  relationships and meta during deserialization
- Bump version to 2.1.0
@lucacorti
Copy link
Copy Markdown
Owner

Looks good to me. We can maybe test this a little bit in the real world and then release it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants