Skip to content
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

Fix retrieving model for reverse relations #573

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1fb5515
Fix retrieving model for reverse relations
glowka Apr 11, 2020
7a99e6e
Adjust testproj migrations to oauth-toolkit v1.3+
glowka Apr 13, 2020
da5f800
Fix lint error
glowka Apr 13, 2020
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
d25bc17
Merge branch '1.21.x' into pr/573
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
1 change: 1 addition & 0 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
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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,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
6 changes: 3 additions & 3 deletions docs/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The second step is specifying, for each endpoint, which authentication mechanism
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object for details.

By default, a top-level `security` that accepts any one of the declared security definitions is generated.
For the example above, that would be :code:`[{'Basic': []}, {'Bearer': []}]`. This can be overriden using the
For the example above, that would be :code:`[{'Basic': []}, {'Bearer': []}]`. This can be overridden using the
:ref:`SECURITY_REQUIREMENTS <security-definitions-settings>` setting.

Operation-level overrides can be added using the ``security`` parameter of
Expand All @@ -53,15 +53,15 @@ Operation-level overrides can be added using the ``security`` parameter of

It is possible to configure ``swagger-ui`` to authenticate against your (or a third party) OAuth2 service when sending
"Try it out" requests. This client-side configuration does not remove the requirement of a spec-side
:ref:`security definiiton <security-definitions-settings>`, but merely allows you to test OAuth2 APIs using
:ref:`security definition <security-definitions-settings>`, but merely allows you to test OAuth2 APIs using
``swagger-ui`` as a client.

**DISCLAIMER**: this setup is very poorly tested as I do not currently implement OAuth in any of my projects. All
contributions relating to documentation, bugs, mistakes or anything else are welcome as an issue or pull request. The
settings described below were added as a result of discussion in issue :issue:`53`.

The settings of interest can be found on the :ref:`settings page <oauth2-settings>`. Configuration options are similar
to most OAuth client setups like web or mobile applications. Reading the relevant ``swagger-ui`` docmentation linked
to most OAuth client setups like web or mobile applications. Reading the relevant ``swagger-ui`` documentation linked
will also probably help.


Expand Down
Loading