Skip to content

Commit

Permalink
Merge pull request ColtonProvias#32 from deryckh/docs-jsonapi-type
Browse files Browse the repository at this point in the history
Add docs about __jsonapi_type_override__.
  • Loading branch information
Anderycks authored Feb 22, 2017
2 parents 6c5cea5 + 9481e5d commit 8eac67b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ your models. Let's do a simple collection serialization::
response = serializer.get_collection(db.session, {}, 'users')
return jsonify(response.data)

The third argument to `get_collection` where `users` is specified is
the model type. This is auto-generated from the model name, but you
can control this using `__jsonapi_type_override__`.

This is useful when you don't want hyphenated type names. For example,
a model named `UserConfig` will have a generated type of `user-config`.
You can change this declaratively on the model::

class UserConfig(Base):
__tablename__ = 'userconfig'
__jsonapi_type_override__ = 'userconfig'

Deserialization
===============

Expand All @@ -54,4 +66,4 @@ Deserialization is also quick and easy::
return jsonify(response.data)

If you use Flask, this can be automated and simplified via the included Flask
module.
module.

0 comments on commit 8eac67b

Please sign in to comment.