11# JSON: API
22
3- API Platform supports the [ JSON: API ] ( https://jsonapi.org ) format. When a client
4- sends a request with an ` Accept: application/vnd.api+json ` header, API Platform
5- serializes responses following the JSON: API specification.
3+ API Platform supports the [ JSON: API ] ( https://jsonapi.org ) format. When a client sends a request with
4+ an ` Accept: application/vnd.api+json ` header, API Platform serializes responses following the
5+ JSON: API specification.
66
7- For details on enabling formats, see
8- [ content negotiation] ( content-negotiation.md ) .
7+ For details on enabling formats, see [ content negotiation] ( content-negotiation.md ) .
98
109## Entity Identifiers as Resource IDs
1110
12- We recommend configuring API Platform to use entity identifiers as the ` id `
13- field of JSON : API resource objects. This will become the default in 5.x:
11+ We recommend configuring API Platform to use entity identifiers as the ` id ` field of JSON : API
12+ resource objects. This will become the default in 5.x:
1413
1514``` yaml
1615# config/packages/api_platform.yaml
@@ -19,9 +18,9 @@ api_platform:
1918 use_iri_as_id : false
2019` ` `
2120
22- With this configuration, the JSON:API ` id` field contains the entity identifier
23- (e.g., `"10"`) instead of the full IRI (e.g., `"/dummies/10"`). A `links.self`
24- field is added to each resource object for navigation :
21+ With this configuration, the JSON:API ` id` field contains the entity identifier (e.g., `"10"`)
22+ instead of the full IRI (e.g., `"/dummies/10"`). A `links.self` field is added to each resource
23+ object for navigation :
2524
2625` ` ` json
2726{
@@ -50,18 +49,18 @@ Relationships reference related resources by entity identifier and `type`.
5049
5150# ## Composite Identifiers
5251
53- Resources with composite identifiers use a semicolon-separated string as the `id`
54- value (e.g., `"field1=val1;field2=val2"`).
52+ Resources with composite identifiers use a semicolon-separated string as the `id` value (e.g.,
53+ ` "field1=val1;field2=val2"` ).
5554
5655# ## Resources Without a Standalone Item Endpoint
5756
58- API Platform must resolve the IRI for any resource that appears in a
59- relationship. If a resource has no standalone `GET` item endpoint (for example,
60- it is only exposed as a subresource), IRI resolution fails.
57+ API Platform must resolve the IRI for any resource that appears in a relationship. If a resource has
58+ no standalone `GET` item endpoint (for example, it is only exposed as a subresource), IRI resolution
59+ fails.
6160
62- Use the `NotExposed` operation to register a URI template for internal IRI
63- resolution without exposing a public endpoint. A `NotExposed` operation registers
64- the route internally but returns a `404` response when accessed directly :
61+ Use the `NotExposed` operation to register a URI template for internal IRI resolution without
62+ exposing a public endpoint. A `NotExposed` operation registers the route internally but returns a
63+ `404` response when accessed directly :
6564
6665` ` ` php
6766<?php
@@ -78,6 +77,6 @@ class Tag
7877}
7978` ` `
8079
81- This allows a parent resource to reference `Tag` objects in its relationships
82- while `Tag` itself has no public item endpoint. The `NotExposed` operation
83- requires a `uriTemplate` with a single URI variable.
80+ This allows a parent resource to reference `Tag` objects in its relationships while `Tag` itself has
81+ no public item endpoint. The `NotExposed` operation requires a `uriTemplate` with a single URI
82+ variable.
0 commit comments