forked from google/jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skimata's null relationships + fixes (google#62)
* Add support to nullify relationship; http://jsonapi.org/format/#document-resource-object-linkage * Fixed: [null] is not valid as an empty relationship. * add support for 'omitempty' on relationships; default behavior of marshalling empty/nil relations (i.e. w/o 'omitempty' tag) marshals with null data relation * cleanup whitespace * Added go 1.7 to test versions; fixed the marshaling of empty relations to return an empty array rather than a null/nil. Added a more robust test case for the marshaling of non omitted relations. * Cleanup. * Added a comment to UnmarshalMany * Document the ‘omitempty’ annotation on a relation. * Add common JSON API values as exported jsonapi pkg constants.
- Loading branch information
Showing
8 changed files
with
327 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
language: go | ||
go: | ||
- 1.4.3 | ||
- 1.5.3 | ||
- 1.4 | ||
- 1.5 | ||
- 1.6 | ||
- 1.7 | ||
- tip | ||
script: go test -v . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package jsonapi | ||
|
||
const ( | ||
// StructTag annotation strings | ||
annotationJSONAPI = "jsonapi" | ||
annotationPrimary = "primary" | ||
annotationClientID = "client-id" | ||
annotationAttribute = "attr" | ||
annotationRelation = "relation" | ||
annotationOmitEmpty = "omitempty" | ||
annotationISO8601 = "iso8601" | ||
annotationSeperator = "," | ||
|
||
iso8601TimeFormat = "2006-01-02T15:04:05Z" | ||
|
||
// MediaType is the identifier for the JSON API media type | ||
// | ||
// see http://jsonapi.org/format/#document-structure | ||
MediaType = "application/vnd.api+json" | ||
|
||
// Pagination Constants | ||
// | ||
// http://jsonapi.org/format/#fetching-pagination | ||
|
||
// KeyFirstPage is the key to the links object whose value contains a link to | ||
// the first page of data | ||
KeyFirstPage = "first" | ||
// KeyLastPage is the key to the links object whose value contains a link to | ||
// the last page of data | ||
KeyLastPage = "last" | ||
// KeyPreviousPage is the key to the links object whose value contains a link | ||
// to the previous page of data | ||
KeyPreviousPage = "prev" | ||
// KeyNextPage is the key to the links object whose value contains a link to | ||
// the next page of data | ||
KeyNextPage = "next" | ||
|
||
// QueryParamPageNumber is a JSON API query parameter used in a page based | ||
// pagination strategy in conjunction with QueryParamPageSize | ||
QueryParamPageNumber = "page[number]" | ||
// QueryParamPageSize is a JSON API query parameter used in a page based | ||
// pagination strategy in conjunction with QueryParamPageNumber | ||
QueryParamPageSize = "page[size]" | ||
|
||
// QueryParamPageOffset is a JSON API query parameter used in an offset based | ||
// pagination strategy in conjunction with QueryParamPageLimit | ||
QueryParamPageOffset = "page[offset]" | ||
// QueryParamPageLimit is a JSON API query parameter used in an offset based | ||
// pagination strategy in conjunction with QueryParamPageOffset | ||
QueryParamPageLimit = "page[limit]" | ||
|
||
// QueryParamPageCursor is a JSON API query parameter used with a cursor-based | ||
// strategy | ||
QueryParamPageCursor = "page[cursor]" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.