You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: admin/getting-started.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Installation
4
4
5
-
Install the skeleton and the library:
5
+
You'll need to install the skeleton and the library.
6
6
7
7
Start by installing [the Yarn package manager](https://yarnpkg.com/) ([NPM](https://www.npmjs.com/) is also supported) and
8
8
the [Create React App](https://facebook.github.io/create-react-app/) tool.
@@ -21,7 +21,7 @@ Finally, install the `@api-platform/admin` library:
21
21
22
22
## Creating the Admin
23
23
24
-
Edit the `src/App.js` file like the following:
24
+
Edit the `src/App.js` file the following way:
25
25
26
26
```javascript
27
27
importReactfrom'react';
@@ -62,11 +62,11 @@ Note: if you don't want to hardcode the API URL, you can [use an environment var
62
62
63
63
## Customizing the Admin
64
64
65
-
The API Platform's admin parses the Hydra documentation exposed by the API and transforms it to an object data structure. This data structure can be customized to add, remove or customize resources and properties. To do so, we can leverage the `AdminBuilder` component provided by the library. It's a lower level component than the `HydraAdmin` one we used in the previous example. It allows to access to the object storing the structure of admin's screens.
65
+
The API Platform's admin parses the Hydra documentation exposed by the API and transforms it to an object data structure. This data structure can be tailored to add, remove or customize resources and properties. To do so, we can leverage the `AdminBuilder` component provided by the library. It's a lower level component than the `HydraAdmin` one we used in the previous example. It allows to access the object storing the structure of admin's screens.
66
66
67
67
### Using Custom Components
68
68
69
-
In the following example, we change components used for the `description` property of the `books` resource to ones accepting HTML (respectively `RichTextField` that renders HTML markup and `RichTextInput`, a WYSWYG editor).
69
+
In the following example, we change components used for the `description` property of the `books` resource to ones accepting HTML (respectively `RichTextField` that renders HTML markup and `RichTextInput`, a WYSIWYG editor).
70
70
(To use the `RichTextInput`, the `ra-input-rich-text` package is must be installed: `yarn add ra-input-rich-text`).
The `field` property of the `Field` class allows to set the component used to render a property in list and show screens.
107
-
The `input` property allows to set the component to use to render the input used in create and edit screens.
107
+
The `input` property allows to set the component used to render the input used in create and edit screens.
108
108
109
109
Any [field](https://marmelab.com/react-admin/Fields.html) or [input](https://marmelab.com/react-admin/Inputs.html) provided by the React Admin library can be used.
110
110
@@ -113,7 +113,7 @@ To go further, take a look to the "[Including react-admin on another React app](
113
113
### Managing Files and Images
114
114
115
115
In the following example, we will:
116
-
* find every [ImageObject](http://schema.org/ImageObject) resources. For each [contentUrl](http://schema.org/contentUrl) fields, we will use [ImageField](https://marmelab.com/react-admin/Fields.html#imagefield) as `field` and [ImageInput](https://marmelab.com/react-admin/Inputs.html#imageinput) as `input`.
116
+
* find every [ImageObject](http://schema.org/ImageObject) resource. For each [contentUrl](http://schema.org/contentUrl) field, we will use [ImageField](https://marmelab.com/react-admin/Fields.html#imagefield) as `field` and [ImageInput](https://marmelab.com/react-admin/Inputs.html#imageinput) as `input`.
117
117
* [ImageInput](https://marmelab.com/react-admin/Inputs.html#imageinput) will return a [File](https://developer.mozilla.org/en/docs/Web/API/File) instance. In this example, we will send a multi-part form data to a special action (`https://demo.api-platform.com/images/upload`). The action will return the ID of the uploaded image. We will "replace" the [File](https://developer.mozilla.org/en/docs/Web/API/File) instance by the ID in `normalizeData`.
118
118
* As `contentUrl` fields will return a string, we have to convert Hydra data to React Admin data. This action will be done by `denormalizeData`.
119
119
@@ -227,9 +227,9 @@ export default class extends Component {
227
227
228
228
### Using the Hydra Data Provider Directly with react-admin
229
229
230
-
By default, the `HydraAdmin` component shipped with API Platform Admin will generate a convenient admin interface for every resources and every properties exposed by the API. But sometimes, you may prefer having full control over the generated admin.
230
+
By default, the `HydraAdmin` component shipped with API Platform Admin will generate a convenient admin interface for every resource and every property exposed by the API. But sometimes, you may prefer having full control over the generated admin.
231
231
232
-
To do so, an alternative approach is [to configure every react-admin components manually](https://marmelab.com/react-admin/Tutorial.html) instead of letting the library generating it, but to still leverage the built-in Hydra [data provider](https://marmelab.com/react-admin/DataProviders.html):
232
+
To do so, an alternative approach is [to configure every react-admin component manually](https://marmelab.com/react-admin/Tutorial.html) instead of letting the library generate them, but to still leverage the built-in Hydra [data provider](https://marmelab.com/react-admin/DataProviders.html):
Copy file name to clipboardExpand all lines: admin/index.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,13 @@ You can also customize all screens by using React Admin components and even raw
17
17
18
18
## Features
19
19
20
-
* Automatically generate an admin interface for all the resources of the API thanks to hypermedia features of Hydra
21
-
*Generate list, create, show, edit screens as well as a delete button
22
-
*Generate suitable inputs and fields according to the API doc (e.g. number HTML input for numbers, checkbox for booleans, selectbox for relationships...)
23
-
*Generate suitable inputs and fields according to Schema.org types if available (e.g. email field for http://schema.org/email)
24
-
*Handle relationships
25
-
*Pagination support
26
-
* Automatically validate if a field is mandatory client-side according to the API description
27
-
*Send proper HTTP requests to the API and decode them using Hydra and JSON-LD formats
* Automatically generates an admin interface for all the resources of the API thanks to hypermedia features of Hydra
21
+
*Generates 'list', 'create', 'show', and 'edit' screens, as well as a delete button
22
+
*Generates suitable inputs and fields according to the API doc (e.g. number HTML input for numbers, checkbox for booleans, selectbox for relationships...)
23
+
*Generates suitable inputs and fields according to Schema.org types if available (e.g. email field for http://schema.org/email)
24
+
*Handles relationships
25
+
*Supports pagination
26
+
* Automatically validates whether a field is mandatory client-side according to the API description
27
+
*Sends proper HTTP requests to the API and decodes them using Hydra and JSON-LD formats
Copy file name to clipboardExpand all lines: core/content-negotiation.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ By default, only the [JSON-LD](https://json-ld.org) format is enabled. However A
7
7
8
8
The framework natively supports JSON-LD, GraphQL, JSONAPI, HAL, raw JSON, XML, YAML and CSV (YAML and CSV support is only available if you use Symfony 3.2+).
9
9
10
-
Both XML and JSON formats are experimental and there are no assurance that we will not break them.
10
+
Both XML and JSON formats are experimental and there is no assurance that we will not break them.
11
11
12
12
API Platform Core will automatically detect the best resolving format depending on:
13
13
@@ -28,7 +28,7 @@ Format | Format name |
28
28
[CSV](https://tools.ietf.org/html/rfc4180) | `csv` | `text/csv` | no
29
29
[HTML](https://whatwg.org/) (API docs) | `html` | `text/html` | no
30
30
31
-
If the client requested format is not specified (if it's not supported, it will throw an HTTP bad request error), the response format will be the first format defined in the `formats` configuration key (see below).
31
+
If the client's requested format is not specified (if it's not supported, it will throw an HTTP bad request error), the response format will be the first format defined in the `formats` configuration key (see below).
32
32
An example using the built-in XML support is available in [Behat specs](https://github.com/api-platform/core/blob/master/features/main/content_negotiation.feature).
33
33
34
34
The API Platform content negotiation system is extendable. Support for other formats can be added by [creating and registering appropriate encoders and, sometimes, normalizers](https://symfony.com/doc/current/serializer.html#adding-normalizers-and-encoders). Adding support for other
@@ -83,8 +83,8 @@ class Book
83
83
}
84
84
```
85
85
86
-
In the example above, `xml` or `jsonld` will be allowed and there is no need to specify the mime types as they are already defined in the configuration.
87
-
Additionally the `csv` format is added with the mime type `text/csv`.
86
+
In the example above, `xml` or `jsonld` will be allowed and there is no need to specify the MIME types as they are already defined in the configuration.
87
+
Additionally the `csv` format is added with the MIME type `text/csv`.
88
88
89
89
It is also important to notice that the usage of this attribute will override the formats defined in the configuration, therefore
90
90
this configuration might disable the `json` or the `html` on this resource for example.
@@ -151,17 +151,17 @@ resources:
151
151
152
152
## Registering a Custom Serializer
153
153
154
-
If you are adding support for a format not supported by default by API Platform nor by the Symfony Serializer Component,
155
-
you need to create custom encoder, decoder and eventually a normalizer and a denormalizer. Refer to the
154
+
If you are adding support for a format supported by default neither by API Platform nor by the Symfony Serializer Component,
155
+
you need to create a custom encoder, decoder and eventually a normalizer and a denormalizer. Refer to the
156
156
Symfony documentation to learn [how to create and register such classes](https://symfony.com/doc/current/cookbook/serializer.html#adding-normalizers-and-encoders).
157
157
158
158
API Platform Core will automatically call the serializer with your defined format name (`myformat` in previous examples)
159
-
as `format` parameter during the deserialization process. Then it will return the result to the client with the asked MIME
159
+
as `format` parameter during the deserialization process. It will then return the result to the client with the requested MIME
160
160
type using its built-in responder.
161
161
162
162
## Writing a Custom Normalizer
163
163
164
-
Using composition is the recommended way to implement a custom normalizer. You can use the following template to start with your
164
+
Using composition is the recommended way to implement a custom normalizer. You can use the following template to start your
165
165
own implementation of `CustomItemNormalizer`:
166
166
167
167
```yaml
@@ -220,7 +220,7 @@ final class CustomItemNormalizer implements NormalizerInterface, DenormalizerInt
220
220
```
221
221
222
222
For example if you want to make the `csv` format work for even complex entities with a lot of hierarchy, you have to
0 commit comments