Skip to content

[WIP] Merge in features from DRF core #461

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

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2eeaddb
Initial migration to DRF SchemaView
kevin-brown Sep 20, 2019
00c6ab3
Remove leading . from formats
kevin-brown Sep 20, 2019
aaafb2d
Switch to using DRF JsonOpenAPIRenderer for openapi format
kevin-brown Sep 20, 2019
e2dee4b
Swap `SwaggerYAMLRenderer` with DRF one
kevin-brown Sep 20, 2019
bdb5b5c
Special case UI rendering instead of everything else
kevin-brown Sep 20, 2019
9b2d878
Migrate errors to built-in DRF exception handling
kevin-brown Sep 20, 2019
5c302c7
Switch `SwaggerJSONRenderer` to use DRF renderer
kevin-brown Sep 20, 2019
d73dd2a
Move validation to SchemaView
kevin-brown Sep 20, 2019
b112ed5
Remove unused `_SpecRenderer`
kevin-brown Sep 20, 2019
19a24eb
Remove calls to codecs in management command
kevin-brown Sep 20, 2019
0bf3993
Migrate validation out to helper method
kevin-brown Sep 20, 2019
386856b
Removed OpenAPICodecYaml from tests
kevin-brown Sep 20, 2019
eea6c38
Removed OpenAPICodeYaml in favor of yaml_sane_dump
kevin-brown Sep 20, 2019
0a8ac96
Remove OpenAPICodecJson from tests
kevin-brown Sep 20, 2019
036fe7a
Remove OpenAPICodeJson in favor of json.dumps
kevin-brown Sep 20, 2019
9de5e99
Stop calling `.with_validators` on renderers
kevin-brown Sep 20, 2019
476a217
Removed internal _OpenAPICodec
kevin-brown Sep 20, 2019
87be3e3
Remove unused imports
kevin-brown Sep 26, 2019
ce5738d
Backport OpenAPIRenderers from DRF 3.10
kevin-brown Sep 26, 2019
f45dd63
Add docs exclusion for APIException
kevin-brown Sep 26, 2019
b98a8e9
Fix Python 2.7 incompatibility
kevin-brown Sep 26, 2019
838d3df
Fix sphinx error
kevin-brown Oct 3, 2019
098f159
Fix linting issues
kevin-brown Oct 3, 2019
9135fa2
Fix sphinx errors
kevin-brown Oct 3, 2019
c83b2de
Fix more sphinx errors
kevin-brown Oct 3, 2019
569ef67
Fix more sphinx errors
kevin-brown Oct 3, 2019
54a4911
Completely remove no-op middleware
kevin-brown Oct 4, 2019
2d83c57
Fix union type hints in Python 3.5.0 - 3.5.2
kevin-brown Oct 4, 2019
0e54993
Subclass OpenAPISchemaGenerator from DRF SchemaGenerator
kevin-brown Oct 4, 2019
f916115
Fixed Python 2.7 compat
kevin-brown Oct 4, 2019
434f447
Add back version assignment
kevin-brown Oct 4, 2019
b49d82f
Remove overridden coerce_path
kevin-brown Oct 4, 2019
949a6a6
Remove unneeded overrides
kevin-brown Oct 4, 2019
e4fbbfb
Remove ignored_endpoints parameter
kevin-brown Oct 4, 2019
08d7f73
Switch to using DRF is_simple_callable
kevin-brown Oct 4, 2019
755d4f4
Fix Sphinx build error
kevin-brown Oct 4, 2019
6056e95
Fix isort errors
kevin-brown Oct 4, 2019
9cdafa8
Fix next sphinx error
kevin-brown Oct 4, 2019
b78b3a6
Fix linting errors
kevin-brown Oct 4, 2019
00f8838
Add utf-8 support for generated formats
Jan 14, 2021
e6d0528
Merge branch 'master' into utf8-support
JoelLefkowitz Sep 22, 2021
6670052
Allow specifying response as a reference
vmax Nov 28, 2021
e6c1aad
[readme] Fix missing re_path import
damien-ramelet Feb 15, 2022
0c14a4f
fix map source mapping
PetrDlouhy Feb 22, 2022
ab7f37f
Remove universal wheel, python 2 is unsupported
gopackgo90 Mar 11, 2022
fc4d6a1
Merge pull request #778 from PetrDlouhy/master
JoelLefkowitz Jul 14, 2022
3f01252
Merge pull request #773 from damien-devpy/missing_import_readme
JoelLefkowitz Jul 14, 2022
55d2805
Inline allow_unicode parameter
JoelLefkowitz Jul 14, 2022
113be08
Merge pull request #692 from ProstoMaxim/utf8-support
JoelLefkowitz Jul 14, 2022
850ccf5
Update changelog
JoelLefkowitz Jul 14, 2022
8bc55e8
Update changelog typos
JoelLefkowitz Jul 14, 2022
78720c7
Merge pull request #782 from gopackgo90/patch-1
JoelLefkowitz Jul 15, 2022
f5f9b2a
Add cspell
JoelLefkowitz Jul 15, 2022
58d0cdf
Fix old spelling errors
JoelLefkowitz Jul 15, 2022
a577536
Add ref_name to UserSerializer after removing suffix typo
JoelLefkowitz Jul 15, 2022
1b03e72
Merge pull request #796 from axnsan12/cspell
JoelLefkowitz Jul 15, 2022
6745ddb
Merge pull request #757 from oppgjorskontoret/allow-inserting-arbitra…
JoelLefkowitz Jul 17, 2022
5068449
Merge branch '1.21.x' into pr/461
JoelLefkowitz Jul 17, 2022
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
176 changes: 176 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"language": "en",
"ignorePaths": [
"./app.json",
".gitignore",
"*.coverage",
"*.min.js",
"**/__pycache__/**",
"**/*.egg-info/**",
"**/*.git/**",
"**/build/**",
"**/coverage/**",
"**/dist/**",
"**/migrations/**",
"**/swagger-ui-dist/**",
"**/venv/**"
],
"dictionaries": [
"css",
"django",
"fonts",
"local",
"misc",
"python",
"softwareTerms"
],
"words": [
"addopts",
"apiview",
"askar",
"auths",
"authtoken",
"autoclass",
"autodata",
"automodule",
"avenir",
"barebones",
"basepath",
"beaugunderson",
"blueyed",
"builddir",
"bysource",
"cacheable",
"callabale",
"camelize",
"camelized",
"classdoc",
"codecov",
"codegen",
"coreapi",
"coreschema",
"corsheaders",
"coveragerc",
"cristi",
"cristian",
"cschema",
"csrfmiddlewaretoken",
"csrftoken",
"dascalescu",
"datadiff",
"deauth",
"deauthorize",
"deprecated",
"djangorestframework",
"djmaster",
"docstrings",
"documentclass",
"elnappo",
"envlist",
"eryk",
"exitfirst",
"extrahead",
"figwidth",
"filterset",
"formop",
"genindex",
"getdefault",
"ghuser",
"gunicorn",
"herokuapp",
"hirokawa",
"howto",
"htbp",
"htmlhelp",
"immutablehash",
"indentless",
"initkwargs",
"joellefkowitz",
"jsons",
"keepdb",
"keyframeprefix",
"letterpaper",
"levelname",
"linenos",
"maxdepth",
"minversion",
"modindex",
"monokai",
"myparent",
"napierała",
"nbsp",
"noscm",
"npmignore",
"odict",
"omap",
"paginators",
"papersize",
"passwordadmin",
"plugable",
"pointsize",
"popd",
"posargs",
"preauth",
"preauthorize",
"prepended",
"proxied",
"psycopg",
"pushd",
"putenv",
"pythonpath",
"pytz",
"qinsq",
"quickstart",
"rebilly",
"redoc",
"referenceable",
"reftest",
"refuri",
"regexes",
"representer",
"rsichny",
"rtype",
"ruamel",
"scrollbars",
"searchbox",
"serializers",
"setuptools",
"sidemenu",
"sourcedir",
"sphinxbuild",
"sphinxopts",
"sphinxproj",
"staticfiles",
"subclassing",
"swaggerapi",
"tenerowicz",
"testenv",
"testproj",
"therefromhere",
"toctree",
"undoc",
"unencrypted",
"uritemplate",
"urlconf",
"urlconfs",
"urlpatterns",
"versionadded",
"versionchanged",
"versionmodified",
"viewcode",
"viewset",
"viewsets",
"vigrond",
"vschema",
"whitenoise",
"wsgi",
"xdist",
"yasg",
"yasgdoc",
"yetanother",
"yetanothers",
"yourapp",
"yusupov",
"zbyszek"
]
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ You want to contribute some code? Great! Here are a few steps to get you started

#. **Update documentation**

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

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

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

******************
Maintainer's notes
Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ In ``urls.py``:
.. code:: python

...
from django.urls import re_path
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
Expand Down Expand Up @@ -189,9 +190,7 @@ b. ``SchemaView`` options
- :python:`SchemaView.with_ui(renderer, cache_timeout, cache_kwargs)` - get a view instance using the
specified UI renderer; one of ``swagger``, ``redoc``
- :python:`SchemaView.without_ui(cache_timeout, cache_kwargs)` - get a view instance with no UI renderer;
same as ``as_cached_view`` with no kwargs
- :python:`SchemaView.as_cached_view(cache_timeout, cache_kwargs, **initkwargs)` - same as ``as_view``,
but with optional caching
same as ``as_view`` with no kwargs
- you can, of course, call :python:`as_view` as usual

All of the first 3 methods take two optional arguments, ``cache_timeout`` and ``cache_kwargs``; if present,
Expand Down
1 change: 1 addition & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "!layout.html" %}
{% block extrahead %}
<!-- cspell:disable-next-line -->
<meta name="google-site-verification" content="saewLzcrUS1lAAgNVIikKWc3DUbFcE-TWtpyw3AW8CA" />
{% endblock %}
35 changes: 26 additions & 9 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ Changelog
#########


**********
**1.21.0**
**********

*Release date: Jul 14, 2022*

- **IMPROVED:** Add utf-8 support to yaml loaders (:pr:`692`)

**********
**1.20.3**
**********

*Release date: Jul 14, 2022*

- **FIXED:** Source mapping in ``redoc.min.js`` (:pr:`778`)
- **FIXED:** Publish action tag pattern in ``publish.yml`` (:pr:`794`)

**********
**1.20.0**
**********
Expand Down Expand Up @@ -87,7 +104,7 @@ and the problems it has caused.
- **IMPROVED:** updated ``swagger-ui`` to version 3.22.0
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-rc.4
- **FIXED:** ``ListModelMixin`` will now always be treated as a list view (:issue:`306`)
- **FIXED:** non-primtive values in field ``choices`` will now be handled properly (:issue:`340`)
- **FIXED:** non-primitive values in field ``choices`` will now be handled properly (:issue:`340`)

**********
**1.14.0**
Expand Down Expand Up @@ -133,7 +150,7 @@ and the problems it has caused.

- **ADDED:** ``get_security_definitions`` and ``get_security_requirements`` hooks to ``OpenAPISchemaGenerator``
- **ADDED:** added ``get_summary_and_description`` and ``split_summary_from_description`` extension points to
``SwaggerAutoSchema`` to allow for better customisation
``SwaggerAutoSchema`` to allow for better customization
- **IMPROVED:** updated ``swagger-ui`` to version 3.20.4
- **IMPROVED:** paginator ``next`` and ``previous`` fields are now marked as ``x-nullable`` (:issue:`263`)
- **IMPROVED:** added the ``tags`` argument to ``swagger_auto_schema`` (:pr:`259`)
Expand All @@ -144,7 +161,7 @@ and the problems it has caused.
- **FIXED:** fixed handling of lazy objects in user-supplied values
- **FIXED:** ``read_only`` serializer fields will be correctly ignored when generating form parameters (:issue:`261`)
- **FIXED:** fixed incorrect return type from ``UIRenderer`` (:pr:`268`)
- **FIXED:** fixed incosistent ordering of global ``securityDefinitions`` and ``security`` objects
- **FIXED:** fixed inconsistent ordering of global ``securityDefinitions`` and ``security`` objects
- **DEPRECATED:** the ``get_summary`` and ``get_description`` extension points have been deprecated in favor of the
new ``get_summary_and_description``, and will be removed in a future release

Expand All @@ -170,7 +187,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a
- **FIXED:** ``minLength`` and ``maxLength`` will now also work for ``ListSerializer`` in addition to ``ListField``
- **FIXED:** ``MultipleChoiceField`` will now use the ``multi`` ``collectionFormat`` where appropriate (:issue:`257`)
- **FIXED:** the ``format``, ``pattern``, ``enum``, ``min_length`` and ``max_length`` attributes of
``coreschema.Schema`` will now be persited into the converted ``openapi.Parameter`` (:issue:`212`, :pr:`233`)
``coreschema.Schema`` will now be persisted into the converted ``openapi.Parameter`` (:issue:`212`, :pr:`233`)

**********
**1.11.0**
Expand Down Expand Up @@ -281,7 +298,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a
- **ADDED:** added ``DEFAULT_GENERATOR_CLASS`` setting and ``--generator-class`` argument to the ``generate_swagger``
management command (:issue:`140`)
- **FIXED:** fixed wrongly required ``'count'`` response field on ``CursorPagination`` (:issue:`141`)
- **FIXED:** fixed some cases where ``swagger_schema_fields`` would not be handlded (:pr:`142`)
- **FIXED:** fixed some cases where ``swagger_schema_fields`` would not be handled (:pr:`142`)
- **FIXED:** fixed crash when encountering ``coreapi.Fields``\ s without a ``schema`` (:issue:`143`)

*********
Expand Down Expand Up @@ -321,7 +338,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a

*Release date: May 12, 2018*

- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behavior
- **FIXED:** ordering of ``SECURITY_REQUIREMENTS`` and ``SECURITY_DEFINITIONS`` is now stable

*********
Expand Down Expand Up @@ -531,7 +548,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a
- **IMPROVED:** removed inline scripts and styles from bundled HTML templates to increase CSP compatibility
- **IMPROVED:** improved validation errors and added more assertion sanity checks (:issue:`37`, :issue:`40`)
- **IMPROVED:** improved handling of NamespaceVersioning by excluding endpoints of differing versions
(i.e. when accesing the schema view for v1, v2 endpoints will not be included in swagger)
(i.e. when accessing the schema view for v1, v2 endpoints will not be included in swagger)

*********
**1.1.3**
Expand Down Expand Up @@ -560,7 +577,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a

- **ADDED:** :ref:`generate_swagger management command <management-command>`
(:issue:`29`, :pr:`31`, thanks to :ghuser:`beaugunderson`)
- **FIXED:** fixed improper generation of ``\Z`` regex tokens - will now be repalced by ``$``
- **FIXED:** fixed improper generation of ``\Z`` regex tokens - will now be replaced by ``$``

*********
**1.1.0**
Expand All @@ -570,7 +587,7 @@ case). Building without ``.git`` or without ``setuptools-scm`` will result in a

- **ADDED:** added support for APIs versioned with ``URLPathVersioning`` or ``NamespaceVersioning``
- **ADDED:** added ability to recursively customize schema generation
:ref:`using pluggable inspector classes <custom-spec-inspectors>`
:ref:`using plugable inspector classes <custom-spec-inspectors>`
- **ADDED:** added ``operation_id`` parameter to :func:`@swagger_auto_schema <.swagger_auto_schema>`
- **ADDED:** integration with `djangorestframework-camel-case
<https://github.com/vbabiy/djangorestframework-camel-case>`_ (:issue:`28`)
Expand Down
9 changes: 6 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,17 @@
('py:class', 'collections.OrderedDict'),

('py:class', 'ruamel.yaml.dumper.SafeDumper'),
('py:class', 'rest_framework.exceptions.APIException'),
('py:class', 'rest_framework.serializers.Serializer'),
('py:class', 'rest_framework.renderers.BaseRenderer'),
('py:class', 'rest_framework.renderers.JSONOpenAPIRenderer'),
('py:class', 'rest_framework.renderers.OpenAPIRenderer'),
('py:class', 'rest_framework.parsers.BaseParser'),
('py:class', 'rest_framework.schemas.coreapi.SchemaGenerator'),
('py:class', 'rest_framework.schemas.generators.EndpointEnumerator'),
('py:class', 'rest_framework.schemas.views.SchemaView'),
('py:class', 'rest_framework.views.APIView'),

('py:class', 'OpenAPICodecYaml'),
('py:class', 'OpenAPICodecJson'),
('py:class', 'OpenAPISchemaGenerator'),

('py:class', 'coreapi.Field'),
Expand All @@ -213,7 +216,7 @@
# for some reason needs the sources dir to be in the path in order for viewcode to work
sys.path.insert(0, os.path.abspath('../src'))

# activate the Django testproj to be able to succesfully import drf_yasg
# activate the Django testproj to be able to successfully import drf_yasg
sys.path.insert(0, os.path.abspath('../testproj'))
os.putenv('DJANGO_SETTINGS_MODULE', 'testproj.settings.local')

Expand Down
4 changes: 2 additions & 2 deletions docs/custom_spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ A second example, of a :class:`~.inspectors.FieldInspector` that removes the ``t
- in the output swagger document there is a ``definitions`` section containing :class:`.Schema` objects for all
models
- every usage of a model refers to that single :class:`.Schema` object - for example, in the ArticleViewSet
above, all requests and responses containg an ``Article`` model would refer to the same schema definition by a
above, all requests and responses containing an ``Article`` model would refer to the same schema definition by a
``'$ref': '#/definitions/Article'``

This is implemented by only generating **one** :class:`.Schema` object for every serializer **class** encountered.
Expand All @@ -433,7 +433,7 @@ A second example, of a :class:`~.inspectors.FieldInspector` that removes the ``t
for a given serializer.

**IMPORTANT:** nested fields on ``ModelSerializer``\ s that are generated from model ``ForeignKeys`` will always be
output by value. If you want the by-reference behaviour you have to explictly set the serializer class of nested
output by value. If you want the by-reference behavior you have to explicitly set the serializer class of nested
fields instead of letting ``ModelSerializer`` generate one automatically; for example:

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion docs/custom_ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The web UI can be customized using the settings available in :ref:`swagger-ui-se
You can also extend one of the `drf-yasg/swagger-ui.html`_ or `drf-yasg/redoc.html`_ templates that are used for
rendering. See the template source code (linked above) for a complete list of customizable blocks.

The ``swagger-ui`` view has some quite involed JavaScript hooks used for some functionality, which you might also
The ``swagger-ui`` view has some quite involved JavaScript hooks used for some functionality, which you might also
want to review at `drf-yasg/swagger-ui-init.js`_.

.. _drf-yasg/swagger-ui.html: https://github.com/axnsan12/drf-yasg/blob/master/src/drf_yasg/templates/drf-yasg/swagger-ui.html
Expand Down
8 changes: 0 additions & 8 deletions docs/drf_yasg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ drf\_yasg\.inspectors
:undoc-members:
:show-inheritance:

drf\_yasg\.middleware
-------------------------------

.. automodule:: drf_yasg.middleware
:members:
:undoc-members:
:show-inheritance:

drf\_yasg\.openapi
----------------------------

Expand Down
Loading