forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnon_resource.feature
More file actions
126 lines (122 loc) · 3.69 KB
/
Copy pathnon_resource.feature
File metadata and controls
126 lines (122 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Feature: JSON API non-resource handling
In order to use non-resource types
As a developer
I should be able to serialize types not mapped to an API resource.
Background:
Given I add "Accept" header equal to "application/vnd.api+json"
And I add "Content-Type" header equal to "application/vnd.api+json"
Scenario: Get a resource containing a raw object
When I send a "GET" request to "/contain_non_resources/1?include=nested"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/vnd.api+json; charset=utf-8"
And the JSON should be valid according to the JSON API schema
And the JSON should be a superset of:
"""
{
"data": {
"id": "/contain_non_resources/1",
"type": "ContainNonResource",
"attributes": {
"_id": 1,
"notAResource": {
"foo": "f1",
"bar": "b1"
}
},
"relationships": {
"nested": {
"data": {
"id": "/contain_non_resources/1-nested",
"type": "ContainNonResource"
}
}
}
},
"included": [
{
"id": "/contain_non_resources/1-nested",
"type": "ContainNonResource",
"attributes": {
"_id": "1-nested",
"notAResource": {
"foo": "f2",
"bar": "b2"
}
}
}
]
}
"""
@!mongodb
@createSchema
Scenario: Create a resource that has a non-resource relation.
When I send a "POST" request to "/non_relation_resources" with body:
"""
{
"data": {
"type": "NonRelationResource",
"attributes": {
"relation": {
"foo": "test"
}
}
}
}
"""
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/vnd.api+json; charset=utf-8"
And the JSON should be valid according to the JSON API schema
And the JSON should be a superset of:
"""
{
"data": {
"id": "/non_relation_resources/1",
"type": "NonRelationResource",
"attributes": {
"_id": 1,
"relation": {
"foo": "test"
}
}
}
}
"""
@!mongodb
@createSchema
Scenario: Create a resource that contains a stdClass object.
When I send a "POST" request to "/plain_object_dummies" with body:
"""
{
"data": {
"type": "PlainObjectDummy",
"attributes": {
"content":"{\"fields\":{\"title\":{\"value\":\"\"},\"images\":[{\"id\":0,\"categoryId\":0,\"uri\":\"/api/pictures\",\"resource\":\"{}\",\"description\":\"\",\"alt\":\"\",\"type\":\"picture\",\"text\":\"\",\"src\":\"\"}],\"alternativeAudio\":{},\"caption\":\"\"},\"showCaption\":false,\"alternativeContent\":false,\"alternativeAudioContent\":false,\"blockLayout\":\"default\"}"
}
}
}
"""
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/vnd.api+json; charset=utf-8"
And the JSON should be valid according to the JSON API schema
And the JSON should be a superset of:
"""
{
"data": {
"id": "/plain_object_dummies/1",
"type": "PlainObjectDummy",
"attributes": {
"_id": 1,
"data": {
"fields": [],
"showCaption": false,
"alternativeContent": false,
"alternativeAudioContent": false,
"blockLayout": "default"
}
}
}
}
"""