@@ -140,7 +140,29 @@ authorization code is similar to those other apps.
140140
141141### JSON serialization
142142
143- ** TO DO**
143+ GALC API endpoints follow the [ JSON: API ] ( https://jsonapi.org/ ) specification
144+ for object serialization, using the [ ` jsonapi ` ] ( https://github.com/stas/jsonapi.rb )
145+ gem. Key differences for the developer from traditional Rails JSON serialization
146+ include:
147+
148+ - rendering the ` :jsonapi ` format rather than ` :json `
149+ - using the ` application/vnd.api+json ` media type rather than ` application/json `
150+ - explicit serialization for all model objects rather than using the default
151+ ActiveModel serializer (see the [ ` app/serializers ` ] ( app/serializers ) directory)
152+ - side-channel information via the [ ` meta ` ] ( https://jsonapi.org/format/#document-meta )
153+ element in the response object
154+ - query parameters following JSON: API 's [ paging] ( https://jsonapi.org/format/#fetching-pagination )
155+ specification and [ filtering] ( https://jsonapi.org/recommendations/#filtering )
156+ recommendation instead of following Rails / ActionController norms
157+
158+ Testing JSON: API responses (and, in particular, getting useful information out
159+ of test failures) can be fairly involved. Some custom RSpec matchers are included
160+ in the [ ` spec/support/matchers ` ] ( spec/support/matchers ) directory, see e.g.
161+ the [ ` ItemsController request spec ` ] ( spec/requests/items_spec.rb ) for an example
162+ of their usage. They're not perfect (note for instance that the specs usually
163+ need to delete the ` links ` field from the response object before comparing) but
164+ they do help. Note that these matchers depend on the serializers in ` app/serializers `
165+ to be working properly, so those need their own [ lower-level unit tests] ( spec/serializers ) .
144166
145167### Image file handling
146168
0 commit comments