Skip to content

Commit 78031f0

Browse files
Joel LefkowitzWasinThsumit4613CoreJakrectra
authored
Advance master to release 1.21.7 (#815)
* Add sample code to handle Base64 fields in drf-extra-fields project * Fix format for .rst * Update answer to the easier version as suggested in Hipo/drf-extra-fields#66 (comment) * update readme.rst `permission_classes` expects tuple but list was provided * url from DEFAULT_API_URL now works fix a bug: url from swagger_settings.DEFAULT_API_URL is not working * Check for allow_null attribute * Add utf-8 support for generated formats * Added `many` support to example code. * serialize pytz object as a string * simplify if condition * handle errors rendering with TemplateHTMLRenderer This change fixes an `OPTIONS` request to the API page which will return a successful response, but the `TemplateHTMLRender` will not be prepared to render it since there is no template name provided in either the view or response [1]. [1]: https://github.com/encode/django-rest-framework/blob/f0a5b958a134e8cd94e3ef3263e8fa623ac9b82f/rest_framework/renderers.py#L178-L189 * Allow specifying response as a reference * [readme] Fix missing re_path import * fix map source mapping * Remove universal wheel, python 2 is unsupported * Inline allow_unicode parameter * Update changelog * Update changelog typos * Add cspell * Fix old spelling errors * Add ref_name to UserSerializer after removing suffix typo * Set permission classes to a tuple * Update chagnelog * Add prepublish twine check * Fix action version syntax * Fix indentation in README.rst code blocks * Add twine to publish dependencies * Specify toxenv explicitly * Specify all tox targets * Add py prefix to toxenvs * Update changelog * Update changelog * Declare Django 3.2 support in README, classifiers This commit will make sure that `Django :: 3.2` will show up in the classifiers list on PyPI: https://pypi.org/project/drf-yasg/ (The magic happens because we parse the README to get supported Django): https://github.com/DavidCain/drf-yasg/blob/ee29412d3cdb311/setup.py#L36 3.2 support should already exist ================================ A closed pull request, #735, noted support for Django 3.2 in both `tox.ini`, and the README. That PR was closed in favor of #741, which edited `tox.ini` and switched to GitHub Actions. #735 (comment) This project has been testing on Django 3.2 for a long time (about a year). I think we can declare it supported it the README! * Fix `pip install` command for contributors on zsh On `zsh` (a popular shell, and the default for macOS), install fails: $ pip install -U -e .[validation] zsh: no matches found: .[validation] Quote the arguments so that `bash` or `zsh` will succeed. * Dont use NullBooleanField if drf version >= 3.14.0 * Swap back BooleanField and NullBooleanField * Update changelog * Update README to use path instead of re_path in example * Run tests with latest dependencies - Django 4.0 & 4.1 - DRF 3.13 & 3.14 - Python 3.10 * Add python 3.10 in GH actions matrix * Fix RecursiveField * Change github actions runner from ubuntu-latest to ubuntu-20.04 * Change github actions runner from ubuntu-latest to ubuntu-20.04 * Remove python 3.6 tests since swagger-spec-validator no longer supports it * Use a string literal for python versions such as "3.10" * Add python 3.10 compatibility to README.md * Update changelog * Fix: Provide enums support for schema. * Fix: Tests for Python 3.11. * Refactoring: Removed old version code. * Fix: Linting is now working. * Fix: Provide usage of Enums as dict keys. * Fix: Docs build with latest sphinx versions. * keep path parameters in their given order * Fix: Action build docs with latest tox version. * Fix: Update python version for dj-master branch. Django master branch bumped minimal python version to Python 3.10. In latest version was added check for uniq basename. * Feature: Migrate to PyYAML for yaml generator. (#845) * Feature: Migrate to PyYAML for yaml generator. Closes #833 * Chore: Update swagger ui and redoc dependencies. * Fix: Remove required coreapi dependency. (#854) * Feature: Migrate to PyYAML for yaml generator. Closes #833 * Chore: Update swagger ui and redoc dependencies. * Fix: Remove required coreapi dependency. * Update Changelog * Feature: Add ``drf_yasg.inspectors.query.DrfAPICompatInspector``. (#857) * Feature: Provide to override default renderers via settings. * Feature: Enable tests for django 4.2. * Docs: Add information how to override ``DEFAULT_SPEC_RENDERERS``. * Feature: Add ``drf_yasg.inspectors.query.DrfAPICompatInspector``. This inspector should be main and replace ``CoreAPICompatInspector`` in the future. * [fix] Fixed map source mapping (#859) * Tests: Improve test coverage 95.91% -> 98.30%. (#862) * Update Changelog * Add python3.6 to the actions matrix but exclude it from tests --------- Co-authored-by: Terry <[email protected]> Co-authored-by: Sumit Singh <[email protected]> Co-authored-by: Core-Chan <[email protected]> Co-authored-by: Krista Mae Rectra <[email protected]> Co-authored-by: mmurashov <[email protected]> Co-authored-by: Christoph Beckmann <[email protected]> Co-authored-by: MilanPecov <[email protected]> Co-authored-by: Terence D. Honles <[email protected]> Co-authored-by: Cristi Vîjdea <[email protected]> Co-authored-by: Max Vorobev <[email protected]> Co-authored-by: Damien Ramelet <[email protected]> Co-authored-by: Petr Dlouhý <[email protected]> Co-authored-by: gopackgo90 <[email protected]> Co-authored-by: David Cain <[email protected]> Co-authored-by: Amir Andohkosh <[email protected]> Co-authored-by: Nikolaos Michas <[email protected]> Co-authored-by: Ignacio Orlandini <[email protected]> Co-authored-by: Sergey Klyuykov <[email protected]> Co-authored-by: Gagan Deep <[email protected]>
1 parent 6557517 commit 78031f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4394
-417
lines changed

.cspell.json

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
{
2+
"language": "en",
3+
"ignorePaths": [
4+
"./app.json",
5+
".gitignore",
6+
"*.coverage",
7+
"*.min.js",
8+
"**/__pycache__/**",
9+
"**/*.egg-info/**",
10+
"**/*.git/**",
11+
"**/build/**",
12+
"**/coverage/**",
13+
"**/dist/**",
14+
"**/migrations/**",
15+
"**/swagger-ui-dist/**",
16+
"**/venv/**"
17+
],
18+
"dictionaries": [
19+
"css",
20+
"django",
21+
"fonts",
22+
"local",
23+
"misc",
24+
"python",
25+
"softwareTerms"
26+
],
27+
"words": [
28+
"addopts",
29+
"apiview",
30+
"askar",
31+
"auths",
32+
"authtoken",
33+
"autoclass",
34+
"autodata",
35+
"automodule",
36+
"avenir",
37+
"barebones",
38+
"basepath",
39+
"beaugunderson",
40+
"blueyed",
41+
"builddir",
42+
"bysource",
43+
"cacheable",
44+
"callabale",
45+
"camelize",
46+
"camelized",
47+
"classdoc",
48+
"codecov",
49+
"codegen",
50+
"coreapi",
51+
"coreschema",
52+
"corsheaders",
53+
"coveragerc",
54+
"cristi",
55+
"cristian",
56+
"cschema",
57+
"csrfmiddlewaretoken",
58+
"csrftoken",
59+
"dascalescu",
60+
"datadiff",
61+
"deauth",
62+
"deauthorize",
63+
"deprecated",
64+
"djangorestframework",
65+
"djmaster",
66+
"docstrings",
67+
"documentclass",
68+
"elnappo",
69+
"envlist",
70+
"eryk",
71+
"exitfirst",
72+
"extrahead",
73+
"figwidth",
74+
"filterset",
75+
"formop",
76+
"genindex",
77+
"getdefault",
78+
"ghuser",
79+
"gunicorn",
80+
"herokuapp",
81+
"hirokawa",
82+
"howto",
83+
"htbp",
84+
"htmlhelp",
85+
"immutablehash",
86+
"indentless",
87+
"initkwargs",
88+
"joellefkowitz",
89+
"jsons",
90+
"keepdb",
91+
"keyframeprefix",
92+
"letterpaper",
93+
"levelname",
94+
"linenos",
95+
"maxdepth",
96+
"minversion",
97+
"modindex",
98+
"monokai",
99+
"myparent",
100+
"napierała",
101+
"nbsp",
102+
"noscm",
103+
"npmignore",
104+
"odict",
105+
"omap",
106+
"paginators",
107+
"papersize",
108+
"passwordadmin",
109+
"plugable",
110+
"pointsize",
111+
"popd",
112+
"posargs",
113+
"preauth",
114+
"preauthorize",
115+
"prepended",
116+
"proxied",
117+
"psycopg",
118+
"pushd",
119+
"putenv",
120+
"pythonpath",
121+
"pytz",
122+
"qinsq",
123+
"quickstart",
124+
"rebilly",
125+
"redoc",
126+
"referenceable",
127+
"reftest",
128+
"refuri",
129+
"regexes",
130+
"representer",
131+
"rsichny",
132+
"rtype",
133+
"ruamel",
134+
"scrollbars",
135+
"searchbox",
136+
"serializers",
137+
"setuptools",
138+
"sidemenu",
139+
"sourcedir",
140+
"sphinxbuild",
141+
"sphinxopts",
142+
"sphinxproj",
143+
"staticfiles",
144+
"subclassing",
145+
"swaggerapi",
146+
"tenerowicz",
147+
"testenv",
148+
"testproj",
149+
"therefromhere",
150+
"toctree",
151+
"undoc",
152+
"unencrypted",
153+
"uritemplate",
154+
"urlconf",
155+
"urlconfs",
156+
"urlpatterns",
157+
"versionadded",
158+
"versionchanged",
159+
"versionmodified",
160+
"viewcode",
161+
"viewset",
162+
"viewsets",
163+
"vigrond",
164+
"vschema",
165+
"whitenoise",
166+
"wsgi",
167+
"xdist",
168+
"yasg",
169+
"yasgdoc",
170+
"yetanother",
171+
"yetanothers",
172+
"yourapp",
173+
"yusupov",
174+
"zbyszek"
175+
]
176+
}

.github/actions/install/action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Install
2+
description: Install dependencies
3+
4+
inputs:
5+
python-version:
6+
description: Python version for installing dependencies
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Checkout the source code
13+
uses: actions/checkout@v2
14+
15+
- name: Set the python version
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ inputs.python-version }}
19+
20+
- name: Set up pip package caching
21+
uses: actions/cache@v2
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
25+
restore-keys: ${{ runner.os }}-pip-
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: pip install -r requirements/ci.txt

.github/workflows/publish.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish
22

33
on:
44
push:
5-
tags:
5+
tags:
66
- "*.*.*"
77

88
jobs:
@@ -13,17 +13,21 @@ jobs:
1313
- name: Checkout the source code
1414
uses: actions/checkout@v2
1515

16-
- name: Set the python version
17-
uses: actions/setup-python@v2
18-
1916
# This is the version of python used to package the code. The unit
20-
# tests will have run against python 3.6, 3.7 etc ensuring
17+
# tests will have run against python 3.6, 3.7 etc ensuring
2118
# compatibility with those runtimes.
2219
# https://github.com/axnsan12/drf-yasg/pull/741#discussion_r713297594
20+
- name: Set the python version
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: 3.8
24+
25+
- name: Install dependencies
26+
uses: ./.github/actions/install
2327
with:
2428
python-version: 3.8
2529

26-
- name: Install pip dependencies
30+
- name: Install builders for publishing
2731
run: pip install -r requirements/publish.txt
2832

2933
- name: Build the distributions

.github/workflows/review.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,44 @@ on: [push, pull_request]
55
jobs:
66
review:
77
name: Run linters and tests
8-
runs-on: ubuntu-latest
8+
runs-on: "ubuntu-20.04"
99
strategy:
1010
matrix:
11-
python: [3.6, 3.7, 3.8, 3.9]
11+
python: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
1212

1313
steps:
14-
- name: Set up pip package caching
15-
uses: actions/cache@v2
16-
with:
17-
path: ~/.cache/pip
18-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
19-
restore-keys: ${{ runner.os }}-pip-
20-
2114
- name: Checkout the source code
2215
uses: actions/checkout@v2
2316

2417
- name: Set the python version
25-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python }}
21+
22+
- name: Install dependencies
23+
uses: ./.github/actions/install
2624
with:
2725
python-version: ${{ matrix.python }}
2826

29-
- name: Install pip dependencies
30-
run: pip install -r requirements/ci.txt
27+
- name: Run tests
28+
29+
# Python 3.6 tests have been removed since swagger-spec-validator no longer supports it.
30+
# A successful workflow run for Python 3.6 is required by the GitHub branch protection rules.
31+
if: ${{ matrix.python != 3.6 }}
32+
33+
env:
34+
PYTHON_VERSION: ${{ matrix.python }}
35+
run: tox -e $(tox -l | grep py${PYTHON_VERSION//.} | paste -sd "," -)
36+
37+
- name: Report coverage
38+
if: ${{ matrix.python == 3.9 }}
39+
run: |
40+
pip install coverage
41+
coverage report
3142
32-
- name: Run unit tests
33-
run: tox
43+
- name: Check for incompatibilities with publishing to PyPi
44+
if: ${{ matrix.python == 3.8 }}
45+
run: |
46+
pip install -r requirements/publish.txt
47+
python setup.py sdist
48+
twine check dist/*

CONTRIBUTING.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
3636
$ python -m venv venv
3737
$ source venv/bin/activate
3838
(venv) $ python -m pip install -U pip setuptools
39-
(venv) $ pip install -U -e .[validation]
39+
(venv) $ pip install -U -e '.[validation]'
4040
(venv) $ pip install -U -r requirements/dev.txt
4141
4242
#. **Make your changes and check them against the test project**
@@ -78,7 +78,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
7878
7979
#. **Update documentation**
8080

81-
If the change modifies behaviour or adds new features, you should update the documentation and ``README.rst``
81+
If the change modifies behavior or adds new features, you should update the documentation and ``README.rst``
8282
accordingly. Documentation is written in reStructuredText and built using Sphinx. You can find the sources in the
8383
``docs`` directory.
8484

@@ -96,7 +96,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
9696
#. **Your code must pass all the required CI jobs before it is merged**
9797

9898
As of now, this consists of running on the supported Python, Django, DRF version matrix (see README),
99-
and building the docs succesfully.
99+
and building the docs successfully.
100100

101101
******************
102102
Maintainer's notes

README.rst

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Generate **real** Swagger/OpenAPI 2.0 specifications from a Django Rest Framewor
1111

1212
Compatible with
1313

14-
- **Django Rest Framework**: 3.10, 3.11, 3.12
15-
- **Django**: 2.2, 3.0, 3.1
16-
- **Python**: 3.6, 3.7, 3.8, 3.9
14+
- **Django Rest Framework**: 3.10, 3.11, 3.12, 3.13, 3.14
15+
- **Django**: 2.2, 3.0, 3.1, 3.2, 4.0, 4.1
16+
- **Python**: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11
1717

1818
Only the latest patch version of each ``major.minor`` series of Python, Django and Django REST Framework is supported.
1919

@@ -132,6 +132,7 @@ In ``urls.py``:
132132
.. code:: python
133133
134134
...
135+
from django.urls import re_path
135136
from rest_framework import permissions
136137
from drf_yasg.views import get_schema_view
137138
from drf_yasg import openapi
@@ -148,13 +149,13 @@ In ``urls.py``:
148149
license=openapi.License(name="BSD License"),
149150
),
150151
public=True,
151-
permission_classes=[permissions.AllowAny],
152+
permission_classes=(permissions.AllowAny,),
152153
)
153154
154155
urlpatterns = [
155-
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
156-
re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
157-
re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
156+
path('swagger<format>/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
157+
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
158+
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
158159
...
159160
]
160161
@@ -357,3 +358,31 @@ provided out of the box - if you have ``djangorestframework-recursive`` installe
357358

358359
.. |nbsp| unicode:: 0xA0
359360
:trim:
361+
362+
drf-extra-fields
363+
=================
364+
365+
Integration with `drf-extra-fields <https://github.com/Hipo/drf-extra-fields>`_ has a problem with Base64 fields.
366+
The drf-yasg will generate Base64 file or image fields as Readonly and not required. Here is a workaround code
367+
for display the Base64 fields correctly.
368+
369+
.. code:: python
370+
371+
class PDFBase64FileField(Base64FileField):
372+
ALLOWED_TYPES = ['pdf']
373+
374+
class Meta:
375+
swagger_schema_fields = {
376+
'type': 'string',
377+
'title': 'File Content',
378+
'description': 'Content of the file base64 encoded',
379+
'read_only': False # <-- FIX
380+
}
381+
382+
def get_file_extension(self, filename, decoded_file):
383+
try:
384+
PyPDF2.PdfFileReader(io.BytesIO(decoded_file))
385+
except PyPDF2.utils.PdfReadError as e:
386+
logger.warning(e)
387+
else:
388+
return 'pdf'

0 commit comments

Comments
 (0)