Commit Graph

189 Commits

Author SHA1 Message Date
Markus Ritberger 417d4eb8fb
Merge pull request #6 from shwoodard/shwoodard-slemgrim-pull-99
Use jsonapi struct tags for nested attrs
2018-10-04 18:04:16 +02:00
Sam Woodard 3c8221b373 use jsonapi tags for nested attrs 2018-10-03 13:51:04 -07:00
Markus Ritberger 8b7e0bc2c0
Merge pull request #5 from Slemgrim/refactor-ptr-error
Refactor ptr error and cleanup
2018-03-14 21:47:34 +01:00
Markus Ritberger d490a0f637 remove whitespaces and stick to 80chars 2018-03-14 21:43:51 +01:00
Markus Ritberger 72f7bad5b3 check for ptr error type in tests 2018-03-14 21:43:24 +01:00
Markus Ritberger 9bc94d8c70 replace public function with custom error type 2018-03-14 20:52:27 +01:00
Markus Ritberger e428b86c25
Merge pull request #4 from msabramo/fix-test-failures
Fix test failures
2018-01-25 16:51:16 +01:00
Marc Abramowitz 7c2ceac7c5 Fix test failures 2018-01-25 07:28:20 -08:00
Markus Ritberger 21b4945ad6
Merge pull request #3 from msabramo/pr-99-make-nested-struct-ptr-work
Make nested struct pointers work
2018-01-22 12:11:07 +01:00
Markus Ritberger bb266b4483
Merge pull request #2 from msabramo/pr-99-show-type-for-ErrUnsupportedPtrType
Show type for ErrUnsupportedPtrType
2018-01-22 08:33:37 +01:00
Markus Ritberger 339909da0d
Merge pull request #1 from msabramo/msabramo-pr-99
Test more things in TestUnmarshalNestedStruct
2018-01-22 08:10:08 +01:00
Marc Abramowitz a3b3bb2cb5 Show type for ErrUnsupportedPtrType
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`
```
2018-01-17 13:38:32 -08:00
Marc Abramowitz 16e19ab9f9 Make nested struct pointers work 2018-01-17 13:02:30 -08:00
Marc Abramowitz b28beab7f3 Add TestUnmarshalNestedStructPtr 2018-01-17 13:02:30 -08:00
Marc Abramowitz e3c0871f34 Test more things in TestUnmarshalNestedStruct 2018-01-17 08:12:59 -08:00
Slemgrim 0400041771 fix wrong type for formatting 2017-11-21 19:15:24 +08:00
Slemgrim a6577dfae8 Add more speaking tests
tests should have an expected outcome vs. an actual outcome to make them easier to debug
2017-11-21 19:05:50 +08:00
Slemgrim 7e5c9014d9 Merge remote-tracking branch 'upstream/master' 2017-11-21 18:42:48 +08:00
Sam Woodard e0fc4eed33
Merge pull request #118 from themccallister/patch-1
Add tests for mismatching accept headers
2017-11-08 09:49:09 -08:00
Jason McCallister 081fb8a5c2 Add additional test for method not found 2017-10-23 22:46:32 -04:00
Jason McCallister c036316c9d Add tests for mismatching accept headers 2017-10-23 22:41:44 -04:00
Aren Patel a06052dd83
Run gofmt -s to simplifiy. 2017-09-13 12:59:59 -07:00
Aren Patel 8d89a9020f
Fix comment. 2017-09-13 12:56:47 -07:00
Aren Patel 2ce5c379b0
Address go lint comments for the examples. 2017-09-13 12:56:01 -07:00
Aren Patel 5e0c586099
Corrected spelling mistakes. 2017-09-13 12:52:31 -07:00
Aren Patel 3b01bb5fe6
Added go report card. 2017-09-13 12:49:52 -07:00
Aren Patel 3e6ead0f9d
Test against 1.9 2017-09-05 11:11:09 -04:00
Markus Ritberger fc6968dfe7 change nested structs to json annotation instead of json:api. It never made sense to use json:api annotation in nested structs 2017-08-14 20:41:26 +02:00
Markus Ritberger b391a84b75 remove duplicated code 2017-08-14 20:39:14 +02:00
Aren Patel c045c87aa1
Ignore Gogland files. 2017-08-01 11:45:13 -07:00
Slemgrim af21dba1b2 handle nested struct slices 2017-07-15 15:22:03 +02:00
Slemgrim 0c97f0cf8d extract attribute handling into custom method for recursive usage later on 2017-07-11 21:43:12 +02:00
Slemgrim ab915ccbc1 unify type handler 2017-07-10 22:50:43 +02:00
Slemgrim f0b268e046 Merge remote-tracking branch 'upstream/master' 2017-07-10 22:16:45 +02:00
Slemgrim ec077ed283 Merge branch 'master' of https://github.com/Slemgrim/jsonapi 2017-07-10 22:12:10 +02:00
Slemgrim e13a19922d extract type handling 2017-07-10 22:09:01 +02:00
Aren Patel 46d3ced043 Added support for implementing the Linkable and Metable interface on collections (slices) being Marshalled. (#94) 2017-07-07 17:58:51 -07:00
Aren Patel cf83b97b3d Public Marshal API Simplification (#90)
* 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
2017-06-28 17:30:09 -07:00
Stratos Neiros ebb7923313 Add omitempty to Node.ID (#89)
This commit adds omitempty to the field ID of type Node. This is needed
when constructing an entity client-side and sending it to the server for
creation. Without omitempty, the constructed entity will contain an
empty "id": "", which is not sensible to transmit.

This change addresses #83.
2017-05-23 20:17:04 -07:00
Angelos Panagiotopoulos af3dab1a94 Update documentation for responding with proper JSON API headers (#84)
* Update documentation for responding with proper JSONAPI headers

* Fixed examples and commented code for sending proper response headers
2017-04-05 11:19:51 -07:00
Anthony Dodd bce7629682 Use subtests (can only test against go >= 1.7 now). (#63) 2017-02-17 15:11:39 -08:00
Aren Patel 2b01775d0f Merge branch 'feature/meta' 2017-02-16 20:33:20 -08:00
Aren Patel 57008357f7 Feature/meta (#81)
* Added back the Metable implementation for our example models.

* Examples updated to use jsonapi.Links and jsonapi.Meta types rather than the underlying map[string]interface{}

* Commenting the Metable interface and moving the Meta type beside it.

* Use the headerAccept constant defined for the example app.

* Make the Meta field of a Link of type Meta rather than a map[string]inteface{}

* Convert the map[string]interface to a Meta in the test.

* Updated the readme to include a deeply nested, varying typed meta example.

* Moving all testing models to their own file; preparing to write a more complete Meta test.

* Make the Meta test also check for the value of the detail key. Moved more test support models.
2017-02-16 20:31:19 -08:00
Aren Patel 0a2decba43 Make the Meta test also check for the value of the detail key. Moving all testing models to their own file. Updated the readme to include a deeply nested, varying typed meta example. Convert the map[string]interface to a Meta in the tests. Make the Meta field of a Link of type Meta rather than a map[string]inteface{}. Use the headerAccept constant defined for the example app. Commenting the new Metable interface and moving the Meta type beside it. Example app updated to use jsonapi.Links and jsonapi.Meta types rather than the underlying map[string]interface{}. 2017-02-16 20:28:09 -08:00
Aren Patel 9babeb5aea Merge branch 'master' into feature/meta
* master:
  Added tests for the REST endpoints exposed in our example. Added a script for running the example app. Split the example into multiple files.
  Go 1.8 released today; dropping support for 1.6
  Travis calls script/test
  Added a script/test such that the example app can also have tests and been included in the CI test runs.

# Conflicts:
#	examples/app.go
2017-02-16 19:30:44 -08:00
Aren Patel 6958c3a8be Added tests for the REST endpoints exposed in our example. Added a script for running the example app. Split the example into multiple files. 2017-02-16 19:28:09 -08:00
Aren Patel 4898d2ff2a Go 1.8 released today; dropping support for 1.6 2017-02-16 17:49:49 -08:00
Aren Patel 4ffe86f477 Travis calls script/test 2017-02-16 17:48:23 -08:00
Aren Patel b7ab492362 Added a script/test such that the example app can also have tests and been included in the CI test runs. 2017-02-16 17:47:00 -08:00
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