Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alan Poulain <contact@alanpoulain.eu>
  • Loading branch information
soyuka and alanpoulain committed Nov 26, 2020
1 parent 01ed8dd commit 001f714
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/adr/0001-resource-identifiers.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Resource identifiers
# Resource Identifiers

* Status: proposed
* Deciders: @dunglas @alanpoulain @soyuka

Technical Story: [#2126][pull/2126]
Implementation: [#3825][pull/3825 ]
Implementation: [#3825][pull/3825]

## Context and Problem Statement

In API Platform, a resource is identified by [IRIs][rfc/IRI], for example `/books/1`. Internally, this is also known as a route with an identifier parameter named `id`: `/books/{id}`. This `id` parameter is then matched to the resource identifiers, known by the `ApiProperty` metadata when `identifier` is true. When multiple identifiers are found, composite identifiers map the value of `id` to the resource identifiers (eg: `keya=value1;keyb=value2`, where `keya` and `keyb` are identifiers of the resource). This behavior is suggested by the [URI RFC][rfc/URI].
Subresources IRIs have multiple parts, for example: `/books/{id}/author/{authorId}`. The router needs to know that `id` matches the `Book` resource, and `authorId` the `Author` resource. To do so, a Tuple representing the class and the property matching each parameter is linked to the route, for example: `id: [Book, id], authorId: [User, id]`.
By normalizing the shape of (sub)-resources (see [0000-subresources-definition][0000-subresources-definition]), we need to normalize the resource identifiers.
By normalizing the shape of (sub-)resources (see [0000-subresources-definition][0000-subresources-definition]), we need to normalize the resource identifiers.

## Decision Outcome

Declare explicit resource `identifiers` that will default to `id: [id, Resource]` with composite identifiers. Allow composite identifiers to be disabled if needed.

### Examples

Define a route `/users/{id}`
Define a route `/users/{id}`:

```php
/**
Expand Down

0 comments on commit 001f714

Please sign in to comment.