Skip to content

Commit 44f76b9

Browse files
authored
Merge pull request #331 from dunglas/improvements
Various docs improvements
2 parents ecb8885 + 617d290 commit 44f76b9

33 files changed

+734
-834
lines changed

admin/authentication-support.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ const fetchWithAuth = (url, options = {}) => {
7373

7474
const restClient = (api) => (hydraClient(api, fetchWithAuth));
7575

76-
class Admin extends Component {
76+
export default class extends Component {
7777
render() {
78-
return <HydraAdmin entrypoint={entrypoint} restClient={restClient} authClient={authClient}/>
78+
return <HydraAdmin entrypoint={entrypoint} restClient={restClient} authClient={authClient}/>;
7979
}
8080
}
81-
82-
export default Admin;
8381
```
8482

8583
Refer to [the chapter dedicated to authentication in the Admin On Rest documentation](https://marmelab.com/admin-on-rest/Authentication.html)

admin/getting-started.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ import parseHydraDocumentation from 'api-doc-parser/lib/hydra/parseHydraDocument
168168

169169
const entrypoint = 'https://demo.api-platform.com';
170170

171-
class App extends Component {
171+
export default class extends Component {
172172
state = {api: null};
173173

174174
componentDidMount() {
@@ -189,8 +189,6 @@ class App extends Component {
189189
return <AdminBuilder api={this.state.api} restClient={hydraClient(entrypoint)}/>
190190
}
191191
}
192-
193-
export default App;
194192
```
195193

196194
Previous chapter: [Introduction](index.md)

admin/handling-relations-to-collections.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This API can be created using the following PHP code:
1212

1313
```php
1414
<?php
15+
// src/AppBundle/Entity/Person.php
1516

1617
namespace App\Entity;
1718

@@ -40,6 +41,7 @@ class Person
4041

4142
```php
4243
<?php
44+
// src/AppBundle/Entity/Book.php
4345

4446
namespace App\Entity;
4547

@@ -128,7 +130,6 @@ Start by adding a "partial search" filter on the `name` property of the `Book` r
128130

129131
```yaml
130132
# config/api_filters.yml
131-
132133
services:
133134
person.search_filter:
134135
parent: 'api_platform.doctrine.orm.search_filter'

client-generator/react.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Bootstrap 4 - from release 0.1.16
3636
<!-- ... -->
3737
```
3838

39-
4039
In the app directory, generate the files for the resource you want:
4140

4241
$ generate-api-platform-client https://demo.api-platform.com src/ --resource foo

client-generator/troubleshooting.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* The generator does not perform any authentication, so you must ensure that all referenced Hydra paths for your API are
44
accessible anonymously. If you are using API Platform this will at least include:
55

6-
```
7-
api_entrypoint ANY ANY ANY /{index}.{_format}
8-
api_doc ANY ANY ANY /docs.{_format}
9-
api_jsonld_context ANY ANY ANY /contexts/{shortName}.{_format}
10-
```
6+
```
7+
api_entrypoint ANY ANY ANY /{index}.{_format}
8+
api_doc ANY ANY ANY /docs.{_format}
9+
api_jsonld_context ANY ANY ANY /contexts/{shortName}.{_format}
10+
```
1111

1212
* If you receive `Error: The class http://www.w3.org/ns/hydra/core#ApiDocumentation doesn't exist.` you may have
1313
specified the documentation URL instead of the entrypoint. For example if you are using API Platform and your
@@ -22,22 +22,22 @@ you are using by running something like `curl https://demo.api-platform.com/`.
2222

2323
* If you receive a message like this:
2424

25-
```
26-
{ Error
27-
at done (/usr/local/share/.config/yarn/global/node_modules/jsonld/js/jsonld.js:6851:19)
28-
at <anonymous>
29-
at process._tickCallback (internal/process/next_tick.js:188:7)
30-
name: 'jsonld.InvalidUrl',
31-
message: 'Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.',
32-
details:
33-
{ code: 'invalid remote context',
34-
url: 'https://demo.api-platform.com/contexts/Entrypoint',
35-
cause: null } }
36-
```
37-
38-
Check access to the specified url, in this case `https://demo.api-platform.com/contexts/Entrypoint`, use curl to check
39-
access and the response `curl https://demo.api-platform.com/contexts/Entrypoint`. In the above case an "Access Denied"
40-
message in JSON format was being returned.
25+
```
26+
{ Error
27+
at done (/usr/local/share/.config/yarn/global/node_modules/jsonld/js/jsonld.js:6851:19)
28+
at <anonymous>
29+
at process._tickCallback (internal/process/next_tick.js:188:7)
30+
name: 'jsonld.InvalidUrl',
31+
message: 'Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.',
32+
details:
33+
{ code: 'invalid remote context',
34+
url: 'https://demo.api-platform.com/contexts/Entrypoint',
35+
cause: null } }
36+
```
37+
38+
Check access to the specified url, in this case `https://demo.api-platform.com/contexts/Entrypoint`, use curl to check
39+
access and the response `curl https://demo.api-platform.com/contexts/Entrypoint`. In the above case an "Access Denied"
40+
message in JSON format was being returned.
4141

4242
Previous chapter: [Vue.js generator](vuejs.md)
4343

core/angularjs-integration.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# AngularJS integration
1+
# AngularJS Integration
2+
3+
Warning: For new project, you should consider using [the API Platform's Progressive Web App generator](../client-generator/index.md)
4+
(that supports React and Vue.js) instead of this Angular v1 integration.
25

36
## Restangular
47

5-
ApiPlatformBundle works fine with [AngularJS v1](http://angularjs.org). The popular [Restangular](https://github.com/mgonto/restangular)
8+
API Platform works fine with [AngularJS v1](http://angularjs.org). The popular [Restangular](https://github.com/mgonto/restangular)
69
REST client library for Angular can easily be configured to handle the API format.
710

811
Here is a working Restangular config:
@@ -98,4 +101,4 @@ You can look at what we have done as another exemple [api-platform/admin](https:
98101

99102
Previous chapter: [NelmioApiDocBundle integration](nelmio-api-doc.md)
100103

101-
Next chapter: [Swagger Support](swagger.md)
104+
Next chapter: [Schema Generator: Introduction](../schema-generator/index.md)

core/configuration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Here's the complete configuration of the Symfony bundle with including default v
44

55
```yaml
66
# app/config/config.yml
7-
87
api_platform:
98

109
# The title of the API.

core/content-negotiation.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ and of a custom format called `myformat` and having `application/vnd.myformat` a
4242

4343
```yaml
4444
# app/config/config.yml
45-
4645
api_platform:
47-
4846
# ...
4947

5048
formats:
@@ -79,9 +77,7 @@ own implementation of `CustomItemNormalizer`:
7977

8078
```yaml
8179
# app/config/services.yml
82-
8380
services:
84-
8581
# ...
8682
8783
'AppBundle\Serializer\CustomItemNormalizer':
@@ -91,7 +87,6 @@ services:
9187

9288
```php
9389
<?php
94-
9590
// src/AppBundle/Serializer/CustomItemNormalizer.php
9691
9792
namespace AppBundle\Serializer;
@@ -139,7 +134,6 @@ flatten or remove too complex relations:
139134

140135
```php
141136
<?php
142-
143137
// src/AppBundle/Serializer/CustomItemNormalizer.php
144138
145139
namespace AppBundle\Serializer;
@@ -172,6 +166,6 @@ class CustomItemNormalizer implements NormalizerInterface, DenormalizerInterface
172166
}
173167
```
174168

175-
Previous chapter: [The Event System](events.md)
169+
Previous chapter: [The Serialization Process](core/serialization.md)
176170

177-
Next chapter: [Using External JSON-LD Vocabularies](external-vocabularies.md)
171+
Next chapter: [Validation](core/validation.md)

core/data-providers.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For a given resource, you can implement two kind of interfaces:
1818
is used when fetching items.
1919

2020
In the following examples we will create custom data providers for an entity class called `AppBundle\Entity\BlogPost`.
21-
Note, that if your entity is not Doctrine-related, you need to flag the identifier property by using `@ApiProperty(identifier=true)` for things to work properly (see also [Entity Identifier Case](serialization-groups-and-relations.md#entity-identifier-case)).
21+
Note, that if your entity is not Doctrine-related, you need to flag the identifier property by using `@ApiProperty(identifier=true)` for things to work properly (see also [Entity Identifier Case](serialization.md#entity-identifier-case)).
2222

2323
## Custom Collection Data Provider
2424

@@ -29,7 +29,6 @@ If no data is available, you should return an empty array.
2929

3030
```php
3131
<?php
32-
3332
// src/AppBundle/DataProvider/BlogPostCollectionDataProvider.php
3433

3534
namespace AppBundle\DataProvider;
@@ -79,7 +78,6 @@ The `getItem` method can return `null` if no result has been found.
7978

8079
```php
8180
<?php
82-
8381
// src/AppBundle/DataProvider/BlogPostItemDataProvider.php
8482
8583
namespace AppBundle\DataProvider;
@@ -118,6 +116,6 @@ services:
118116
tags: [ 'api_platform.item_data_provider' ]
119117
```
120118

121-
Previous chapter: [Extending JSON-LD context](extending-jsonld-context.md)
119+
Previous chapter: [The Event System](core/events.md)
122120

123-
Next chapter: [Extensions](extensions.md)
121+
Next chapter: [Extensions](core/extensions.md)

core/default-order.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ customize this order, you must add an `order` attribute on your ApiResource anno
77

88
```php
99
<?php
10-
1110
// src/AppBundle/Entity/Book.php
1211

1312
namespace AppBundle\Entity;
@@ -33,7 +32,6 @@ If you only specify the key, `ASC` direction will be used as default. For exampl
3332

3433
```php
3534
<?php
36-
3735
// src/AppBundle/Entity/Book.php
3836

3937
namespace AppBundle\Entity;
@@ -61,8 +59,8 @@ class Book
6159

6260
It's also possible to configure the default filter on an association property:
6361

62+
```php
6463
<?php
65-
6664
// src/AppBundle/Entity/Book.php
6765

6866
namespace AppBundle\Entity;
@@ -81,6 +79,7 @@ class Book
8179
*/
8280
public $author;
8381
}
82+
```
8483

8584
Previous chapter: [Operations](operations.md)
8685

core/events.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ In the following example, we will send a mail each time a new book is created us
1616

1717
```php
1818
<?php
19-
2019
// src/AppBundle/EventSubscriber/BookMailSubscriber.php
2120

2221
namespace AppBundle\EventSubscriber;
@@ -108,4 +107,4 @@ Constant | Event | Priority |
108107

109108
Previous chapter: [Pagination](pagination.md)
110109

111-
Next chapter: [Content Negotiation](content-negotiation.md)
110+
Next chapter: [Data Providers](core/data-providers.md)

core/extending-jsonld-context.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ within the following annotation, will be passed to the context, that provides a
66

77
```php
88
<?php
9-
109
// src/AppBundle/Entity/Book.php
1110

1211
namespace AppBundle\Entity;
@@ -64,6 +63,6 @@ The generated context will now have your custom attributes set:
6463

6564
Note that you do not have to provide the `@id` attribute, if you do not provide an `@id` attribute, the value from `iri` will be taken.
6665

67-
Previous chapter: [Using External JSON-LD Vocabularies](external-vocabularies.md)
66+
Previous chapter: [Using External Vocabularies](external-vocabularies.md)
6867

69-
Next chapter: [Data Providers](data-providers.md)
68+
Next chapter: [FOSUserBundle Integration](core/fosuser-bundle.md)

core/extensions.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ Finally register the custom extension:
120120

121121
```yaml
122122
# app/config/services.yml
123-
124123
services:
125124

126125
# ...
@@ -143,19 +142,16 @@ To secure the access to endpoints, use the following access control rule:
143142

144143
```yaml
145144
# app/config/security.yml
146-
147145
security:
148-
149146
# ...
150147
151148
access_control:
152-
153149
# ...
154150
155151
- { path: ^/offers, roles: IS_AUTHENTICATED_FULLY }
156152
- { path: ^/users, roles: IS_AUTHENTICATED_FULLY }
157153
```
158154

159-
Previous chapter: [Data Providers](data-providers.md)
155+
Previous chapter: [Extensions](core/extensions.md)
160156

161-
Next chapter: [Security](security.md)
157+
Next chapter: [Security](core/security.md)

core/external-vocabularies.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Using External JSON-LD Vocabularies
1+
# Using External Vocabularies
22

33
JSON-LD allows to define classes and properties of your API with open vocabularies such as [Schema.org](https://schema.org)
44
and [Good Relations](http://www.heppnetz.de/projects/goodrelations/).
@@ -7,7 +7,6 @@ API Platform Core provides annotations usable on PHP classes and properties for
77

88
```php
99
<?php
10-
1110
// src/AppBundle/Entity/Book.php
1211

1312
namespace AppBundle\Entity;

0 commit comments

Comments
 (0)