Using go run $GOPATH/src/github.com/google/jsonapi/examples/app.go as
shown in the Readme, leads to errors (#126) since go run requires all
the .go files of a program.
This commit changes the Readme to show how to run the example app using
go build to avoid this issue.
* Used to have 6 functions: MarshalOnePayload, MarshalOnePayloadWithoutIncluded, MarshalOne, MarshalManyPayload, MarshalManyPayloadWithoutIncluded, MarshalMany - now there are only 3: MarshalPayload, MarshalPayloadWithoutIncluded, Marshal. This simplifies the public API; will be easier to explain and document while still providing the existing support for struct ptrs (&Blog{}) and slices of struct ptrs ([]*Blog{}).
* Correcting all code occurrences leftover.
* Updating README to reflect Marshal API changes.
* Omit the mention of One vs Many
* 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
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.
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.
* 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
* 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.
* 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.
* 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.