kt.jsonapi
supports generation of JSON:API responses using
adaptation from application objects.
Input validation for JSON:API is not currently provided, but is planned for the future.
The current implementation works with the Flask web framework.
- Drop support for Python 3.6.
- Update to support Flask 2.2 and newer without deprecation warnings.
The changes to use
app.json
orapp.json_provider_class
instead ofapp.json_encoder
affect many applications that drive their own response generation.
- Add missing
long_description
package metadata.
- First public release of
kt.jsonapi
. - Added support for Python 3.10, 3.11.
- Bug fix: The context methods
created()
andresource()
could serialize the primary data intoincluded
as well asdata
if a circular relationship including the primary data passed into the call was included. - Fix tests inherited from the
resource
tests to actually invoked thecreated
method when run as part of the tests forcreated
. - Add response method
related()
to generate a serialized response for the target of a relationship. This is useful with regard to mutable to-one relationships because of the constraint that therelated
resource link not change because of changes to the referenced resource. - Allow a Flask application to provide specialized context implementations that can provide appropriate JSON:API Object values.
- Support serialization of a JSON:API Object with all responses.
- Avoid unintended chained exceptions in
context()
anderror_context()
high-level functions.
- Support JSON:API 1.1 enhancements to the link & error objects.
- Support
include
andfields
as appropriate for responses where the primary data is a relationship. This reflects an extension of the relationship interfaces with thename
attribute, which remains optional; if not present,include
andfields
continue to generate an error. - Include content from relationships which were identified in the
include
query parameter even if the relationships themselves were excluded by afields[...]
parameter. - Update to modern PyPA tooling recommendations.
- Serialization of errors via adaptation is supported using a new context method. This includes support for multiple error objects in a single response. This does not cause JSON:API errors to be returned automatically from response methods on the context, since switching from a planned response to an error response should invoke content negotiation; this is left to integration layers.
- Support relationships that cannot be included in composite documents
using the
include
query string parameter. A request for inclusion of resources from a non-includable relationship will cause an exception indicating a 400 Bad Request response will be raised. Otherwise, the relationship will be serialized without adata
element; onlylinks
andmeta
will be included, as appropriate.
- Support pagination links of
None
for collections and to-many relationships. - Treat an empty
include
query parameter as an empty list of relationship paths. This was previously silently treated as an empty relationship path, though invalid. json-api/json-api#1530
- Manage query parameters for top-level self and pagination links. This can be a significant change for applications that deal with query parameters themselves. json-api/json-api#1502
- Fix generation of links for a relationship to correctly deal with
collection-oriented query parameters (
filter
,page
,sort
). - Validate relationship paths passed to the
include
query parameter. - Change constructor for
Context
object to accept both the Flask application and request objects, and update call sites to de-proxy those before passing them in. This (slightly) improves the resilience of the constructed context to be less dependent on the source thread. - Change constructor signature for
Link
object to accept ameta
parameter instead of assembling keyword parameters into the dictionary for arbitrary metadata. This will allow additional future flexibility for parameters with more specific interpretation.
- Added
created()
method on the context object, for use in returning a response containing a newly created resource. Similar toresource()
, it returns a 201 status code and a serialization of the created resource.
- Support explicit request to receive no fields by resource type. This reflects a recent clarification added to the JSON:API specification.
- Provide
included
in response if request includes aninclude
query parameter, even if the value is an empty list. Improves conformance with JSON:API 1.1. json-api/json-api#1230 - Adapt source object to IResource in relationship implementations.
First release, internal to Keeper Technology, LLC.