active_model_serializers 0.10.9 → 0.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -2
- data/README.md +18 -19
- data/lib/action_controller/serialization.rb +9 -1
- data/lib/active_model/serializer/collection_serializer.rb +11 -2
- data/lib/active_model/serializer/concerns/caching.rb +2 -1
- data/lib/active_model/serializer/fieldset.rb +1 -1
- data/lib/active_model/serializer/reflection.rb +4 -4
- data/lib/active_model/serializer/version.rb +1 -1
- data/lib/active_model/serializer.rb +13 -4
- data/lib/active_model_serializers/adapter/attributes.rb +21 -0
- data/lib/active_model_serializers/adapter/json_api/pagination_links.rb +5 -1
- data/lib/active_model_serializers/adapter/json_api/resource_identifier.rb +1 -1
- data/lib/active_model_serializers/model/caching.rb +26 -0
- metadata +20 -292
- data/.github/ISSUE_TEMPLATE.md +0 -29
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -15
- data/.gitignore +0 -35
- data/.rubocop.yml +0 -109
- data/.simplecov +0 -110
- data/.travis.yml +0 -63
- data/CODE_OF_CONDUCT.md +0 -74
- data/CONTRIBUTING.md +0 -105
- data/Gemfile +0 -74
- data/Rakefile +0 -76
- data/active_model_serializers.gemspec +0 -64
- data/appveyor.yml +0 -28
- data/bin/bench +0 -171
- data/bin/bench_regression +0 -316
- data/bin/rubocop +0 -38
- data/bin/serve_benchmark +0 -39
- data/docs/README.md +0 -41
- data/docs/STYLE.md +0 -58
- data/docs/general/adapters.md +0 -269
- data/docs/general/caching.md +0 -58
- data/docs/general/configuration_options.md +0 -185
- data/docs/general/deserialization.md +0 -100
- data/docs/general/fields.md +0 -31
- data/docs/general/getting_started.md +0 -133
- data/docs/general/instrumentation.md +0 -40
- data/docs/general/key_transforms.md +0 -40
- data/docs/general/logging.md +0 -21
- data/docs/general/rendering.md +0 -293
- data/docs/general/serializers.md +0 -495
- data/docs/how-open-source-maintained.jpg +0 -0
- data/docs/howto/add_pagination_links.md +0 -138
- data/docs/howto/add_relationship_links.md +0 -140
- data/docs/howto/add_root_key.md +0 -62
- data/docs/howto/grape_integration.md +0 -42
- data/docs/howto/outside_controller_use.md +0 -66
- data/docs/howto/passing_arbitrary_options.md +0 -27
- data/docs/howto/serialize_poro.md +0 -73
- data/docs/howto/test.md +0 -154
- data/docs/howto/upgrade_from_0_8_to_0_10.md +0 -265
- data/docs/integrations/ember-and-json-api.md +0 -147
- data/docs/integrations/grape.md +0 -19
- data/docs/jsonapi/errors.md +0 -56
- data/docs/jsonapi/schema/schema.json +0 -366
- data/docs/jsonapi/schema.md +0 -151
- data/docs/rfcs/0000-namespace.md +0 -106
- data/docs/rfcs/template.md +0 -15
- data/test/action_controller/adapter_selector_test.rb +0 -64
- data/test/action_controller/explicit_serializer_test.rb +0 -137
- data/test/action_controller/json/include_test.rb +0 -248
- data/test/action_controller/json_api/deserialization_test.rb +0 -114
- data/test/action_controller/json_api/errors_test.rb +0 -42
- data/test/action_controller/json_api/fields_test.rb +0 -68
- data/test/action_controller/json_api/linked_test.rb +0 -204
- data/test/action_controller/json_api/pagination_test.rb +0 -126
- data/test/action_controller/json_api/transform_test.rb +0 -191
- data/test/action_controller/lookup_proc_test.rb +0 -51
- data/test/action_controller/namespace_lookup_test.rb +0 -234
- data/test/action_controller/serialization_scope_name_test.rb +0 -237
- data/test/action_controller/serialization_test.rb +0 -480
- data/test/active_model_serializers/adapter_for_test.rb +0 -210
- data/test/active_model_serializers/json_pointer_test.rb +0 -24
- data/test/active_model_serializers/logging_test.rb +0 -79
- data/test/active_model_serializers/model_test.rb +0 -144
- data/test/active_model_serializers/railtie_test_isolated.rb +0 -70
- data/test/active_model_serializers/register_jsonapi_renderer_test_isolated.rb +0 -163
- data/test/active_model_serializers/serialization_context_test_isolated.rb +0 -73
- data/test/active_model_serializers/test/schema_test.rb +0 -133
- data/test/active_model_serializers/test/serializer_test.rb +0 -64
- data/test/active_record_test.rb +0 -11
- data/test/adapter/attributes_test.rb +0 -42
- data/test/adapter/deprecation_test.rb +0 -102
- data/test/adapter/json/belongs_to_test.rb +0 -47
- data/test/adapter/json/collection_test.rb +0 -106
- data/test/adapter/json/has_many_test.rb +0 -55
- data/test/adapter/json/transform_test.rb +0 -95
- data/test/adapter/json_api/belongs_to_test.rb +0 -157
- data/test/adapter/json_api/collection_test.rb +0 -98
- data/test/adapter/json_api/errors_test.rb +0 -78
- data/test/adapter/json_api/fields_test.rb +0 -98
- data/test/adapter/json_api/has_many_explicit_serializer_test.rb +0 -98
- data/test/adapter/json_api/has_many_test.rb +0 -175
- data/test/adapter/json_api/has_one_test.rb +0 -82
- data/test/adapter/json_api/include_data_if_sideloaded_test.rb +0 -215
- data/test/adapter/json_api/json_api_test.rb +0 -35
- data/test/adapter/json_api/linked_test.rb +0 -415
- data/test/adapter/json_api/links_test.rb +0 -112
- data/test/adapter/json_api/pagination_links_test.rb +0 -208
- data/test/adapter/json_api/parse_test.rb +0 -139
- data/test/adapter/json_api/relationship_test.rb +0 -399
- data/test/adapter/json_api/resource_meta_test.rb +0 -102
- data/test/adapter/json_api/toplevel_jsonapi_test.rb +0 -84
- data/test/adapter/json_api/transform_test.rb +0 -514
- data/test/adapter/json_api/type_test.rb +0 -195
- data/test/adapter/json_test.rb +0 -48
- data/test/adapter/null_test.rb +0 -24
- data/test/adapter/polymorphic_test.rb +0 -220
- data/test/adapter_test.rb +0 -69
- data/test/array_serializer_test.rb +0 -24
- data/test/benchmark/app.rb +0 -67
- data/test/benchmark/benchmarking_support.rb +0 -69
- data/test/benchmark/bm_active_record.rb +0 -83
- data/test/benchmark/bm_adapter.rb +0 -40
- data/test/benchmark/bm_caching.rb +0 -121
- data/test/benchmark/bm_lookup_chain.rb +0 -85
- data/test/benchmark/bm_transform.rb +0 -47
- data/test/benchmark/config.ru +0 -3
- data/test/benchmark/controllers.rb +0 -85
- data/test/benchmark/fixtures.rb +0 -221
- data/test/cache_test.rb +0 -717
- data/test/collection_serializer_test.rb +0 -129
- data/test/fixtures/active_record.rb +0 -115
- data/test/fixtures/poro.rb +0 -227
- data/test/generators/scaffold_controller_generator_test.rb +0 -26
- data/test/generators/serializer_generator_test.rb +0 -77
- data/test/grape_test.rb +0 -198
- data/test/lint_test.rb +0 -51
- data/test/logger_test.rb +0 -22
- data/test/poro_test.rb +0 -11
- data/test/serializable_resource_test.rb +0 -81
- data/test/serializers/association_macros_test.rb +0 -39
- data/test/serializers/associations_test.rb +0 -520
- data/test/serializers/attribute_test.rb +0 -155
- data/test/serializers/attributes_test.rb +0 -54
- data/test/serializers/caching_configuration_test_isolated.rb +0 -172
- data/test/serializers/configuration_test.rb +0 -34
- data/test/serializers/fieldset_test.rb +0 -16
- data/test/serializers/meta_test.rb +0 -204
- data/test/serializers/options_test.rb +0 -34
- data/test/serializers/read_attribute_for_serialization_test.rb +0 -81
- data/test/serializers/reflection_test.rb +0 -481
- data/test/serializers/root_test.rb +0 -23
- data/test/serializers/serialization_test.rb +0 -57
- data/test/serializers/serializer_for_test.rb +0 -138
- data/test/serializers/serializer_for_with_namespace_test.rb +0 -90
- data/test/support/custom_schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
- data/test/support/isolated_unit.rb +0 -86
- data/test/support/rails5_shims.rb +0 -55
- data/test/support/rails_app.rb +0 -40
- data/test/support/schemas/active_model_serializers/test/schema_test/my/index.json +0 -6
- data/test/support/schemas/active_model_serializers/test/schema_test/my/show.json +0 -6
- data/test/support/schemas/custom/show.json +0 -7
- data/test/support/schemas/hyper_schema.json +0 -93
- data/test/support/schemas/render_using_json_api.json +0 -43
- data/test/support/schemas/simple_json_pointers.json +0 -10
- data/test/support/serialization_testing.rb +0 -81
- data/test/test_helper.rb +0 -72
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
-
"title": "JSON API Schema",
|
|
4
|
-
"description": "This is a schema for responses in the JSON API format. For more, see http://jsonapi.org",
|
|
5
|
-
"oneOf": [
|
|
6
|
-
{
|
|
7
|
-
"$ref": "#/definitions/success"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"$ref": "#/definitions/failure"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"$ref": "#/definitions/info"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
|
|
17
|
-
"definitions": {
|
|
18
|
-
"success": {
|
|
19
|
-
"type": "object",
|
|
20
|
-
"required": [
|
|
21
|
-
"data"
|
|
22
|
-
],
|
|
23
|
-
"properties": {
|
|
24
|
-
"data": {
|
|
25
|
-
"$ref": "#/definitions/data"
|
|
26
|
-
},
|
|
27
|
-
"included": {
|
|
28
|
-
"description": "To reduce the number of HTTP requests, servers **MAY** allow responses that include related resources along with the requested primary resources. Such responses are called \"compound documents\".",
|
|
29
|
-
"type": "array",
|
|
30
|
-
"items": {
|
|
31
|
-
"$ref": "#/definitions/resource"
|
|
32
|
-
},
|
|
33
|
-
"uniqueItems": true
|
|
34
|
-
},
|
|
35
|
-
"meta": {
|
|
36
|
-
"$ref": "#/definitions/meta"
|
|
37
|
-
},
|
|
38
|
-
"links": {
|
|
39
|
-
"description": "Link members related to the primary data.",
|
|
40
|
-
"allOf": [
|
|
41
|
-
{
|
|
42
|
-
"$ref": "#/definitions/links"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"$ref": "#/definitions/pagination"
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"jsonapi": {
|
|
50
|
-
"$ref": "#/definitions/jsonapi"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"additionalProperties": false
|
|
54
|
-
},
|
|
55
|
-
"failure": {
|
|
56
|
-
"type": "object",
|
|
57
|
-
"required": [
|
|
58
|
-
"errors"
|
|
59
|
-
],
|
|
60
|
-
"properties": {
|
|
61
|
-
"errors": {
|
|
62
|
-
"type": "array",
|
|
63
|
-
"items": {
|
|
64
|
-
"$ref": "#/definitions/error"
|
|
65
|
-
},
|
|
66
|
-
"uniqueItems": true
|
|
67
|
-
},
|
|
68
|
-
"meta": {
|
|
69
|
-
"$ref": "#/definitions/meta"
|
|
70
|
-
},
|
|
71
|
-
"jsonapi": {
|
|
72
|
-
"$ref": "#/definitions/jsonapi"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"additionalProperties": false
|
|
76
|
-
},
|
|
77
|
-
"info": {
|
|
78
|
-
"type": "object",
|
|
79
|
-
"required": [
|
|
80
|
-
"meta"
|
|
81
|
-
],
|
|
82
|
-
"properties": {
|
|
83
|
-
"meta": {
|
|
84
|
-
"$ref": "#/definitions/meta"
|
|
85
|
-
},
|
|
86
|
-
"links": {
|
|
87
|
-
"$ref": "#/definitions/links"
|
|
88
|
-
},
|
|
89
|
-
"jsonapi": {
|
|
90
|
-
"$ref": "#/definitions/jsonapi"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"additionalProperties": false
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
"meta": {
|
|
97
|
-
"description": "Non-standard meta-information that can not be represented as an attribute or relationship.",
|
|
98
|
-
"type": "object",
|
|
99
|
-
"additionalProperties": true
|
|
100
|
-
},
|
|
101
|
-
"data": {
|
|
102
|
-
"description": "The document's \"primary data\" is a representation of the resource or collection of resources targeted by a request.",
|
|
103
|
-
"oneOf": [
|
|
104
|
-
{
|
|
105
|
-
"$ref": "#/definitions/resource"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"description": "An array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections.",
|
|
109
|
-
"type": "array",
|
|
110
|
-
"items": {
|
|
111
|
-
"$ref": "#/definitions/resource"
|
|
112
|
-
},
|
|
113
|
-
"uniqueItems": true
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
|
-
"resource": {
|
|
118
|
-
"description": "\"Resource objects\" appear in a JSON API document to represent resources.",
|
|
119
|
-
"type": "object",
|
|
120
|
-
"required": [
|
|
121
|
-
"type",
|
|
122
|
-
"id"
|
|
123
|
-
],
|
|
124
|
-
"properties": {
|
|
125
|
-
"type": {
|
|
126
|
-
"type": "string"
|
|
127
|
-
},
|
|
128
|
-
"id": {
|
|
129
|
-
"type": "string"
|
|
130
|
-
},
|
|
131
|
-
"attributes": {
|
|
132
|
-
"$ref": "#/definitions/attributes"
|
|
133
|
-
},
|
|
134
|
-
"relationships": {
|
|
135
|
-
"$ref": "#/definitions/relationships"
|
|
136
|
-
},
|
|
137
|
-
"links": {
|
|
138
|
-
"$ref": "#/definitions/links"
|
|
139
|
-
},
|
|
140
|
-
"meta": {
|
|
141
|
-
"$ref": "#/definitions/meta"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"additionalProperties": false
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
"links": {
|
|
148
|
-
"description": "A resource object **MAY** contain references to other resource objects (\"relationships\"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.",
|
|
149
|
-
"type": "object",
|
|
150
|
-
"properties": {
|
|
151
|
-
"self": {
|
|
152
|
-
"description": "A `self` member, whose value is a URL for the relationship itself (a \"relationship URL\"). This URL allows the client to directly manipulate the relationship. For example, it would allow a client to remove an `author` from an `article` without deleting the people resource itself.",
|
|
153
|
-
"type": "string",
|
|
154
|
-
"format": "uri"
|
|
155
|
-
},
|
|
156
|
-
"related": {
|
|
157
|
-
"$ref": "#/definitions/link"
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
"additionalProperties": true
|
|
161
|
-
},
|
|
162
|
-
"link": {
|
|
163
|
-
"description": "A link **MUST** be represented as either: a string containing the link's URL or a link object.",
|
|
164
|
-
"oneOf": [
|
|
165
|
-
{
|
|
166
|
-
"description": "A string containing the link's URL.",
|
|
167
|
-
"type": "string",
|
|
168
|
-
"format": "uri"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"type": "object",
|
|
172
|
-
"required": [
|
|
173
|
-
"href"
|
|
174
|
-
],
|
|
175
|
-
"properties": {
|
|
176
|
-
"href": {
|
|
177
|
-
"description": "A string containing the link's URL.",
|
|
178
|
-
"type": "string",
|
|
179
|
-
"format": "uri"
|
|
180
|
-
},
|
|
181
|
-
"meta": {
|
|
182
|
-
"$ref": "#/definitions/meta"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
]
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
"attributes": {
|
|
190
|
-
"description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.",
|
|
191
|
-
"type": "object",
|
|
192
|
-
"patternProperties": {
|
|
193
|
-
"^(?!relationships$|links$)\\w[-\\w_]*$": {
|
|
194
|
-
"description": "Attributes may contain any valid JSON value."
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
"additionalProperties": false
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
"relationships": {
|
|
201
|
-
"description": "Members of the relationships object (\"relationships\") represent references from the resource object in which it's defined to other resource objects.",
|
|
202
|
-
"type": "object",
|
|
203
|
-
"patternProperties": {
|
|
204
|
-
"^\\w[-\\w_]*$": {
|
|
205
|
-
"properties": {
|
|
206
|
-
"links": {
|
|
207
|
-
"$ref": "#/definitions/links"
|
|
208
|
-
},
|
|
209
|
-
"data": {
|
|
210
|
-
"description": "Member, whose value represents \"resource linkage\".",
|
|
211
|
-
"oneOf": [
|
|
212
|
-
{
|
|
213
|
-
"$ref": "#/definitions/relationshipToOne"
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
"$ref": "#/definitions/relationshipToMany"
|
|
217
|
-
}
|
|
218
|
-
]
|
|
219
|
-
},
|
|
220
|
-
"meta": {
|
|
221
|
-
"$ref": "#/definitions/meta"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
"additionalProperties": false
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
"additionalProperties": false
|
|
228
|
-
},
|
|
229
|
-
"relationshipToOne": {
|
|
230
|
-
"description": "References to other resource objects in a to-one (\"relationship\"). Relationships can be specified by including a member in a resource's links object.",
|
|
231
|
-
"anyOf": [
|
|
232
|
-
{
|
|
233
|
-
"$ref": "#/definitions/empty"
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"$ref": "#/definitions/linkage"
|
|
237
|
-
}
|
|
238
|
-
]
|
|
239
|
-
},
|
|
240
|
-
"relationshipToMany": {
|
|
241
|
-
"description": "An array of objects each containing \"type\" and \"id\" members for to-many relationships.",
|
|
242
|
-
"type": "array",
|
|
243
|
-
"items": {
|
|
244
|
-
"$ref": "#/definitions/linkage"
|
|
245
|
-
},
|
|
246
|
-
"uniqueItems": true
|
|
247
|
-
},
|
|
248
|
-
"empty": {
|
|
249
|
-
"description": "Describes an empty to-one relationship.",
|
|
250
|
-
"type": "null"
|
|
251
|
-
},
|
|
252
|
-
"linkage": {
|
|
253
|
-
"description": "The \"type\" and \"id\" to non-empty members.",
|
|
254
|
-
"type": "object",
|
|
255
|
-
"required": [
|
|
256
|
-
"type",
|
|
257
|
-
"id"
|
|
258
|
-
],
|
|
259
|
-
"properties": {
|
|
260
|
-
"type": {
|
|
261
|
-
"type": "string"
|
|
262
|
-
},
|
|
263
|
-
"id": {
|
|
264
|
-
"type": "string"
|
|
265
|
-
},
|
|
266
|
-
"meta": {
|
|
267
|
-
"$ref": "#/definitions/meta"
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
"additionalProperties": false
|
|
271
|
-
},
|
|
272
|
-
"pagination": {
|
|
273
|
-
"type": "object",
|
|
274
|
-
"properties": {
|
|
275
|
-
"first": {
|
|
276
|
-
"description": "The first page of data",
|
|
277
|
-
"oneOf": [
|
|
278
|
-
{ "type": "string", "format": "uri" },
|
|
279
|
-
{ "type": "null" }
|
|
280
|
-
]
|
|
281
|
-
},
|
|
282
|
-
"last": {
|
|
283
|
-
"description": "The last page of data",
|
|
284
|
-
"oneOf": [
|
|
285
|
-
{ "type": "string", "format": "uri" },
|
|
286
|
-
{ "type": "null" }
|
|
287
|
-
]
|
|
288
|
-
},
|
|
289
|
-
"prev": {
|
|
290
|
-
"description": "The previous page of data",
|
|
291
|
-
"oneOf": [
|
|
292
|
-
{ "type": "string", "format": "uri" },
|
|
293
|
-
{ "type": "null" }
|
|
294
|
-
]
|
|
295
|
-
},
|
|
296
|
-
"next": {
|
|
297
|
-
"description": "The next page of data",
|
|
298
|
-
"oneOf": [
|
|
299
|
-
{ "type": "string", "format": "uri" },
|
|
300
|
-
{ "type": "null" }
|
|
301
|
-
]
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
"jsonapi": {
|
|
307
|
-
"description": "An object describing the server's implementation",
|
|
308
|
-
"type": "object",
|
|
309
|
-
"properties": {
|
|
310
|
-
"version": {
|
|
311
|
-
"type": "string"
|
|
312
|
-
},
|
|
313
|
-
"meta": {
|
|
314
|
-
"$ref": "#/definitions/meta"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
"additionalProperties": false
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
"error": {
|
|
321
|
-
"type": "object",
|
|
322
|
-
"properties": {
|
|
323
|
-
"id": {
|
|
324
|
-
"description": "A unique identifier for this particular occurrence of the problem.",
|
|
325
|
-
"type": "string"
|
|
326
|
-
},
|
|
327
|
-
"links": {
|
|
328
|
-
"$ref": "#/definitions/links"
|
|
329
|
-
},
|
|
330
|
-
"status": {
|
|
331
|
-
"description": "The HTTP status code applicable to this problem, expressed as a string value.",
|
|
332
|
-
"type": "string"
|
|
333
|
-
},
|
|
334
|
-
"code": {
|
|
335
|
-
"description": "An application-specific error code, expressed as a string value.",
|
|
336
|
-
"type": "string"
|
|
337
|
-
},
|
|
338
|
-
"title": {
|
|
339
|
-
"description": "A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization.",
|
|
340
|
-
"type": "string"
|
|
341
|
-
},
|
|
342
|
-
"detail": {
|
|
343
|
-
"description": "A human-readable explanation specific to this occurrence of the problem.",
|
|
344
|
-
"type": "string"
|
|
345
|
-
},
|
|
346
|
-
"source": {
|
|
347
|
-
"type": "object",
|
|
348
|
-
"properties": {
|
|
349
|
-
"pointer": {
|
|
350
|
-
"description": "A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. \"/data\" for a primary data object, or \"/data/attributes/title\" for a specific attribute].",
|
|
351
|
-
"type": "string"
|
|
352
|
-
},
|
|
353
|
-
"parameter": {
|
|
354
|
-
"description": "A string indicating which query parameter caused the error.",
|
|
355
|
-
"type": "string"
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
"meta": {
|
|
360
|
-
"$ref": "#/definitions/meta"
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
"additionalProperties": false
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
data/docs/jsonapi/schema.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
[Back to Guides](../README.md)
|
|
2
|
-
|
|
3
|
-
[](http://jsonapi.org/)
|
|
4
|
-
|
|
5
|
-
## JSON API Requests
|
|
6
|
-
|
|
7
|
-
- [Query Parameters Spec](http://jsonapi.org/format/#query-parameters)
|
|
8
|
-
|
|
9
|
-
Headers:
|
|
10
|
-
|
|
11
|
-
- Request: `Accept: application/vnd.api+json`
|
|
12
|
-
- Response: `Content-Type: application/vnd.api+json`
|
|
13
|
-
|
|
14
|
-
### [Fetching Data](http://jsonapi.org/format/#fetching)
|
|
15
|
-
|
|
16
|
-
A server MUST support fetching resource data for every URL provided as:
|
|
17
|
-
|
|
18
|
-
- a `self` link as part of the top-level links object
|
|
19
|
-
- a `self` link as part of a resource-level links object
|
|
20
|
-
- a `related` link as part of a relationship-level links object
|
|
21
|
-
|
|
22
|
-
Example supported requests
|
|
23
|
-
|
|
24
|
-
- Individual resource or collection
|
|
25
|
-
- GET /articles
|
|
26
|
-
- GET /articles/1
|
|
27
|
-
- GET /articles/1/author
|
|
28
|
-
- Relationships
|
|
29
|
-
- GET /articles/1/relationships/comments
|
|
30
|
-
- GET /articles/1/relationships/author
|
|
31
|
-
- Optional: [Inclusion of related resources](http://jsonapi.org/format/#fetching-includes) `JSONAPI::IncludeDirective`
|
|
32
|
-
- GET /articles/1?`include`=comments
|
|
33
|
-
- GET /articles/1?`include`=comments.author
|
|
34
|
-
- GET /articles/1?`include`=author,comments.author
|
|
35
|
-
- GET /articles/1/relationships/comments?`include`=comments.author
|
|
36
|
-
- Optional: [Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) `ActiveModel::Serializer::Fieldset`
|
|
37
|
-
- GET /articles?`include`=author&`fields`[articles]=title,body&`fields`[people]=name
|
|
38
|
-
- Optional: [Sorting](http://jsonapi.org/format/#fetching-sorting)
|
|
39
|
-
- GET /people?`sort`=age
|
|
40
|
-
- GET /people?`sort`=age,author.name
|
|
41
|
-
- GET /articles?`sort`=-created,title
|
|
42
|
-
- Optional: [Pagination](http://jsonapi.org/format/#fetching-pagination)
|
|
43
|
-
- GET /articles?`page`[number]=3&`page`[size]=1
|
|
44
|
-
- Optional: [Filtering](http://jsonapi.org/format/#fetching-filtering)
|
|
45
|
-
- GET /comments?`filter`[post]=1
|
|
46
|
-
- GET /comments?`filter`[post]=1,2
|
|
47
|
-
- GET /comments?`filter`[post]=1,2
|
|
48
|
-
|
|
49
|
-
### [CRUD Actions](http://jsonapi.org/format/#crud)
|
|
50
|
-
|
|
51
|
-
### [Asynchronous Processing](http://jsonapi.org/recommendations/#asynchronous-processing)
|
|
52
|
-
|
|
53
|
-
### [Bulk Operations Extension](http://jsonapi.org/extensions/bulk/)
|
|
54
|
-
|
|
55
|
-
## JSON API Document Schema
|
|
56
|
-
|
|
57
|
-
| JSON API object | JSON API properties | Required | ActiveModelSerializers representation |
|
|
58
|
-
|-----------------------|----------------------------------------------------------------------------------------------------|----------|---------------------------------------|
|
|
59
|
-
| schema | oneOf (success, failure, info) | |
|
|
60
|
-
| success | data, included, meta, links, jsonapi | | AM::SerializableResource
|
|
61
|
-
| success.meta | meta | | AMS::Adapter::Base#meta
|
|
62
|
-
| success.included | UniqueArray(resource) | | AMS::Adapter::JsonApi#serializable_hash_for_collection
|
|
63
|
-
| success.data | data | |
|
|
64
|
-
| success.links | allOf (links, pagination) | | AMS::Adapter::JsonApi#links_for
|
|
65
|
-
| success.jsonapi | jsonapi | |
|
|
66
|
-
| failure | errors, meta, jsonapi | errors | AMS::Adapter::JsonApi#failure_document, #1004
|
|
67
|
-
| failure.errors | UniqueArray(error) | | AM::S::ErrorSerializer, #1004
|
|
68
|
-
| meta | Object | |
|
|
69
|
-
| data | oneOf (resource, UniqueArray(resource)) | | AMS::Adapter::JsonApi#serializable_hash_for_collection,#serializable_hash_for_single_resource
|
|
70
|
-
| resource | String(type), String(id),<br>attributes, relationships,<br>links, meta | type, id | AM::S::Adapter::JsonApi#primary_data_for
|
|
71
|
-
| links | Uri(self), Link(related) | | #1028, #1246, #1282
|
|
72
|
-
| link | oneOf (linkString, linkObject) | |
|
|
73
|
-
| link.linkString | Uri | |
|
|
74
|
-
| link.linkObject | Uri(href), meta | href |
|
|
75
|
-
| attributes | patternProperties(<br>`"^(?!relationships$|links$)\\w[-\\w_]*$"`),<br>any valid JSON | | AM::Serializer#attributes, AMS::Adapter::JsonApi#resource_object_for
|
|
76
|
-
| relationships | patternProperties(<br>`"^\\w[-\\w_]*$"`);<br>links, relationships.data, meta | | AMS::Adapter::JsonApi#relationships_for
|
|
77
|
-
| relationships.data | oneOf (relationshipToOne, relationshipToMany) | | AMS::Adapter::JsonApi#resource_identifier_for
|
|
78
|
-
| relationshipToOne | anyOf(empty, linkage) | |
|
|
79
|
-
| relationshipToMany | UniqueArray(linkage) | |
|
|
80
|
-
| empty | null | |
|
|
81
|
-
| linkage | String(type), String(id), meta | type, id | AMS::Adapter::JsonApi#primary_data_for
|
|
82
|
-
| pagination | pageObject(first), pageObject(last),<br>pageObject(prev), pageObject(next) | | AMS::Adapter::JsonApi::PaginationLinks#serializable_hash
|
|
83
|
-
| pagination.pageObject | oneOf(Uri, null) | |
|
|
84
|
-
| jsonapi | String(version), meta | | AMS::Adapter::JsonApi::Jsonapi#as_json
|
|
85
|
-
| error | String(id), links, String(status),<br>String(code), String(title),<br>String(detail), error.source, meta | | AM::S::ErrorSerializer, AMS::Adapter::JsonApi::Error.resource_errors
|
|
86
|
-
| error.source | String(pointer), String(parameter) | | AMS::Adapter::JsonApi::Error.error_source
|
|
87
|
-
| pointer | [JSON Pointer RFC6901](https://tools.ietf.org/html/rfc6901) | | AMS::JsonPointer
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
The [http://jsonapi.org/schema](schema/schema.json) makes a nice roadmap.
|
|
91
|
-
|
|
92
|
-
### Success Document
|
|
93
|
-
- [ ] success
|
|
94
|
-
- [ ] data: `"$ref": "#/definitions/data"`
|
|
95
|
-
- [ ] included: array of unique items of type `"$ref": "#/definitions/resource"`
|
|
96
|
-
- [ ] meta: `"$ref": "#/definitions/meta"`
|
|
97
|
-
- [ ] links:
|
|
98
|
-
- [ ] link: `"$ref": "#/definitions/links"`
|
|
99
|
-
- [ ] pagination: ` "$ref": "#/definitions/pagination"`
|
|
100
|
-
- [ ] jsonapi: ` "$ref": "#/definitions/jsonapi"`
|
|
101
|
-
|
|
102
|
-
### Failure Document
|
|
103
|
-
|
|
104
|
-
- [ ] failure
|
|
105
|
-
- [x] errors: array of unique items of type ` "$ref": "#/definitions/error"`
|
|
106
|
-
- [ ] meta: `"$ref": "#/definitions/meta"`
|
|
107
|
-
- [ ] jsonapi: `"$ref": "#/definitions/jsonapi"`
|
|
108
|
-
|
|
109
|
-
### Info Document
|
|
110
|
-
|
|
111
|
-
- [ ] info
|
|
112
|
-
- [ ] meta: `"$ref": "#/definitions/meta"`
|
|
113
|
-
- [ ] links: `"$ref": "#/definitions/links"`
|
|
114
|
-
- [ ] jsonapi: ` "$ref": "#/definitions/jsonapi"`
|
|
115
|
-
|
|
116
|
-
### Definitions
|
|
117
|
-
|
|
118
|
-
- [ ] definitions:
|
|
119
|
-
- [ ] meta
|
|
120
|
-
- [ ] data: oneOf (resource, array of unique resources)
|
|
121
|
-
- [ ] resource
|
|
122
|
-
- [ ] attributes
|
|
123
|
-
- [ ] relationships
|
|
124
|
-
- [ ] relationshipToOne
|
|
125
|
-
- [ ] empty
|
|
126
|
-
- [ ] linkage
|
|
127
|
-
- [ ] meta
|
|
128
|
-
- [ ] relationshipToMany
|
|
129
|
-
- [ ] linkage
|
|
130
|
-
- [ ] meta
|
|
131
|
-
- [ ] links
|
|
132
|
-
- [ ] meta
|
|
133
|
-
- [ ] links
|
|
134
|
-
- [ ] link
|
|
135
|
-
- [ ] uri
|
|
136
|
-
- [ ] href, meta
|
|
137
|
-
- [ ] pagination
|
|
138
|
-
- [ ] jsonapi
|
|
139
|
-
- [ ] meta
|
|
140
|
-
- [ ] error
|
|
141
|
-
- [ ] id: a unique identifier for this particular occurrence of the problem.
|
|
142
|
-
- [ ] links: a links object containing the following members:
|
|
143
|
-
- [ ] about: a link that leads to further details about this particular occurrence of the problem.
|
|
144
|
-
- [ ] status: the HTTP status code applicable to this problem, expressed as a string value.
|
|
145
|
-
- [ ] code: an application-specific error code, expressed as a string value.
|
|
146
|
-
- [ ] title: a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
|
|
147
|
-
- [x] detail: a human-readable explanation specific to this occurrence of the problem.
|
|
148
|
-
- [x] source: an object containing references to the source of the error, optionally including any of the following members:
|
|
149
|
-
- [x] pointer: a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].
|
|
150
|
-
- [x] parameter: a string indicating which query parameter caused the error.
|
|
151
|
-
- [ ] meta: a meta object containing non-standard meta-information about the error.
|
data/docs/rfcs/0000-namespace.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
- Start Date: (2015-10-29)
|
|
2
|
-
- RFC PR: https://github.com/rails-api/active_model_serializers/pull/1310
|
|
3
|
-
- ActiveModelSerializers Issue: https://github.com/rails-api/active_model_serializers/issues/1298
|
|
4
|
-
|
|
5
|
-
# Summary
|
|
6
|
-
|
|
7
|
-
Provide a consistent API for the user of the AMS.
|
|
8
|
-
|
|
9
|
-
# Motivation
|
|
10
|
-
|
|
11
|
-
The actual public API is defined under `ActiveModelSerializers`,
|
|
12
|
-
`ActiveModel::Serializer` and `ActiveModel`.
|
|
13
|
-
|
|
14
|
-
At the `ActiveModel::Serializer` we have:
|
|
15
|
-
|
|
16
|
-
- `ActiveModel::Serializer.config`
|
|
17
|
-
- `ActiveModel::Serializer`
|
|
18
|
-
|
|
19
|
-
At the `ActiveModelSerializers` we have:
|
|
20
|
-
|
|
21
|
-
- `ActiveModelSerializers::Model`
|
|
22
|
-
- `ActiveModelSerializers.logger`
|
|
23
|
-
|
|
24
|
-
At `ActiveModel` we have:
|
|
25
|
-
|
|
26
|
-
- `ActiveModel::SerializableResource`
|
|
27
|
-
|
|
28
|
-
The idea here is to provide a single namespace `ActiveModelSerializers` to the user.
|
|
29
|
-
Following the same idea we have on other gems like
|
|
30
|
-
[Devise](https://github.com/plataformatec/devise/blob/e9c82472ffe7c43a448945f77e034a0e47dde0bb/lib/devise.rb),
|
|
31
|
-
[Refile](https://github.com/refile/refile/blob/6b24c293d044862dafbf1bfa4606672a64903aa2/lib/refile.rb) and
|
|
32
|
-
[Active Job](https://github.com/rails/rails/blob/30bacc26f8f258b39e12f63fe52389a968d9c1ea/activejob/lib/active_job.rb)
|
|
33
|
-
for example.
|
|
34
|
-
|
|
35
|
-
This way we are clarifing the boundaries of
|
|
36
|
-
[ActiveModelSerializers and Rails](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG.md#prehistory)
|
|
37
|
-
and make clear that the `ActiveModel::Serializer` class is no longer the primary
|
|
38
|
-
behavior of the ActiveModelSerializers.
|
|
39
|
-
|
|
40
|
-
# Detailed design
|
|
41
|
-
|
|
42
|
-
## New classes and modules organization
|
|
43
|
-
|
|
44
|
-
Since this will be a big change we can do this on baby steps, read small pull requests. A
|
|
45
|
-
possible approach is:
|
|
46
|
-
|
|
47
|
-
- All new code will be in `lib/active_model_serializers/` using
|
|
48
|
-
the module namespace `ActiveModelSerializers`.
|
|
49
|
-
- Move all content under `ActiveModel::Serializer` to be under
|
|
50
|
-
`ActiveModelSerializers`, the adapter is on this steps;
|
|
51
|
-
- Move all content under `ActiveModel` to be under `ActiveModelSerializers`,
|
|
52
|
-
the `SerializableResource` is on this step;
|
|
53
|
-
- Change all public API that doesn't make sense, keeping in mind only to keep
|
|
54
|
-
this in the same namespace
|
|
55
|
-
- Update the README;
|
|
56
|
-
- Update the docs;
|
|
57
|
-
|
|
58
|
-
The following table represents the current and the desired classes and modules
|
|
59
|
-
at the first moment.
|
|
60
|
-
|
|
61
|
-
| Current | Desired | Notes |
|
|
62
|
-
|--------------------------------------------------------|--------------------------------------------------|--------------------|
|
|
63
|
-
| `ActiveModelSerializers` and `ActiveModel::Serializer` | `ActiveModelSerializers` | The main namespace |
|
|
64
|
-
| `ActiveModelSerializers.logger` | `ActiveModelSerializers.logger` ||
|
|
65
|
-
| `ActiveModelSerializers::Model` | `ActiveModelSerializers::Model` ||
|
|
66
|
-
| `ActiveModel::SerializableResource` | `ActiveModelSerializers::SerializableResource` ||
|
|
67
|
-
| `ActiveModel::Serializer` | `ActiveModelSerializers::Serializer` | The name can be discussed in a future pull request. For example, we can rename this to `Resource` [following this idea](https://github.com/rails-api/active_model_serializers/pull/1301/files#r42963185) more info about naming in the next section|
|
|
68
|
-
| `ActiveModel::Serializer.config` | `ActiveModelSerializers.config` ||
|
|
69
|
-
|
|
70
|
-
## Renaming of class and modules
|
|
71
|
-
|
|
72
|
-
When moving some content to the new namespace we can find some names that does
|
|
73
|
-
not make much sense like `ActiveModel::Serializer::Adapter::JsonApi`.
|
|
74
|
-
Discussion of renaming existing classes / modules and JsonApi objects will
|
|
75
|
-
happen in separate pull requests, and issues, and in the google doc
|
|
76
|
-
https://docs.google.com/document/d/1rcrJr0sVcazY2Opd_6Kmv1iIwuHbI84s1P_NzFn-05c/edit?usp=sharing
|
|
77
|
-
|
|
78
|
-
Some of names already have a definition.
|
|
79
|
-
|
|
80
|
-
- Adapters get their own namespace under ActiveModelSerializers. E.g
|
|
81
|
-
`ActiveModelSerializers::Adapter`
|
|
82
|
-
- Serializers get their own namespace under ActiveModelSerializers. E.g
|
|
83
|
-
`ActiveModelSerializers::Serializer`
|
|
84
|
-
|
|
85
|
-
## Keeping compatibility
|
|
86
|
-
|
|
87
|
-
All moved classes or modules be aliased to their old name and location with
|
|
88
|
-
deprecation warnings, such as
|
|
89
|
-
[was done for CollectionSerializer](https://github.com/rails-api/active_model_serializers/pull/1251).
|
|
90
|
-
|
|
91
|
-
# Drawbacks
|
|
92
|
-
|
|
93
|
-
This will be a breaking change, so all users serializers will be broken after a
|
|
94
|
-
major bump.
|
|
95
|
-
All pull requests will need to rebase since the architeture will change a lot.
|
|
96
|
-
|
|
97
|
-
# Alternatives
|
|
98
|
-
|
|
99
|
-
We can keep the way it is, and keep in mind to not add another namespace as a
|
|
100
|
-
public API.
|
|
101
|
-
|
|
102
|
-
# Unresolved questions
|
|
103
|
-
|
|
104
|
-
What is the better class name to be used to the class that will be inherited at
|
|
105
|
-
the creation of a serializer. This can be discussed in other RFC or directly via
|
|
106
|
-
pull request.
|
data/docs/rfcs/template.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
- Start Date: (YYYY-MM-DD)
|
|
2
|
-
- RFC PR: https://github.com/rails-api/active_model_serializers/pull/dddd
|
|
3
|
-
- ActiveModelSerializers Issue: https://github.com/rails-api/active_model_serializers/issues/dddd
|
|
4
|
-
|
|
5
|
-
# Summary
|
|
6
|
-
|
|
7
|
-
# Motivation
|
|
8
|
-
|
|
9
|
-
# Detailed design
|
|
10
|
-
|
|
11
|
-
# Drawbacks
|
|
12
|
-
|
|
13
|
-
# Alternatives
|
|
14
|
-
|
|
15
|
-
# Unresolved questions
|