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: core/extending-jsonld-context.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,14 @@
5
5
<palign="center"class="symfonycasts"><ahref="https://symfonycasts.com/screencast/api-platform/json-ld?cid=apip"><imgsrc="../symfony/images/symfonycasts-player.png"alt="JSON-LD screencast"><br>Watch the JSON-LD screencast</a></p>
6
6
7
7
API Platform provides the possibility to extend the JSON-LD context of properties. This allows you to describe JSON-LD-typed
8
-
values, inverse properties using the `@reverse` keyword and you can even overwrite the `@id` property this way. Everything you define
9
-
within the following annotation will be passed to the context. This provides a generic way to extend the context.
8
+
values, inverse properties using the `@reverse` keyword, and you can even overwrite the `@id` property this way.
9
+
Everything you define within the following annotation will be passed to the context. This provides a generic way to
10
+
extend the context.
10
11
11
12
```php
12
13
<?php
13
-
// api/src/Entity/Book.php
14
-
namespace App\Entity;
14
+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
15
+
namespace App\ApiResource;
15
16
16
17
use ApiPlatform\Metadata\ApiProperty;
17
18
use ApiPlatform\Metadata\ApiResource;
@@ -71,8 +72,8 @@ It's also possible to replace the Hydra context used by the documentation genera
71
72
72
73
```php
73
74
<?php
74
-
// api/src/Entity/Book.php
75
-
namespace App\Entity;
75
+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
76
+
namespace App\ApiResource;
76
77
77
78
use ApiPlatform\Metadata\ApiResource;
78
79
use ApiPlatform\Metadata\Get;
@@ -88,8 +89,9 @@ class Book
88
89
89
90
```yaml
90
91
# api/config/api_platform/resources.yaml
92
+
# The YAML syntax is only supported for Symfony
91
93
resources:
92
-
App\Entity\Book:
94
+
App\ApiResource\Book:
93
95
operations:
94
96
ApiPlatform\Metadata\Get:
95
97
hydraContext: { foo: 'bar' }
@@ -98,12 +100,13 @@ resources:
98
100
```xml
99
101
<?xml version="1.0" encoding="UTF-8" ?>
100
102
<!-- api/config/api_platform/resources.xml -->
103
+
<!-- The XML syntax is only supported for Symfony -->
0 commit comments