* RFC 3339 support for both Marshal and Unmarshal.
* Post merge cleanup
* Update request_test.go
Co-authored-by: Quetzy Garcia <quetzy.garcia@integrate.com>
* Spelling
* Update request.go
Co-authored-by: Quetzy Garcia <quetzy.garcia@integrate.com>
* Simplify the ISO 8601 logic. No need for the const rfc3339TimeFormat use time.RFC3339 directly.
Co-authored-by: Quetzy Garcia <quetzy.garcia@integrate.com>
@omarismail LGTM.
I'm curious what you think about perhaps documenting these `iso8601` and `rfc3339` in the `Readme.md`? How did you find that this tag option/value existed? How can we make this better for others vs having to search the library implementation?
* fix(request): change the order of the resource data check to prioritise the type when unmarshalling
- fixes#176
* tests(request): update the TestUnmarshalPayload_ptrsAllNil test that broke
* Using %v instead of %s
* Added a test case to demonstrate that this library follows the spec: covered the case where the incoming request payload is missing the `type` field, an error is expected.
Co-authored-by: Aren Patel <git@arenpatel.com>
to aid in troubleshooting.
Before:
```
Pointer type in struct is not supported
```
After:
```
jsonapi: Can't unmarshal true (bool) to struct field `Name`, which is a pointer to `string`
```
* 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
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
* 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.
* Added support for string, int(8,16,32,64), uint(8,16,32,64) and each of their ptr types as acceptable to use for the ID field.
* No longer declaring a new idErr var; also eliminate the switch within a switch - if the ID field was a string or *string it will continue. Added a couple extra tests.
* Add support for iso8601 struct tag.
Currently only unix timestamps are supported for serialising time.Time objects. The JSON.API specification doesn't make a specific requirement on time serialisation format, though it does make a recommendation for using ISO8601.
This adds support for an additional struct tag `iso8601` which controls serialisation and deserialisation using the ISO8601 timestamp format.
* Update doc.go with information regarding iso8601 and omitempty tag arguments.
* add support for direct use of slice of struct pointers for MarshalMany
* Added a test to ensure that whether MarshalManyPayload is called with a []interface{} or []*Struct it will produce the same desired result.
* Added a test to show how the new error type may be returned.
* Ensure the outside accessible Errs have comments.
* Page char width cleanup. Addressed warnings about duplicated "client-id" definition; using the const.
* add support to unmarshal attributes to struct field that are ptr types
* Spacing, addressed all the linter warnings, comments to describe errors, cleanup, left a TODO note to resolve the Error messaging.