mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
347 lines
11 KiB
HTML
347 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>
|
|
File: schema
|
|
|
|
— Documentation by YARD 0.8.7.6
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
hasFrames = window.top.frames.main ? true : false;
|
|
relpath = '';
|
|
framesUrl = "frames.html#!file.schema.html";
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="_index.html">Index</a> »
|
|
<span class="title">File: schema</span>
|
|
|
|
|
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a class="full_list_link" id="class_list_link"
|
|
href="class_list.html">
|
|
Class List
|
|
</a>
|
|
|
|
<a class="full_list_link" id="method_list_link"
|
|
href="method_list.html">
|
|
Method List
|
|
</a>
|
|
|
|
<a class="full_list_link" id="file_list_link"
|
|
href="file_list.html">
|
|
File List
|
|
</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<iframe id="search_frame"></iframe>
|
|
|
|
<div id="content"><div id='filecontents'>
|
|
<p><a href="../README.md">Back to Guides</a></p>
|
|
|
|
<p><a href="http://jsonapi.org/"><img
|
|
src="https://img.shields.io/badge/JSON%20API-1.0-lightgrey.svg"></a></p>
|
|
|
|
<h2 id="label-JSON+API+Requests">JSON API Requests</h2>
|
|
<ul><li>
|
|
<p><a href="http://jsonapi.org/format/#query-parameters">Query Parameters
|
|
Spec</a></p>
|
|
</li></ul>
|
|
|
|
<p>Headers:</p>
|
|
<ul><li>
|
|
<p>Request: <code>Accept: application/vnd.api+json</code></p>
|
|
</li><li>
|
|
<p>Response: <code>Content-Type: application/vnd.api+json</code></p>
|
|
</li></ul>
|
|
|
|
<h3 id="label-Fetching+Data"><a href="http://jsonapi.org/format/#fetching">Fetching Data</a></h3>
|
|
|
|
<p>A server MUST support fetching resource data for every URL provided as:</p>
|
|
<ul><li>
|
|
<p>a <code>self</code> link as part of the top-level links object</p>
|
|
</li><li>
|
|
<p>a <code>self</code> link as part of a resource-level links object</p>
|
|
</li><li>
|
|
<p>a <code>related</code> link as part of a relationship-level links object</p>
|
|
</li></ul>
|
|
|
|
<p>Example supported requests</p>
|
|
<ul><li>
|
|
<p>Individual resource or collection</p>
|
|
</li><li>
|
|
<p>GET /articles</p>
|
|
</li><li>
|
|
<p>GET /articles/1</p>
|
|
</li><li>
|
|
<p>GET /articles/1/author</p>
|
|
</li><li>
|
|
<p>Relationships</p>
|
|
</li><li>
|
|
<p>GET /articles/1/relationships/comments</p>
|
|
</li><li>
|
|
<p>GET /articles/1/relationships/author</p>
|
|
</li><li>
|
|
<p>Optional: <a href="http://jsonapi.org/format/#fetching-includes">Inclusion
|
|
of related resources</a> <code>JSONAPI::IncludeDirective</code></p>
|
|
</li><li>
|
|
<p>GET /articles/1?<code>include</code>=comments</p>
|
|
</li><li>
|
|
<p>GET /articles/1?<code>include</code>=comments.author</p>
|
|
</li><li>
|
|
<p>GET /articles/1?<code>include</code>=author,comments.author</p>
|
|
</li><li>
|
|
<p>GET /articles/1/relationships/comments?<code>include</code>=comments.author</p>
|
|
</li><li>
|
|
<p>Optional: <a
|
|
href="http://jsonapi.org/format/#fetching-sparse-fieldsets">Sparse
|
|
Fieldsets</a> <code>ActiveModel::Serializer::Fieldset</code></p>
|
|
</li><li>
|
|
<p>GET /<a href="articles">articles?include=author&fields</a>=<a
|
|
href="people">title,body&fields</a>=name</p>
|
|
</li><li>
|
|
<p>Optional: <a href="http://jsonapi.org/format/#fetching-sorting">Sorting</a></p>
|
|
</li><li>
|
|
<p>GET /people?<code>sort</code>=age</p>
|
|
</li><li>
|
|
<p>GET /people?<code>sort</code>=age,author.name</p>
|
|
</li><li>
|
|
<p>GET /articles?<code>sort</code>=-created,title</p>
|
|
</li><li>
|
|
<p>Optional: <a
|
|
href="http://jsonapi.org/format/#fetching-pagination">Pagination</a></p>
|
|
</li><li>
|
|
<p>GET /<a href="number">articles?page</a>=<a href="size">3&page</a>=1</p>
|
|
</li><li>
|
|
<p>Optional: <a
|
|
href="http://jsonapi.org/format/#fetching-filtering">Filtering</a></p>
|
|
</li><li>
|
|
<p>GET /<a href="post">comments?filter</a>=1</p>
|
|
</li><li>
|
|
<p>GET /<a href="post">comments?filter</a>=1,2</p>
|
|
</li><li>
|
|
<p>GET /<a href="post">comments?filter</a>=1,2</p>
|
|
</li></ul>
|
|
|
|
<h3 id="label-CRUD+Actions"><a href="http://jsonapi.org/format/#crud">CRUD Actions</a></h3>
|
|
|
|
<h3 id="label-Asynchronous+Processing"><a href="http://jsonapi.org/recommendations/#asynchronous-processing">Asynchronous Processing</a></h3>
|
|
|
|
<h3 id="label-Bulk+Operations+Extension"><a href="http://jsonapi.org/extensions/bulk/">Bulk Operations Extension</a></h3>
|
|
|
|
<h2 id="label-JSON+API+Document+Schema">JSON API Document Schema</h2>
|
|
|
|
<p>| JSON API object | JSON API properties | Required | ActiveModelSerializers
|
|
representation |
|
|
|———————–|—————————————————————————————————-|———-|—————————————| | schema |
|
|
oneOf (success, failure, info) | | | success | data, included, meta, links,
|
|
jsonapi | | AM::SerializableResource | success.meta | meta | |
|
|
AMS::Adapter::Base#meta | success.included | UniqueArray(resource) | |
|
|
AMS::Adapter::JsonApi#serializable_hash_for_collection | success.data |
|
|
data | | | success.links | allOf (links, pagination) | |
|
|
AMS::Adapter::JsonApi#links_for | success.jsonapi | jsonapi | | | failure |
|
|
errors, meta, jsonapi | errors | AMS::Adapter::JsonApi#failure_document,
|
|
#1004 | failure.errors | UniqueArray(error) | | AM::S::ErrorSerializer,
|
|
#1004 | meta | Object | | | data | oneOf (resource, UniqueArray(resource))
|
|
| |
|
|
AMS::Adapter::JsonApi#serializable_hash_for_collection,#serializable_hash_for_single_resource
|
|
| resource | String(type), String(id),<br>attributes,
|
|
relationships,<br>links, meta | type, id |
|
|
AM::S::Adapter::JsonApi#primary_data_for | links | Uri(self), Link(related)
|
|
| | #1028, #1246, #1282 | link | oneOf (linkString, linkObject) | | |
|
|
link.linkString | Uri | | | link.linkObject | Uri(href), meta | href | |
|
|
attributes | <a
|
|
href="-\\w_">patternProperties(<br>“^(?!relationships$|links$)\w</a><code>*$"</code>),<br>any
|
|
valid JSON | | AM::Serializer#attributes,
|
|
AMS::Adapter::JsonApi#resource_object_for | relationships | <a
|
|
href="-\\w_">patternProperties(<br>”^\w</a><code>*$"</code>);<br>links,
|
|
relationships.data, meta | | AMS::Adapter::JsonApi#relationships_for |
|
|
relationships.data | oneOf (relationshipToOne, relationshipToMany) | |
|
|
AMS::Adapter::JsonApi#resource_identifier_for | relationshipToOne |
|
|
anyOf(empty, linkage) | | | relationshipToMany | UniqueArray(linkage) | | |
|
|
empty | null | | | linkage | String(type), String(id), meta | type, id |
|
|
AMS::Adapter::JsonApi#primary_data_for | pagination | pageObject(first),
|
|
pageObject(last),<br>pageObject(prev), pageObject(next) | |
|
|
AMS::Adapter::JsonApi::PaginationLinks#serializable_hash |
|
|
pagination.pageObject | oneOf(Uri, null) | | | jsonapi | String(version),
|
|
meta | | AMS::Adapter::JsonApi::Jsonapi#as_json | 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 | error.source |
|
|
String(pointer), String(parameter) | |
|
|
AMS::Adapter::JsonApi::Error.error_source | pointer | <a
|
|
href="https://tools.ietf.org/html/rfc6901">JSON Pointer RFC6901</a> | |
|
|
AMS::JsonPointer</p>
|
|
|
|
<p>The <a href="schema/schema.json">jsonapi.org/schema</a> makes a nice
|
|
roadmap.</p>
|
|
|
|
<h3 id="label-Success+Document">Success Document</h3>
|
|
<ul><li>
|
|
<p>[ ] success</p>
|
|
</li><li>
|
|
<p>[ ] data: <code>"$ref": "#/definitions/data"</code></p>
|
|
</li><li>
|
|
<p>[ ] included: array of unique items of type <code>"$ref":
|
|
"#/definitions/resource"</code></p>
|
|
</li><li>
|
|
<p>[ ] meta: <code>"$ref": "#/definitions/meta"</code></p>
|
|
</li><li>
|
|
<p>[ ] links:</p>
|
|
<ul><li>
|
|
<p>[ ] link: <code>"$ref": "#/definitions/links"</code></p>
|
|
</li><li>
|
|
<p>[ ] pagination: <code>"$ref":
|
|
"#/definitions/pagination"</code></p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] jsonapi: <code>"$ref":
|
|
"#/definitions/jsonapi"</code></p>
|
|
</li></ul>
|
|
|
|
<h3 id="label-Failure+Document">Failure Document</h3>
|
|
<ul><li>
|
|
<p>[ ] failure</p>
|
|
</li><li>
|
|
<p>[x] errors: array of unique items of type <code>"$ref":
|
|
"#/definitions/error"</code></p>
|
|
</li><li>
|
|
<p>[ ] meta: <code>"$ref": "#/definitions/meta"</code></p>
|
|
</li><li>
|
|
<p>[ ] jsonapi: <code>"$ref":
|
|
"#/definitions/jsonapi"</code></p>
|
|
</li></ul>
|
|
|
|
<h3 id="label-Info+Document">Info Document</h3>
|
|
<ul><li>
|
|
<p>[ ] info</p>
|
|
</li><li>
|
|
<p>[ ] meta: <code>"$ref": "#/definitions/meta"</code></p>
|
|
</li><li>
|
|
<p>[ ] links: <code>"$ref": "#/definitions/links"</code></p>
|
|
</li><li>
|
|
<p>[ ] jsonapi: <code>"$ref":
|
|
"#/definitions/jsonapi"</code></p>
|
|
</li></ul>
|
|
|
|
<h3 id="label-Definitions">Definitions</h3>
|
|
<ul><li>
|
|
<p>[ ] definitions:</p>
|
|
</li><li>
|
|
<p>[ ] meta</p>
|
|
</li><li>
|
|
<p>[ ] data: oneOf (resource, array of unique resources)</p>
|
|
</li><li>
|
|
<p>[ ] resource</p>
|
|
<ul><li>
|
|
<p>[ ] attributes</p>
|
|
</li><li>
|
|
<p>[ ] relationships</p>
|
|
</li><li>
|
|
<p>[ ] relationshipToOne</p>
|
|
<ul><li>
|
|
<p>[ ] empty</p>
|
|
</li><li>
|
|
<p>[ ] linkage</p>
|
|
</li><li>
|
|
<p>[ ] meta</p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] relationshipToMany</p>
|
|
<ul><li>
|
|
<p>[ ] linkage</p>
|
|
</li><li>
|
|
<p>[ ] meta</p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] links</p>
|
|
</li><li>
|
|
<p>[ ] meta</p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] links</p>
|
|
<ul><li>
|
|
<p>[ ] link</p>
|
|
</li><li>
|
|
<p>[ ] uri</p>
|
|
</li><li>
|
|
<p>[ ] href, meta</p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] pagination</p>
|
|
</li><li>
|
|
<p>[ ] jsonapi</p>
|
|
<ul><li>
|
|
<p>[ ] meta</p>
|
|
</li></ul>
|
|
</li><li>
|
|
<p>[ ] error</p>
|
|
<ul><li>
|
|
<p>[ ] id: a unique identifier for this particular occurrence of the problem.</p>
|
|
</li><li>
|
|
<p>[ ] links: a links object containing the following members:</p>
|
|
</li><li>
|
|
<p>[ ] about: a link that leads to further details about this particular
|
|
occurrence of the problem.</p>
|
|
</li><li>
|
|
<p>[ ] status: the HTTP status code applicable to this problem, expressed as a
|
|
string value.</p>
|
|
</li><li>
|
|
<p>[ ] code: an application-specific error code, expressed as a string value.</p>
|
|
</li><li>
|
|
<p>[ ] 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.</p>
|
|
</li><li>
|
|
<p>[x] detail: a human-readable explanation specific to this occurrence of the
|
|
problem.</p>
|
|
</li><li>
|
|
<p>[x] source: an object containing references to the source of the error,
|
|
optionally including any of the following members:</p>
|
|
</li><li>
|
|
<p>[x] pointer: a JSON Pointer <a
|
|
href="https://tools.ietf.org/html/rfc6901">RFC6901</a> to the associated
|
|
entity in the request document [e.g. “/data” for a primary data object, or
|
|
“/data/attributes/title” for a specific attribute].</p>
|
|
</li><li>
|
|
<p>[x] parameter: a string indicating which query parameter caused the error.</p>
|
|
</li><li>
|
|
<p>[ ] meta: a meta object containing non-standard meta-information about the
|
|
error.</p>
|
|
</li></ul>
|
|
</li></ul>
|
|
</div></div>
|
|
|
|
<div id="footer">
|
|
Generated on Thu Jun 16 09:05:07 2016 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.8.7.6 (ruby-2.2.4).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |