Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Unified usage of JSON:API abbreviation #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Kevin Partington <platinumazure@gmail.com>
Kieran Evans <keyz182@gmail.com>
Léo S. <leo@naeka.fr>
Luc Cary <luc.cary@gmail.com>
Mansi Dhruv <mansi.p.dhruv@gmail.com>
Matt Layman <https://www.mattlayman.com>
Michael Haselton <icereval@gmail.com>
Mohammed Ali Zubair <mazg1493@gmail.com>
Expand Down
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ any parts of the framework not mentioned in the documentation should generally b

## [Unreleased]

### Fixed

* Adjusted error messages to correctly use capitial "JSON:API" abbreviation as used in the specification.

### Changed

* Moved resolving of `included_serialzers` and `related_serializers` classes to serializer's meta class.
Expand Down Expand Up @@ -104,10 +108,10 @@ This is the last release supporting Django 1.11, Django 2.1, Django REST Framewo
### Added

* Added support for serializing nested serializers as attribute json value introducing setting `JSON_API_SERIALIZE_NESTED_SERIALIZERS_AS_ATTRIBUTE`
* Note: As keys of nested serializers are not json:api spec field names they are not inflected by format field names option.
* Added `rest_framework_json_api.serializer.Serializer` class to support initial JSON API views without models.
* Note: As keys of nested serializers are not JSON:API spec field names they are not inflected by format field names option.
* Added `rest_framework_json_api.serializer.Serializer` class to support initial JSON:API views without models.
* Note that serializers derived from this class need to define `resource_name` in their `Meta` class.
* This fix might be a **BREAKING CHANGE** if you use `rest_framework_json_api.serializers.Serializer` for non json:api spec views (usually `APIView`). You need to change those serializers classes to use `rest_framework.serializers.Serializer` instead.
* This fix might be a **BREAKING CHANGE** if you use `rest_framework_json_api.serializers.Serializer` for non JSON:API spec views (usually `APIView`). You need to change those serializers classes to use `rest_framework.serializers.Serializer` instead.

### Fixed

Expand Down Expand Up @@ -202,7 +206,7 @@ This is the last release supporting Python 2.7, Python 3.4, Django Filter 1.1, D
* Don't swallow `filter[]` params when there are several
* Fix DeprecationWarning regarding collections.abc import in Python 3.7
* Allow OPTIONS request to be used on RelationshipView
* Remove non-JSONAPI methods (PUT and TRACE) from ModelViewSet and RelationshipView.
* Remove non-JSON:API methods (PUT and TRACE) from ModelViewSet and RelationshipView.
This fix might be a **BREAKING CHANGE** if your clients are incorrectly using PUT instead of PATCH.
* Avoid validation error for missing fields on a PATCH request using polymorphic serializers

Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================
JSON API and Django Rest Framework
JSON:API and Django Rest Framework
==================================

.. image:: https://github.com/django-json-api/django-rest-framework-json-api/workflows/Tests/badge.svg
Expand All @@ -18,7 +18,7 @@ JSON API and Django Rest Framework
Overview
--------

**JSON API support for Django REST Framework**
**JSON:API support for Django REST Framework**

* Documentation: https://django-rest-framework-json-api.readthedocs.org/
* Format specification: http://jsonapi.org/format/
Expand All @@ -38,7 +38,7 @@ By default, Django REST Framework will produce a response like::
}


However, for an ``identity`` model in JSON API format the response should look
However, for an ``identity`` model in JSON:API format the response should look
like the following::

{
Expand Down Expand Up @@ -67,9 +67,9 @@ like the following::
Goals
-----

As a Django REST Framework JSON API (short DJA) we are trying to address following goals:
As a Django REST Framework JSON:API (short DJA) we are trying to address following goals:

1. Support the `JSON API`_ spec to compliance
1. Support the `JSON:API`_ spec to compliance

2. Be as compatible with `Django REST Framework`_ as possible

Expand All @@ -81,7 +81,7 @@ As a Django REST Framework JSON API (short DJA) we are trying to address followi

5. Be performant

.. _JSON API: http://jsonapi.org
.. _JSON:API: http://jsonapi.org
.. _Django REST Framework: https://www.django-rest-framework.org/

------------
Expand Down Expand Up @@ -149,7 +149,7 @@ installed and activated:

Browse to

* http://localhost:8000 for the list of available collections (in a non-JSONAPI format!),
* http://localhost:8000 for the list of available collections (in a non-JSON:API format!),
* http://localhost:8000/swagger-ui/ for a Swagger user interface to the dynamic schema view, or
* http://localhost:8000/openapi for the schema view's OpenAPI specification document.

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Reporting a Vulnerability

If you believe you've found something in Django REST Framework JSON API which has security implications, please **do not raise the issue in a public forum**.
If you believe you've found something in Django REST Framework JSON:API which has security implications, please **do not raise the issue in a public forum**.

Send a description of the issue via email to [rest-framework-jsonapi-security@googlegroups.com][security-mail]. The project maintainers will then work with you to resolve any issues where required, prior to any public disclosure.

Expand Down
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

Django REST Framework JSON API (aka DJA) should be easy to contribute to.
Django REST Framework JSON:API (aka DJA) should be easy to contribute to.
If anything is unclear about how to contribute,
please submit an issue on GitHub so that we can fix it!

Expand All @@ -11,7 +11,7 @@ if the proposed change makes sense for the project.

### Clone

To start developing on Django REST Framework JSON API you need to first clone the repository:
To start developing on Django REST Framework JSON:API you need to first clone the repository:

git clone https://github.com/django-json-api/django-rest-framework-json-api.git

Expand Down
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Django REST Framework JSON API documentation build configuration file, created by
# Django REST Framework JSON:API documentation build configuration file, created by
# sphinx-quickstart on Fri Jul 24 23:31:15 2015.
#
# This file is execfile()d with the current directory set to its
Expand Down Expand Up @@ -59,10 +59,10 @@
master_doc = "index"

# General information about the project.
project = "Django REST Framework JSON API"
project = "Django REST Framework JSON:API"
year = datetime.date.today().year
copyright = "{}, Django REST Framework JSON API contributors".format(year)
author = "Django REST Framework JSON API contributors"
copyright = "{}, Django REST Framework JSON:API contributors".format(year)
author = "Django REST Framework JSON:API contributors"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -244,8 +244,8 @@
(
master_doc,
"DjangoRESTFrameworkJSONAPI.tex",
"Django REST Framework JSON API Documentation",
"Django REST Framework JSON API contributors",
"Django REST Framework JSON:API Documentation",
"Django REST Framework JSON:API contributors",
"manual",
),
]
Expand Down Expand Up @@ -279,7 +279,7 @@
(
master_doc,
"djangorestframeworkjsonapi",
"Django REST Framework JSON API Documentation",
"Django REST Framework JSON:API Documentation",
[author],
1,
)
Expand All @@ -298,7 +298,7 @@
(
master_doc,
"DjangoRESTFrameworkJSONAPI",
"Django REST Framework JSON API Documentation",
"Django REST Framework JSON:API Documentation",
author,
"DjangoRESTFrameworkJSONAPI",
"One line description of project.",
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Getting Started

*Note: this package is named Django REST Framework JSON API to follow the naming
*Note: this package is named Django REST Framework JSON:API to follow the naming
convention of other Django REST Framework packages. Since that's quite a bit
to say or type this package will be referred to as DJA elsewhere in these docs.*

Expand All @@ -20,7 +20,7 @@ By default, Django REST Framework produces a response like:
```


However, for the same `identity` model in JSON API format the response should look
However, for the same `identity` model in JSON:API format the response should look
like the following:
``` js
{
Expand Down Expand Up @@ -97,7 +97,7 @@ and add `rest_framework_json_api` to your `INSTALLED_APPS` setting below `rest_f


Browse to
* [http://localhost:8000](http://localhost:8000) for the list of available collections (in a non-JSONAPI format!),
* [http://localhost:8000](http://localhost:8000) for the list of available collections (in a non-JSON:API format!),
* [http://localhost:8000/swagger-ui/](http://localhost:8000/swagger-ui/) for a Swagger user interface to the dynamic schema view, or
* [http://localhost:8000/openapi](http://localhost:8000/openapi) for the schema view's OpenAPI specification document.

Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. Django REST Framework JSON API documentation master file, created by
.. Django REST Framework JSON:API documentation master file, created by
sphinx-quickstart on Fri Jul 24 23:31:15 2015.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to Django REST Framework JSON API
Welcome to Django REST Framework JSON:API
==========================================================

Contents:
Expand Down
12 changes: 5 additions & 7 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ class MyViewset(ModelViewSet):
### Exception handling

For the `exception_handler` class, if the optional `JSON_API_UNIFORM_EXCEPTIONS` is set to True,
all exceptions will respond with the JSON API [error format](http://jsonapi.org/format/#error-objects).
all exceptions will respond with the JSON:API [error format](http://jsonapi.org/format/#error-objects).

When `JSON_API_UNIFORM_EXCEPTIONS` is False (the default), non-JSON API views will respond
When `JSON_API_UNIFORM_EXCEPTIONS` is False (the default), non-JSON:API views will respond
with the normal DRF error format.

### Performance Testing
Expand Down Expand Up @@ -312,8 +312,7 @@ multiple endpoints. Setting the `resource_name` on views may result in a differe

### Inflecting object and relation keys

This package includes the ability (off by default) to automatically convert [json
api field names](http://jsonapi.org/format/#document-resource-object-fields) of requests and responses from the python/rest_framework's preferred underscore to
This package includes the ability (off by default) to automatically convert [JSON:API field names](http://jsonapi.org/format/#document-resource-object-fields) of requests and responses from the python/rest_framework's preferred underscore to
a format of your choice. To hook this up include the following setting in your
project settings:

Expand Down Expand Up @@ -524,8 +523,7 @@ The relationship name is formatted by the `JSON_API_FORMAT_FIELD_NAMES` setting,

#### ResourceRelatedField

Because of the additional structure needed to represent relationships in JSON
API, this package provides the `ResourceRelatedField` for serializers, which
Because of the additional structure needed to represent relationships in JSON:API, this package provides the `ResourceRelatedField` for serializers, which
works similarly to `PrimaryKeyRelatedField`. By default,
`rest_framework_json_api.serializers.ModelSerializer` will use this for
related fields automatically. It can be instantiated explicitly as in the
Expand Down Expand Up @@ -896,7 +894,7 @@ Related links will be created automatically when using the Relationship View.

### Included

JSON API can include additional resources in a single network request.
JSON:API can include additional resources in a single network request.
The specification refers to this feature as
[Compound Documents](http://jsonapi.org/format/#document-compound-documents).
Compound Documents can reduce the number of network requests
Expand Down
2 changes: 1 addition & 1 deletion example/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_sort_underscore(self):

def test_sort_related(self):
"""
test sort via related field using jsonapi path `.` and django orm `__` notation.
test sort via related field using JSON:API path `.` and django orm `__` notation.
ORM relations must be predefined in the View's .ordering_fields attr
"""
for datum in ("blog__id", "blog.id"):
Expand Down
2 changes: 1 addition & 1 deletion example/tests/test_generic_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_ember_expected_renderer(self):

def test_default_validation_exceptions(self):
"""
Default validation exceptions should conform to json api spec
Default validation exceptions should conform to JSON:API spec
"""
expected = {
"errors": [
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The base set of requirements for Django REST framework JSON API is actually
# The base set of requirements for Django REST framework JSON:API is actually
# fairly small, but for the purposes of development and testing
# there are a number of packages that are useful to install.

Expand Down
6 changes: 3 additions & 3 deletions rest_framework_json_api/django_filters/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DjangoFilterBackend(DjangoFilterBackend):
"""
A Django-style ORM filter implementation, using `django-filter`.
This is not part of the jsonapi standard per-se, other than the requirement
This is not part of the JSON:API standard per-se, other than the requirement
to use the `filter` keyword: This is an optional implementation of style of
filtering in which each filter is an ORM expression as implemented by
DjangoFilterBackend and seems to be in alignment with an interpretation of
Expand Down Expand Up @@ -50,7 +50,7 @@ class DjangoFilterBackend(DjangoFilterBackend):
the name of the query parameter for searching to make sure it doesn't conflict
with a field name defined in the filterset.
The recommended value is: `search_param="filter[search]"` but just make sure it's
`filter[<something>]` to comply with the jsonapi spec requirement to use the filter
`filter[<something>]` to comply with the JSON:API spec requirement to use the filter
keyword. The default is "search" unless overriden but it's used here just to make sure
we don't complain about it being an invalid filter.
"""
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_filterset_kwargs(self, request, queryset, view):
raise ValidationError(
"missing value for query parameter {}".format(qp)
)
# convert jsonapi relationship path to Django ORM's __ notation
# convert JSON:API relationship path to Django ORM's __ notation
key = m.groupdict()["assoc"].replace(".", "__")
key = undo_format_field_name(key)
data.setlist(key, val)
Expand Down
6 changes: 3 additions & 3 deletions rest_framework_json_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def exception_handler(exc, context):
if not response:
return response

# Use regular DRF format if not rendered by DRF JSON API and not uniform
# Use regular DRF format if not rendered by DRF JSON:API and not uniform
is_json_api_view = rendered_with_json_api(context["view"])
is_uniform = json_api_settings.UNIFORM_EXCEPTIONS
if not is_json_api_view and not is_uniform:
return response

# Convert to DRF JSON API error format
# Convert to DRF JSON:API error format
response = utils.format_drf_errors(response, context, exc)

# Add top-level 'errors' object when not rendered by DRF JSON API
# Add top-level 'errors' object when not rendered by DRF JSON:API
if not is_json_api_view:
response.data = utils.format_errors(response.data)

Expand Down
2 changes: 1 addition & 1 deletion rest_framework_json_api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def validate_query_params(self, request):
:raises ValidationError: if not.
"""
# TODO: For jsonapi error object conformance, must set jsonapi errors "parameter" for
# TODO: For JSON:API error object conformance, must set JSON:API errors "parameter" for
# the ValidationError. This requires extending DRF/DJA Exceptions.
for qp in request.query_params.keys():
m = self.query_regex.match(qp)
Expand Down
2 changes: 1 addition & 1 deletion rest_framework_json_api/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class JsonApiPageNumberPagination(PageNumberPagination):
"""
A json-api compatible pagination format.
A JSON:API compatible pagination format.
"""

page_query_param = "page[number]"
Expand Down
10 changes: 5 additions & 5 deletions rest_framework_json_api/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JSONParser(parsers.JSONParser):
Similar to `JSONRenderer`, the `JSONParser` you may override the following methods if you
need highly custom parsing control.

A JSON API client will send a payload that looks like this:
A JSON:API client will send a payload that looks like this:

.. code:: json

Expand Down Expand Up @@ -87,7 +87,7 @@ def parse(self, stream, media_type=None, parser_context=None):
from rest_framework_json_api.views import RelationshipView

if isinstance(view, RelationshipView):
# We skip parsing the object as JSONAPI Resource Identifier Object and not a regular
# We skip parsing the object as JSON:API Resource Identifier Object and not a regular
# Resource Object
if isinstance(data, list):
for resource_identifier_object in data:
Expand All @@ -96,12 +96,12 @@ def parse(self, stream, media_type=None, parser_context=None):
and resource_identifier_object.get("type")
):
raise ParseError(
"Received data contains one or more malformed JSONAPI "
"Received data contains one or more malformed JSON:API "
"Resource Identifier Object(s)"
)
elif not (data.get("id") and data.get("type")):
raise ParseError(
"Received data is not a valid JSONAPI Resource Identifier Object"
"Received data is not a valid JSON:API Resource Identifier Object"
)

return data
Expand All @@ -111,7 +111,7 @@ def parse(self, stream, media_type=None, parser_context=None):
# Sanity check
if not isinstance(data, dict):
raise ParseError(
"Received data is not a valid JSONAPI Resource Identifier Object"
"Received data is not a valid JSON:API Resource Identifier Object"
)

# Check for inconsistencies
Expand Down
Loading