Skip to content

Commit 8a11162

Browse files
committedMay 2, 2019
add a movies collection with the ability to create a new movie
1 parent 04f7717 commit 8a11162

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed
 

‎movies/src/resources/context.jsonld

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"@context": {
3+
"mov": "https://hydra-movies.herokuapp.com/doc#",
34
"hydra": "http://www.w3.org/ns/hydra/core#",
5+
"hydra:expects": {
6+
"@type": "@vocab"
7+
},
8+
"hydra:returns": {
9+
"@type": "@vocab"
10+
},
11+
"hydra:property": {
12+
"@type": "@vocab"
13+
},
414
"schema": "http://schema.org/"
515
}
6-
}
16+
}

‎movies/src/resources/doc.jsonld

+40-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,48 @@
66
"hydra:description": "This API shows how a basic CRUD (Create, Read, Update, Delete) API can be designed using Hydra Core Vocabulary.",
77
"hydra:entrypoint": "/",
88
"hydra:supportedClass": [
9+
{
10+
"@id": "schema:EntryPoint",
11+
"@type": "hydra:Class",
12+
"hydra:title": "API entrypoint",
13+
"hydra:supportedProperty": [
14+
{
15+
"hydra:property": "hydra:collection",
16+
"hydra:title": "Collections",
17+
"hydra:description": "Collections provided by this API"
18+
}
19+
]
20+
},
21+
{
22+
"@id": "mov:MovieCollection",
23+
"@type": "hydra:Class",
24+
"hydra:title": "All movies",
25+
"hydra:supportedOperation": {
26+
"@id": "mov:create-movie",
27+
"@type": "schema:CreateAction",
28+
"hydra:title": "Create a new movie",
29+
"hydra:method": "POST",
30+
"hydra:expects": "schema:Movie",
31+
"hydra:returns": "schema:Movie",
32+
"hydra:statusCodes": [
33+
{
34+
"hydra:code": 201,
35+
"hydra:description": "If the movie was created successfully."
36+
}
37+
]
38+
}
39+
},
940
{
1041
"@id": "schema:Movie",
1142
"@type": "hydra:Class",
12-
"hydra:title": "A movie"
43+
"hydra:title": "Movie",
44+
"hydra:supportedProperty": [
45+
{
46+
"hydra:property": "schema:name",
47+
"hydra:title": "name",
48+
"hydra:description": "The movie's name"
49+
}
50+
]
1351
}
1452
]
15-
}
53+
}

‎movies/src/resources/index.jsonld

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"@context": "/context.jsonld",
33
"@id": "/",
4-
"@type": "hydra:Entrypoint"
5-
}
4+
"@type": "schema:EntryPoint",
5+
"hydra:collection": {
6+
"@id": "movies",
7+
"@type": [
8+
"hydra:Collection",
9+
"mov:MovieCollection"
10+
]
11+
}
12+
}

0 commit comments

Comments
 (0)
Please sign in to comment.