Skip to content

Commit e9ab38d

Browse files
authored
Merge branch 'main' into fix/empty-data-in-response-using-rest-action
2 parents 7b2832c + 21493c1 commit e9ab38d

20 files changed

+231
-96
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ jobs:
3030
- name: Run tox targets for ${{ matrix.python-version }}
3131
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)
3232
- name: Upload coverage report
33-
uses: codecov/codecov-action@v2
33+
uses: codecov/codecov-action@v4
3434
with:
35+
token: ${{ secrets.CODECOV_TOKEN }}
3536
env_vars: PYTHON
3637
check:
3738
name: Run check

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ any parts of the framework not mentioned in the documentation should generally b
1212

1313
### Added
1414

15+
* Added `429 Too Many Requests` as a possible error response in the OpenAPI schema.
16+
17+
## [7.0.0] - 2024-05-02
18+
19+
### Added
20+
1521
* Added support for Python 3.12
1622
* Added support for Django 5.0
1723
* Added support for Django REST framework 3.15
@@ -23,6 +29,8 @@ any parts of the framework not mentioned in the documentation should generally b
2329
* Avoided that an empty attributes dict is rendered in case serializer does not
2430
provide any attribute fields.
2531
* Avoided shadowing of exception when rendering errors (regression since 4.3.0).
32+
* Ensured that sparse fields only applies when rendering, not when parsing.
33+
* Adjusted that sparse fields properly removes meta fields when not defined.
2634

2735
### Removed
2836

example/tests/__snapshots__/test_openapi.ambr

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
}
6969
},
7070
"description": "[Resource does not exist](https://jsonapi.org/format/#crud-deleting-responses-404)"
71+
},
72+
"429": {
73+
"content": {
74+
"application/vnd.api+json": {
75+
"schema": {
76+
"$ref": "#/components/schemas/failure"
77+
}
78+
}
79+
},
80+
"description": "too many requests"
7181
}
7282
},
7383
"tags": [
@@ -264,6 +274,16 @@
264274
}
265275
},
266276
"description": "[Conflict]([Conflict](https://jsonapi.org/format/#crud-updating-responses-409)"
277+
},
278+
"429": {
279+
"content": {
280+
"application/vnd.api+json": {
281+
"schema": {
282+
"$ref": "#/components/schemas/failure"
283+
}
284+
}
285+
},
286+
"description": "too many requests"
267287
}
268288
},
269289
"tags": [
@@ -399,6 +419,16 @@
399419
}
400420
},
401421
"description": "not found"
422+
},
423+
"429": {
424+
"content": {
425+
"application/vnd.api+json": {
426+
"schema": {
427+
"$ref": "#/components/schemas/failure"
428+
}
429+
}
430+
},
431+
"description": "too many requests"
402432
}
403433
},
404434
"tags": [
@@ -546,6 +576,16 @@
546576
}
547577
},
548578
"description": "not found"
579+
},
580+
"429": {
581+
"content": {
582+
"application/vnd.api+json": {
583+
"schema": {
584+
"$ref": "#/components/schemas/failure"
585+
}
586+
}
587+
},
588+
"description": "too many requests"
549589
}
550590
},
551591
"tags": [
@@ -754,6 +794,16 @@
754794
}
755795
},
756796
"description": "[Conflict](https://jsonapi.org/format/#crud-creating-responses-409)"
797+
},
798+
"429": {
799+
"content": {
800+
"application/vnd.api+json": {
801+
"schema": {
802+
"$ref": "#/components/schemas/failure"
803+
}
804+
}
805+
},
806+
"description": "too many requests"
757807
}
758808
},
759809
"tags": [
@@ -1341,6 +1391,16 @@
13411391
}
13421392
},
13431393
"description": "not found"
1394+
},
1395+
"429": {
1396+
"content": {
1397+
"application/vnd.api+json": {
1398+
"schema": {
1399+
"$ref": "#/components/schemas/failure"
1400+
}
1401+
}
1402+
},
1403+
"description": "too many requests"
13441404
}
13451405
},
13461406
"tags": [

example/tests/integration/test_non_paginated_responses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_multiple_entries_no_pagination(multiple_entries, client):
1414
expected = {
1515
"data": [
1616
{
17-
"type": "posts",
17+
"type": "entries",
1818
"id": "1",
1919
"attributes": {
2020
"headline": multiple_entries[0].headline,
@@ -70,7 +70,7 @@ def test_multiple_entries_no_pagination(multiple_entries, client):
7070
},
7171
},
7272
{
73-
"type": "posts",
73+
"type": "entries",
7474
"id": "2",
7575
"attributes": {
7676
"headline": multiple_entries[1].headline,

example/tests/integration/test_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_pagination_with_single_entry(single_entry, client):
1414
expected = {
1515
"data": [
1616
{
17-
"type": "posts",
17+
"type": "entries",
1818
"id": "1",
1919
"attributes": {
2020
"headline": single_entry.headline,

example/tests/integration/test_sparse_fieldsets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def test_sparse_fieldset_valid_fields(client, entry):
1515
entry = data[0]
1616
assert entry["attributes"].keys() == {"headline"}
1717
assert entry["relationships"].keys() == {"blog"}
18+
assert "meta" not in entry
1819

1920

2021
@pytest.mark.parametrize(

example/tests/test_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def test_search_keywords(self):
470470
expected_result = {
471471
"data": [
472472
{
473-
"type": "posts",
473+
"type": "entries",
474474
"id": "7",
475475
"attributes": {
476476
"headline": "ANTH3868X",

example/tests/unit/test_renderer_class_methods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def test_extract_attributes():
102102
assert sorted(JSONRenderer.extract_attributes(fields, resource)) == sorted(
103103
expected
104104
), "Regular fields should be extracted"
105-
assert sorted(JSONRenderer.extract_attributes(fields, {})) == sorted(
106-
{"username": ""}
105+
assert (
106+
JSONRenderer.extract_attributes(fields, {}) == {}
107107
), "Should not extract read_only fields on empty serializer"
108108

109109

example/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ class BlogCustomViewSet(JsonApiViewSet):
126126

127127
class EntryViewSet(ModelViewSet):
128128
queryset = Entry.objects.all()
129-
resource_name = "posts"
129+
# TODO it should not be supported to overwrite resource name
130+
# of endpoints with serializers as includes and sparse fields
131+
# cannot be aware of it
132+
# resource_name = "posts"
130133

131134
def get_serializer_class(self):
132135
return EntrySerializer
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
black==24.4.0
1+
black==24.4.2
22
flake8==7.0.0
3-
flake8-bugbear==24.2.6
3+
flake8-bugbear==24.4.26
44
flake8-isort==6.1.1
55
isort==5.13.2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
recommonmark==0.7.1
2-
Sphinx==7.2.6
2+
Sphinx==7.3.7
33
sphinx_rtd_theme==2.0.0

requirements/requirements-testing.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
factory-boy==3.3.0
2-
Faker==24.9.0
3-
pytest==8.1.1
2+
Faker==25.0.1
3+
pytest==8.2.0
44
pytest-cov==5.0.0
55
pytest-django==4.8.0
66
pytest-factoryboy==2.7.0

rest_framework_json_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = "djangorestframework-jsonapi"
2-
__version__ = "6.1.0"
2+
__version__ = "7.0.0"
33
__author__ = ""
44
__license__ = "BSD"
55
__copyright__ = ""

0 commit comments

Comments
 (0)