Commit Graph

31 Commits

Author SHA1 Message Date
Samantha Belkin 776433d17d Add support for 'meta' (#72)
* add Meta field in node structs and Metable/RelationshipMetable interfaces

* update response marshalling to add Meta

* update tests for presence of Meta

* add Metable and RelationshipMetable interfaces to example

* update README to include Meta details
2017-02-16 17:40:50 -08:00
Aren Patel 52f00735e0 Add GoDoc button. 2017-02-13 11:41:01 -08:00
Matt Bostock 40fe9896b3 Prefix example app with $GOPATH env var (#79)
Instead of using `cd` to change to the package directory, prepend the examples commands with `$GOPATH`, which will make the commands easier to follow for anyone unfamiliar with Go. It's easy to miss the 'cd' instruction above.
2017-02-07 18:42:29 -08:00
Aren Patel ec041eb56b Updated README.md
Corrected the example for Links
2017-02-03 19:16:54 -08:00
Marc Abramowitz 71d291e52c README.md: Fix typo in "serializer" (#65) 2017-02-03 12:16:52 -08:00
Anthony Dodd 5836d603a3
Handle type errors properly during unmarshal node.
During the `unmarshalNode` routine, various type errors may come up.
Currently they are being swallowed by the error handling mechanism.
Rework that system so that errors are actually exposed and can be
corrected without having to dive into the code.

Handle time.Time & *time.Time type errors.

Add test for unmarshalling ptr with bad type.

Final `attr` type check catch-all & tests.

Implement system for JSON API compatible errors.

This commit creates a series of structs and interfaces for representing
JSON API compatible error objects. It includes a method for emitting a
payload of error objects (according to the JSON API spec). Its algorithm
is based upon a series of interfaces which define incremental levels of
support for errors which are JSON API compatible.

Use new error type for unmarshalling errors.

Update some docs & the privacy of a func.

Don't be prescriptive on `meta`. Use map[string]interface{}.

Add a README section on errors &c.

Do not force inclusion of `title` & `detail` (use omitempty).

Update README & docs on use of pertient errors related types.

Update tests to account for these changes.

If error type is already *ErrorObject, return immediately.

Rm everything except for ErrorsPayload, ErrorObject & MarshalErrors.

Also update README & tests.

Remove a test fixture which is no longer needed.
2017-01-31 13:06:10 -06:00
Aren Patel 3ea9ec4904 Testing and Documentation for UnmarshalManyPayload (#66)
* Added a test for UnmarshalManyPayload

* Document UnmarshalManyPayload in the Readme

* Update the example app to have a UnmarshalManyPayload usage.

* DRY the UnmarshalManyPayload implementation.

* Add a test for grabbing the Links out of a ManyPayload
2017-01-26 15:25:13 -08:00
Aren Patel 15abc3066a Use constants for status codes, HTTP methods and JSON API media types in comments and readme 2017-01-20 18:06:44 -08:00
Kyle Truscott 46a5b96356 Add support for 'links' via optional interfaces (#57)
* Implement `links` via optional interfaces

* Updating example app to include links

* Update readme with links information

* Exclude a slice relationship only if the slice is empty AND there are no defined links

* Remove `Link` in favor of vanilla `map[string]interface{}`. More flexible for different allowed links spec implementations.

* Update app.go with correct Links methods

* Use LinksObject and LinkObject types along with type assertion to provide errors when marshaling an invalid links JSON API object.

* Renamed LinksObject Links and LinkObject Link

* Added back the relationship link post merge.

* Renamed the JSON* Linkable functions JSONAPI* such that when a library user implements the interface it is clear the functions are used for JSON API as opposed to JSON

* Example cleanup.

* Refactor the example to use constants from jsonapi and http.
2017-01-20 17:55:59 -08:00
Aren Patel 2cb19b89ed Skimata's null relationships + fixes (#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.
2017-01-20 16:13:04 -08:00
Aren Patel dd46e31eb5 Updated: build status badge, the go get installation instruction to account for the repo move, readme examples use ID instead of Id (so that they would be linter compliant if copy/pasted). shwoodard/jsonapi => google/jsonapi (#41) 2016-07-22 18:31:33 -07:00
Aren Patel de4994e265 Feature/omitempty (#35)
* Implemented a failing test demonstrating the intended behaviour of the omitempty annotation.

* Updated the failing test to ensure that unset field without the "omitempty" annotation are not inadvertently omitted.

* Working implementation of the "omitempty" annotation for fields that are of any type.

* Update the readme to include a brief description of how to use the `omitempty` in a attr field.

* Update the json example also using a uint for type variety.
2016-07-16 08:24:21 -07:00
Sean W. Richardson 0f0ccecbdb Fix typo in example app go get text. 2015-08-24 19:53:05 -05:00
Dennis Faust 0af952c6c4 Small edits to readme. Standardize on JSON API. 2015-08-18 14:22:19 -07:00
Sam Woodard 789321ddea fix readme subtree install url 2015-07-31 21:48:48 -07:00
Aren Patel 6522035828 Updated GitHub url - fixes #4 2015-07-24 22:06:38 -07:00
Sam Woodard 853b80c07a add alternative installation with subtress docs 2015-07-19 10:55:51 -07:00
Sam Woodard 0554b45f81 proof read, fixes, clarifications, add installation 2015-07-19 10:32:22 -07:00
Sam Woodard b8389265b6 typo fix 2015-07-13 14:51:26 -07:00
Sam Woodard 48a0031e3a typo fix 2015-07-13 14:49:36 -07:00
Sam Woodard dde4d75da4 fix link 2015-07-13 14:04:08 -07:00
Sam Woodard 3574efbd33 link to godoc 2015-07-13 14:02:26 -07:00
Sam Woodard bc547ac735 more docs including package desc for godoc 2015-07-13 11:59:11 -07:00
Sam Woodard 9333e9b531 add build status badge to readme md 2015-07-13 11:34:03 -07:00
Sam Woodard 6fb6757b35 lots more docs 2015-07-13 11:23:03 -07:00
Sam Woodard e7bd3d1fbc more docs for MarshalMany 2015-07-13 10:44:47 -07:00
Sam Woodard d9a31fb056 add more docs 2015-07-13 10:10:11 -07:00
Sam Woodard c5ab82d971 fix link 2015-07-13 10:07:55 -07:00
Sam Woodard 1514449cab work on README 2015-07-13 10:07:12 -07:00
Sam Woodard ffcbb660c3 readme work and an example app 2015-07-10 13:50:51 -07:00
Sam Woodard fcfbda00d2 licence and begin readme 2015-07-08 16:48:13 -07:00