Skip to content

Commit 22bd0ad

Browse files
committed
Merge branch '2.3'
2 parents 3548831 + 58131bf commit 22bd0ad

File tree

12 files changed

+122
-29
lines changed

12 files changed

+122
-29
lines changed

.travis.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@ node_js:
44

55
cache:
66
yarn: true
7+
directories:
8+
- $HOME/.cache/pip
79

810
env:
911
global:
1012
secure: gjiWHIgNjLXuEFmLiepiOTHOuauHfeKHutrE0sBwFZUQzP9FoGTZzJub1z8/vm+hhygA+TZbB0iclygHyNrXCkZyNdnZXChXl4iPdYqY3OARPOAbQff16+/XSUDsZ/Ok1etdb3kKor1R4rBt/WywBvXmmdggumTA3yT5ExI+dyomdONo4yMUZ7g1la0ehMEzGqyVjt0nUW31PN3l6dI1qgigHCuotSrrpWP6fTXuUh5l6YA7KXb/V1hJxaGENLz1Cdfk0sF66e4KsV/DX6JZSqpvdqVB8OTPU+si511yJtGS8OeuLs4RqmXMLrY/ChCodlYnfCE+NleBFpUnCVqth/RDRh7LvplUJlpsXNcfyoA3mOFmZa0euOMCqJ3qwESz802Y9c5oN63hn2OUF/raFDc3SMMC86FFHxwyYjz5+yzXYupnFNj39NKdQ1v1KBbY8BD8UT8RU3mlu4/3LRz0tSamREHj3pGgBmvgUZfUE1dMngeaZjOmBaIZH8TnKQ75CvfnoT+LJnZo6g9g4uwz6jtaIziSMZ0OW/95nF8yx+xONbHEtt5ex5M09NOFsN2vB2bcUAgIjyGrmmNLQadwJyQv557IGPEE5CyGhJpXh9XZ+WMw2vO45MOw4sQPkARF6OJkMteqFc2NLXMOQJ07EScbgEKR/9VOcyxIk/7a7nc=
1113

12-
before_install:
13-
- curl -o- -L https://yarnpkg.com/install.sh | bash
14-
- export PATH="$HOME/.yarn/bin:$PATH"
15-
1614
install:
17-
- pip install --user proselint
15+
- pip install --quiet --user proselint
1816
- cp .proselintrc ~
1917
- cd ..
20-
- git clone https://github.com/api-platform/website.git
18+
- git clone --depth 1 https://github.com/api-platform/website.git
2119
- cd website
22-
- yarn install
20+
- yarn install --silent
2321
- ln -s $TRAVIS_BUILD_DIR src/pages/docs
2422
- cd $TRAVIS_BUILD_DIR
2523

2624
script:
27-
- find . -name '*.md' ! -name 'conduct.md' ! -name 'heroku.md' -exec proselint {} \;
28-
- cd $TRAVIS_BUILD_DIR/../website
25+
- find . -name '*.md' -exec proselint {} \;
26+
- cd ../website
2927
- bin/generate-nav
3028
- GATSBY_BRANCH_NAME=$TRAVIS_BRANCH yarn gatsby build
3129
# Preserve artifacts

admin/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Install the skeleton and the library:
66

77
Start by installing [the Yarn package manager](https://yarnpkg.com/) ([NPM](https://www.npmjs.com/) is also supported) and
8-
the [Create React App](https://github.com/facebookincubator/create-react-app) tool.
8+
the [Create React App](https://facebook.github.io/create-react-app/) tool.
99

1010
Then, create a new React application for your admin:
1111

@@ -58,7 +58,7 @@ Clear the cache to apply this change:
5858
5959
Your new administration interface is ready! Type `yarn start` to try it!
6060

61-
Note: if you don't want to hardcode the API URL, you can [use an environment variable](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables).
61+
Note: if you don't want to hardcode the API URL, you can [use an environment variable](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables).
6262

6363
## Customizing the Admin
6464

@@ -145,7 +145,7 @@ const myApiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoin
145145
src: value
146146
});
147147
148-
field.fieldComponent = (
148+
field.field = (
149149
<FunctionField
150150
key={field.name}
151151
render={
@@ -157,7 +157,7 @@ const myApiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoin
157157
/>
158158
);
159159

160-
field.inputComponent = (
160+
field.input = (
161161
<ImageInput accept="image/*" key={field.name} multiple={false} source={field.name}>
162162
<ImageField source="src"/>
163163
</ImageInput>

admin/handling-relations-to-collections.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class Book
7171

7272
The admin handles this `to-many` relation automatically!
7373

74-
But we can go further:
75-
7674
## Customizing a Property
7775

7876
Let's customize the components used for the `authors` property, to display them by their 'name' instead 'id' (the default behavior).

client-generator/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The API Platform Client Generator
22

3-
Client Generator is the fastest way to scaffold fully-featured webapps and native mobile apps from APIs supporting the [Hydra](http://www.hydra-cg.com/) format.
3+
Client Generator is the fastest way to scaffold fully featured webapps and native mobile apps from APIs supporting the [Hydra](http://www.hydra-cg.com/) format.
44

55
![Screencast](images/client-generator-demo.gif)
66

core/deprecations.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Deprecating Resources and Properties (Alternative to Versioning)
2+
3+
A best practice regarding web APIs development is to apply [the evolution strategy](https://philsturgeon.uk/api/2018/05/02/api-evolution-for-rest-http-apis/)
4+
to indicate to client applications which resource types, operations and fields are deprecated and shouldn't be used anymore.
5+
6+
While versioning an API requires modifying all clients to upgrade, even the ones not impacted by the changes.
7+
It's a tedious task that should be avoided as much as possible.
8+
9+
On the other hand, the evolution strategy (also known as versionless APIs) consists of deprecating the fields, resources
10+
types or operations that will be removed at some point.
11+
12+
Most modern API formats including [JSON-LD / Hydra](content-negotiation.md), [GraphQL](graphql.md) and [OpenAPI](swagger.md)
13+
allow to mark resources types, operations or fields as deprecated.
14+
15+
## Deprecating Resource Classes, Operations and Properties
16+
17+
When using API Platform, it's easy to mark a whole resource, a specific operation or a specific property as deprecated.
18+
All documentation formats mentioned in the introduction will then automatically take the deprecation into account.
19+
20+
To deprecate a resource class, use the `deprecationReason` attribute:
21+
22+
```php
23+
<?php
24+
// api/src/Entity/Parchment.php
25+
26+
namespace App\Entity;
27+
28+
use ApiPlatform\Core\Annotation\ApiResource;
29+
30+
/**
31+
* @ApiResource(deprecationReason="Create a Book instead")
32+
*/
33+
class Parchment
34+
{
35+
// ...
36+
}
37+
```
38+
39+
As you can see, to deprecate a resource, we just have to explain what the client should do to upgrade in the dedicated attribute.
40+
41+
The deprecation will automatically be taken into account by clients supporting the previously mentioned format, including
42+
[API Platform Admin](../admin/index.md), [API Platform Client Generator](../client-generator/index.md) and the lower level
43+
[api-doc-parser library](https://github.com/api-platform/api-doc-parser).
44+
45+
Here is how it renders for OpenAPI in the built-in Swagger UI shipped with the framework:
46+
47+
![Deprecation shown in Swagger UI](images/deprecated-swagger-ui.png)
48+
49+
And now in the built-in version of GraphiQL (for GraphQL APIs):
50+
51+
![Deprecation shown in GraphiQL](images/deprecated-graphiql.png)
52+
53+
You can also use this new `deprecationReason` attribute to deprecate specific [operations](operations.md):
54+
55+
```php
56+
<?php
57+
// api/src/Entity/Review.php
58+
59+
/**
60+
* @ApiResource(itemOperations={
61+
* "get"={"deprecation_reason"="Retrieve a Book instead"}
62+
* })
63+
*/
64+
class Parchment
65+
{
66+
// ...
67+
}
68+
```
69+
70+
It's also possible to deprecate a single property:
71+
72+
```php
73+
<?php
74+
// api/src/Entity/Review.php
75+
76+
namespace App\Entity;
77+
78+
use ApiPlatform\Core\Annotation\ApiProperty;
79+
use ApiPlatform\Core\Annotation\ApiResource;
80+
81+
/**
82+
* @ApiResource
83+
*/
84+
class Review
85+
{
86+
// ...
87+
88+
/**
89+
* @ApiProperty(deprecationReason="Use the rating property instead")
90+
*/
91+
public $letter;
92+
}
93+
```
94+
95+
* With JSON-lD / Hydra, [an `owl:deprecated` annotation property](https://www.w3.org/TR/owl2-syntax/#Annotation_Properties) will be added to the appropriate data structure
96+
* With Swagger / OpenAPI, [a `deprecated` property](https://swagger.io/docs/specification/2-0/paths-and-operations/) will be added
97+
* With GraphQL, the [`isDeprecated` and `deprecationReason` properties](https://facebook.github.io/graphql/June2018/#sec-Deprecation) will be added to the schema

core/file-upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,5 @@ uploaded cover, you can have a nice illustrated book record!
249249
}
250250
```
251251

252-
Voila! You can now send files to your API, and link them to any other resources
252+
Voilà! You can now send files to your API, and link them to any other resources
253253
in your app.

core/fosuser-bundle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If you are using the API Platform Standard Edition, you will need to enable the
2222
configuration options:
2323

2424
```yaml
25-
# api/config/packages/api_platform.yaml
25+
# api/config/packages/framework.yaml
2626
framework:
2727
form: { enabled: true }
2828
```

core/images/deprecated-graphiql.png

25.9 KB
Loading

core/images/deprecated-swagger-ui.png

53.2 KB
Loading

core/serialization.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ all set!
5858

5959
It is simple to specify what groups to use in the API system:
6060

61-
1. Add the `normalizationContext` and `denormalizationContext` annotation properties to the `@ApiResource` annotation, and specify which groups to use. Here you see that we add `read` and `write`, respectively. You can use any group names you wish.
61+
1. Add the `normalizationContext` and `denormalizationContext` annotation properties to the `@ApiResource` annotation, and specify which groups to use. Here you see that we add `read` and `write`, respectively. You can use any group names you wish.
6262
2. Apply the `@Groups` annotation to properties in the object.
6363

6464
```php
@@ -129,7 +129,7 @@ App\Entity\Book:
129129
```
130130

131131
In the previous example, the `name` property will be visible when reading (`GET`) the object, and it will also be available
132-
to write (`PUT/POST`). The `author` property will be write-only; it will not be visible when serialized responses are
132+
to write (`PUT/POST`). The `author` property will be write-only; it will not be visible when serialized responses are
133133
returned by the API.
134134

135135
Internally, API Platform passes the value of the `normalization_context` to the Symfony Serializer during the normalization
@@ -415,7 +415,7 @@ final class BookContextBuilder implements SerializerContextBuilderInterface
415415
```
416416

417417
If the user has the `ROLE_ADMIN` permission and the subject is an instance of Book, `admin_input` group will be dynamically added to the
418-
denormalization context. The `$normalization` variable lets you check whether the context is for normalization (if `TRUE`) or denormalization
418+
denormalization context. The `$normalization` variable lets you check whether the context is for normalization (if `TRUE`) or denormalization
419419
(`FALSE`).
420420

421421
## Changing the Serialization Context on a Per-item Basis
@@ -500,8 +500,8 @@ class BookAttributeNormalizer implements ContextAwareNormalizerInterface, Normal
500500
This will add the serialization group `can_retrieve_book` only if the currently logged-in user has access to the given book
501501
instance.
502502

503-
Note: In this example, we use the `TokenStorageInterface` to verify access to the book instance. However, Symfony
504-
provides many useful other services that might be better suited to your use case. For example, the [`AuthorizationChecker`](https://symfony.com/doc/current/components/security/authorization.html#authorization-checker).
503+
Note: In this example, we use the `TokenStorageInterface` to verify access to the book instance. However, Symfony
504+
provides many useful other services that might be better suited to your use case. For example, the [`AuthorizationChecker`](https://symfony.com/doc/current/components/security/authorization.html#authorization-checker).
505505

506506
## Name Conversion
507507

@@ -524,7 +524,7 @@ api_platform:
524524

525525
## Decorating a Serializer and Adding Extra Data
526526

527-
In the following example, we will see how we add extra informations to the serialized output. Here is how we add the
527+
In the following example, we will see how we add extra informations to the serialized output. Here is how we add the
528528
date on each request in `GET`:
529529

530530
```yaml
@@ -599,7 +599,7 @@ API Platform is able to guess the entity identifier using [Doctrine metadata](ht
599599
It also supports composite identifiers.
600600

601601
If you are not using the Doctrine ORM Provider, you must explicitly mark the identifier using the `identifier` attribute of
602-
the `ApiPlatform\Core\Annotation\ApiProperty` annotation. For example:
602+
the `ApiPlatform\Core\Annotation\ApiProperty` annotation. For example:
603603

604604

605605
```php
@@ -644,7 +644,7 @@ App\Entity\Book:
644644
```
645645

646646
In some cases, you will want to set the identifier of a resource from the client (e.g. a client-side generated UUID, or a slug).
647-
In such cases, you must make the identifier property a writable class property. Specifically, to use client-generated IDs, you
647+
In such cases, you must make the identifier property a writable class property. Specifically, to use client-generated IDs, you
648648
must do the following:
649649

650650
1. create a setter for the identifier of the entity (e.g. `public function setId(string $id)`) or make it a `public` property ,

deployment/kubernetes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Before running your application for the first time, be sure to create the databa
8383

8484
## Tiller RBAC Issue
8585

86-
We noticed that some tiller RBAC trouble occured, you generally can resolve it running:
86+
We noticed that some tiller RBAC trouble occurred, you generally can resolve it running:
8787

8888
kubectl create serviceaccount --namespace kube-system tiller
8989
serviceaccount "tiller" created

distribution/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
> - Fabien Potencier (creator of Symfony), SymfonyCon 2017
77
88
[API Platform](https://api-platform.com) is a powerful but easy to use **full stack** framework dedicated to API-driven projects.
9-
It contains a **PHP** library to create fully-featured APIs supporting industry-leading standards (JSON-LD, GraphQL, OpenAPI...),
9+
It contains a **PHP** library to create fully featured APIs supporting industry-leading standards (JSON-LD, GraphQL, OpenAPI...),
1010
provides ambitious **JavaScript** tooling to consume those APIs in a snap (admin, PWA and mobile apps generators, hypermedia
1111
client...) and is shipped with a nice **Docker** and **Kubernetes** integration to develop and deploy instantly in the cloud.
1212

@@ -510,7 +510,7 @@ Now try to add another book by issuing a `POST` request to `/books` with the fol
510510
}
511511
```
512512

513-
Oops, we missed to add the title. But submit the request anyway. You should get a 500 error with the following message:
513+
Oops, we missed to add the title. Submit the request anyway, you should get a 500 error with the following message:
514514

515515
An exception occurred while executing 'INSERT INTO book [...] VALUES [...]' with params [...]:
516516
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null

0 commit comments

Comments
 (0)