Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 904895ba3c | |||
| 79adfc19be | |||
| 2965e08e39 | |||
| f2e05ee4c0 | |||
| bbc70a7e3d | |||
| ca43a7de0c | |||
| cc43bdf5cb | |||
| db86981dc1 | |||
| b37ce3227a | |||
| 8fbab88bda | |||
| 58b979f4ea | |||
| d9b6fbc1b8 | |||
| 20370d912e | |||
| 178390a9a0 | |||
| 7982f62f38 | |||
| 9fa4765121 | |||
| 544d72db0a | |||
| 696ec3a94a | |||
| e0aec3ff45 | |||
| ee7b9a0734 | |||
| 0697c415ed | |||
| 4825ec70b1 | |||
| 54ad90415d | |||
| 1184ea8b46 | |||
| 6ac58b8cf7 | |||
| d627a1bc5d | |||
| 38e884b5ea | |||
| 2ef7cfbfe3 | |||
| 58adbb8f4c | |||
| 34c7fa2b0e | |||
| 6b2ce7d0f9 | |||
| 256a052564 | |||
| cc90bc1544 | |||
| ecee6f8177 | |||
| 408b31fc4f | |||
| a4a11ad1ab | |||
| aca0c4713e | |||
| 3077195396 | |||
| 94f6ca8c89 | |||
| ae5eeeb600 | |||
| 23ebe2ff3e | |||
| 713c669e28 | |||
| 2545ae9657 | |||
| f03d9d71e9 | |||
| a993cba7aa | |||
| bfd88cbdb4 | |||
| 123a05c82c | |||
| 7065429d47 | |||
| bd727fbe88 | |||
| 698a175a1b | |||
| 5b225423ae | |||
| 209201b9a5 | |||
| ca00ed35be | |||
| 4e7fa28744 | |||
| 979ec84630 | |||
| d2dc09cb3c | |||
| 36992072ca | |||
| aa90723703 | |||
| 301511bebc | |||
| c0f37f6ec1 | |||
| 5e684549a1 | |||
| 322971f3e7 | |||
| 6dd8ded05d | |||
| 7270154828 |
@@ -159,3 +159,5 @@ com_crashlytics_export_strings.xml
|
|||||||
crashlytics.properties
|
crashlytics.properties
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
fabric.properties
|
fabric.properties
|
||||||
|
|
||||||
|
\.pytest_cache/
|
||||||
|
|||||||
Generated
+1
@@ -16,6 +16,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/testproj" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/testproj" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/docs/_build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.6 (drf-yasg)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.6 (drf-yasg)" jdkType="Python SDK" />
|
||||||
|
|||||||
+2
-1
@@ -10,11 +10,12 @@
|
|||||||
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="ourVersions">
|
<option name="ourVersions">
|
||||||
<value>
|
<value>
|
||||||
<list size="4">
|
<list size="5">
|
||||||
<item index="0" class="java.lang.String" itemvalue="2.7" />
|
<item index="0" class="java.lang.String" itemvalue="2.7" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="3.4" />
|
<item index="1" class="java.lang.String" itemvalue="3.4" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="3.5" />
|
<item index="2" class="java.lang.String" itemvalue="3.5" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="3.6" />
|
<item index="3" class="java.lang.String" itemvalue="3.6" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="3.7" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
|
|||||||
Generated
+3
@@ -70,4 +70,7 @@
|
|||||||
</LinkMapSettings>
|
</LinkMapSettings>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (drf-yasg)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (drf-yasg)" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
||||||
+4
-1
@@ -2,17 +2,20 @@ language: python
|
|||||||
cache: pip
|
cache: pip
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- '2.7'
|
|
||||||
- '3.4'
|
- '3.4'
|
||||||
- '3.5'
|
- '3.5'
|
||||||
- '3.6'
|
- '3.6'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DRF=3.7
|
- DRF=3.7
|
||||||
|
- DRF=3.8
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- stage: test
|
- stage: test
|
||||||
|
python: '2.7'
|
||||||
|
env: DRF=3.7
|
||||||
|
-
|
||||||
python: '3.6'
|
python: '3.6'
|
||||||
env: DRF=master
|
env: DRF=master
|
||||||
-
|
-
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ You want to contribute some code? Great! Here are a few steps to get you started
|
|||||||
$ virtualenv venv
|
$ virtualenv venv
|
||||||
$ source venv/bin/activate
|
$ source venv/bin/activate
|
||||||
(venv) $ pip install -e .[validation]
|
(venv) $ pip install -e .[validation]
|
||||||
(venv) $ pip install -rrequirements/dev.txt "Django>=1.11.7"
|
(venv) $ pip install -r requirements/dev.txt
|
||||||
|
|
||||||
#. **Make your changes and check them against the test project**
|
#. **Make your changes and check them against the test project**
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -11,7 +11,7 @@ Generate **real** Swagger/OpenAPI 2.0 specifications from a Django Rest Framewor
|
|||||||
|
|
||||||
Compatible with
|
Compatible with
|
||||||
|
|
||||||
- **Django Rest Framework**: 3.7.7
|
- **Django Rest Framework**: 3.7.7, 3.8.x
|
||||||
- **Django**: 1.11.x, 2.0.x
|
- **Django**: 1.11.x, 2.0.x
|
||||||
- **Python**: 2.7, 3.4, 3.5, 3.6
|
- **Python**: 2.7, 3.4, 3.5, 3.6
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ In ``urls.py``:
|
|||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=None), name='schema-json'),
|
url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
|
||||||
url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=None), name='schema-swagger-ui'),
|
url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||||
url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=None), name='schema-redoc'),
|
url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -353,6 +353,12 @@ Integration with `djangorestframework-camel-case <https://github.com/vbabiy/djan
|
|||||||
provided out of the box - if you have ``djangorestframework-camel-case`` installed and your ``APIView`` uses
|
provided out of the box - if you have ``djangorestframework-camel-case`` installed and your ``APIView`` uses
|
||||||
``CamelCaseJSONParser`` or ``CamelCaseJSONRenderer``, all property names will be converted to *camelCase* by default.
|
``CamelCaseJSONParser`` or ``CamelCaseJSONRenderer``, all property names will be converted to *camelCase* by default.
|
||||||
|
|
||||||
|
djangorestframework-recursive
|
||||||
|
===============================
|
||||||
|
|
||||||
|
Integration with `djangorestframework-recursive <https://github.com/heywbj/django-rest-framework-recursive>`_ is
|
||||||
|
provided out of the box - if you have ``djangorestframework-recursive`` installed.
|
||||||
|
|
||||||
.. |travis| image:: https://img.shields.io/travis/axnsan12/drf-yasg/master.svg
|
.. |travis| image:: https://img.shields.io/travis/axnsan12/drf-yasg/master.svg
|
||||||
:target: https://travis-ci.org/axnsan12/drf-yasg
|
:target: https://travis-ci.org/axnsan12/drf-yasg
|
||||||
:alt: Travis CI
|
:alt: Travis CI
|
||||||
|
|||||||
@@ -3,6 +3,122 @@ Changelog
|
|||||||
#########
|
#########
|
||||||
|
|
||||||
|
|
||||||
|
**********
|
||||||
|
**1.9.2**
|
||||||
|
**********
|
||||||
|
|
||||||
|
*Release date: Aug 03, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.17.6
|
||||||
|
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.32
|
||||||
|
- **IMPROVED:** added ``--api-version`` argument to the ``generate_swagger`` management command (:pr:`170`)
|
||||||
|
- **FIXED:** corrected various documentation typos (:pr:`160`, :pr:`162`, :issue:`171`, :pr:`172`)
|
||||||
|
- **FIXED:** made ``generate_swagger`` work for projects without authentication (:pr:`161`)
|
||||||
|
- **FIXED:** fixed ``SafeText`` interaction with YAML codec (:issue:`159`)
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.9.1**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: Jun 30, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** added a ``swagger_fake_view`` marker to more easily detect mock views in view methods;
|
||||||
|
``getattr(self, 'swagger_fake_view', False)`` inside a view method like ``get_serializer_class`` will tell you if the
|
||||||
|
view instnace is being used for swagger schema introspection (:issue:`154`)
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.17.1
|
||||||
|
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.25
|
||||||
|
- **FIXED:** fixed wrong handling of duplicate urls in urlconf (:pr:`155`)
|
||||||
|
- **FIXED:** fixed crash when passing ``None`` as a response override (:issue:`148`)
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.9.0**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: Jun 16, 2018*
|
||||||
|
|
||||||
|
- **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_extra_fields`` would not be handlded (:pr:`142`)
|
||||||
|
- **FIXED:** fixed crash when encountering ``coreapi.Fields``\ s without a ``schema`` (:issue:`143`)
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.8.0**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: Jun 01, 2018*
|
||||||
|
|
||||||
|
- **ADDED:** added a :ref:`swagger_schema_fields <swagger_schema_fields>` field on serializer ``Meta`` classes for
|
||||||
|
customizing schema generation (:issue:`132`, :pr:`134`)
|
||||||
|
- **FIXED:** error responses from schema views are now rendered with ``JSONRenderer`` instead of throwing
|
||||||
|
confusing errors (:pr:`130`, :issue:`58`)
|
||||||
|
- **FIXED:** ``readOnly`` schema fields will now no longer be marked as ``required`` (:pr:`133`)
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.4**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: May 14, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.14.2
|
||||||
|
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.20
|
||||||
|
- **FIXED:** ignore ``None`` return from ``get_operation`` to avoid empty ``Path`` objects in output
|
||||||
|
- **FIXED:** request body is now allowed on ``DELETE`` endpoints (:issue:`118`)
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.3**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: May 12, 2018*
|
||||||
|
|
||||||
|
- **FIXED:** views whose ``__init__`` methods throw exceptions will now be ignored during endpoint enumeration
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.2**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: May 12, 2018*
|
||||||
|
|
||||||
|
- **FIXED:** fixed generation of default ``SECURITY_REQUIREMENTS`` to match documented behaviour
|
||||||
|
- **FIXED:** ordering of ``SECURITY_REQUIREMENTS`` and ``SECURITY_DEFINITIONS`` is now stable
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.1**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: May 05, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.14.1
|
||||||
|
- **IMPROVED:** set ``swagger-ui`` ``showCommonExtensions`` to ``True`` by default and add
|
||||||
|
``SHOW_COMMON_EXTENSIONS`` setting key
|
||||||
|
- **IMPROVED:** set ``min_length=1`` when ``allow_blank=False`` (:pr:`112`, thanks to :ghuser:`elnappo`)
|
||||||
|
- **FIXED:** made documentation ordering of ``SwaggerDict`` extra attributes stable
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.7.0**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: Apr 27, 2018*
|
||||||
|
|
||||||
|
- **ADDED:** added integration with `djangorestframework-recursive <https://github.com/heywbj/django-rest-framework-recursive>`_
|
||||||
|
(:issue:`109`, :pr:`110`, thanks to :ghuser:`rsichny`)
|
||||||
|
|
||||||
|
*NOTE:* in order for this to work, you will have to add the new ``drf_yasg.inspectors.RecursiveFieldInspector`` to
|
||||||
|
your ``DEFAULT_FIELD_INSPECTORS`` array if you changed it from the default value
|
||||||
|
|
||||||
|
- **FIXED:** ``SchemaRef`` now supports cyclical references via the ``ignore_unresolved`` argument
|
||||||
|
|
||||||
|
*********
|
||||||
|
**1.6.2**
|
||||||
|
*********
|
||||||
|
|
||||||
|
*Release date: Apr 25, 2018*
|
||||||
|
|
||||||
|
- **IMPROVED:** updated ``swagger-ui`` to version 3.13.6
|
||||||
|
- **IMPROVED:** switched ``ReDoc`` to version 2.0.0-alpha.17 (was 1.21.2); fixes :issue:`107`
|
||||||
|
- **FIXED:** made documentation ordering of parameters stable for urls with multiple parameters (:issue:`105`, :pr:`106`)
|
||||||
|
- **FIXED:** fixed crash when using a model ``ChoiceField`` of unknown child type
|
||||||
|
|
||||||
*********
|
*********
|
||||||
**1.6.1**
|
**1.6.1**
|
||||||
*********
|
*********
|
||||||
|
|||||||
+11
-5
@@ -87,8 +87,8 @@ Where you can use the :func:`@swagger_auto_schema <.swagger_auto_schema>` decora
|
|||||||
|
|
||||||
* for ``ViewSet``, ``GenericViewSet``, ``ModelViewSet``, because each viewset corresponds to multiple **paths**, you have
|
* for ``ViewSet``, ``GenericViewSet``, ``ModelViewSet``, because each viewset corresponds to multiple **paths**, you have
|
||||||
to decorate the *action methods*, i.e. ``list``, ``create``, ``retrieve``, etc. |br|
|
to decorate the *action methods*, i.e. ``list``, ``create``, ``retrieve``, etc. |br|
|
||||||
Additionally, ``@list_route``\ s or ``@detail_route``\ s defined on the viewset, like function based api views, can
|
Additionally, ``@action``\ s, ``@list_route``\ s or ``@detail_route``\ s defined on the viewset, like function based
|
||||||
respond to multiple HTTP methods and thus have multiple operations that must be decorated separately:
|
api views, can respond to multiple HTTP methods and thus have multiple operations that must be decorated separately:
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -96,13 +96,13 @@ Where you can use the :func:`@swagger_auto_schema <.swagger_auto_schema>` decora
|
|||||||
class ArticleViewSet(viewsets.ModelViewSet):
|
class ArticleViewSet(viewsets.ModelViewSet):
|
||||||
# method or 'methods' can be skipped because the list_route only handles a single method (GET)
|
# method or 'methods' can be skipped because the list_route only handles a single method (GET)
|
||||||
@swagger_auto_schema(operation_description='GET /articles/today/')
|
@swagger_auto_schema(operation_description='GET /articles/today/')
|
||||||
@list_route(methods=['get'])
|
@action(detail=False, methods=['get'])
|
||||||
def today(self, request):
|
def today(self, request):
|
||||||
...
|
...
|
||||||
|
|
||||||
@swagger_auto_schema(method='get', operation_description="GET /articles/{id}/image/")
|
@swagger_auto_schema(method='get', operation_description="GET /articles/{id}/image/")
|
||||||
@swagger_auto_schema(method='post', operation_description="POST /articles/{id}/image/")
|
@swagger_auto_schema(method='post', operation_description="POST /articles/{id}/image/")
|
||||||
@detail_route(methods=['get', 'post'], parser_classes=(MultiPartParser,))
|
@action(detail=True, methods=['get', 'post'], parser_classes=(MultiPartParser,))
|
||||||
def image(self, request, id=None):
|
def image(self, request, id=None):
|
||||||
...
|
...
|
||||||
|
|
||||||
@@ -169,13 +169,19 @@ You can define some per-serializer options by adding a ``Meta`` class to your se
|
|||||||
class Meta:
|
class Meta:
|
||||||
... options here ...
|
... options here ...
|
||||||
|
|
||||||
Currently, the only option you can add here is
|
.. _swagger_schema_fields:
|
||||||
|
|
||||||
|
The available options are:
|
||||||
|
|
||||||
* ``ref_name`` - a string which will be used as the model definition name for this serializer class; setting it to
|
* ``ref_name`` - a string which will be used as the model definition name for this serializer class; setting it to
|
||||||
``None`` will force the serializer to be generated as an inline model everywhere it is used. If two serializers
|
``None`` will force the serializer to be generated as an inline model everywhere it is used. If two serializers
|
||||||
have the same ``ref_name``, both their usages will be replaced with a reference to the same definition.
|
have the same ``ref_name``, both their usages will be replaced with a reference to the same definition.
|
||||||
If this option is not specified, all serializers have an implicit name derived from their class name, minus any
|
If this option is not specified, all serializers have an implicit name derived from their class name, minus any
|
||||||
``Serializer`` suffix (e.g. ``UserSerializer`` -> ``User``, ``SerializerWithSuffix`` -> ``SerializerWithSuffix``)
|
``Serializer`` suffix (e.g. ``UserSerializer`` -> ``User``, ``SerializerWithSuffix`` -> ``SerializerWithSuffix``)
|
||||||
|
* ``swagger_schema_fields`` - a dictionary mapping :class:`.Schema` field names to values. These attributes
|
||||||
|
will be set on the :class:`.Schema` object generated from the ``Serializer``. Field names must be python values,
|
||||||
|
which are converted to Swagger ``Schema`` attribute names according to :func:`.make_swagger_name`.
|
||||||
|
Attribute names and values must conform to the `OpenAPI 2.0 specification <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject>`_.
|
||||||
|
|
||||||
|
|
||||||
*************************
|
*************************
|
||||||
|
|||||||
@@ -174,6 +174,15 @@ in a few ways:
|
|||||||
:ref:`@swagger_auto_schema <custom-spec-swagger-auto-schema>`, to prevent ``get_serializer`` from being called on
|
:ref:`@swagger_auto_schema <custom-spec-swagger-auto-schema>`, to prevent ``get_serializer`` from being called on
|
||||||
the view
|
the view
|
||||||
* :ref:`exclude your endpoint from introspection <custom-spec-excluding-endpoints>`
|
* :ref:`exclude your endpoint from introspection <custom-spec-excluding-endpoints>`
|
||||||
|
* use the ``swagger_fake_view`` marker to detect requests generated by ``drf-yasg``:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
def get_serializer_class(self):
|
||||||
|
if getattr(self, 'swagger_fake_view', False):
|
||||||
|
return TodoTreeSerializer
|
||||||
|
|
||||||
|
raise NotImplementedError("must not call this")
|
||||||
|
|
||||||
.. _SCRIPT_NAME: https://www.python.org/dev/peps/pep-0333/#environ-variables
|
.. _SCRIPT_NAME: https://www.python.org/dev/peps/pep-0333/#environ-variables
|
||||||
.. _FORCE_SCRIPT_NAME: https://docs.djangoproject.com/en/2.0/ref/settings/#force-script-name
|
.. _FORCE_SCRIPT_NAME: https://docs.djangoproject.com/en/2.0/ref/settings/#force-script-name
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ Security requirements
|
|||||||
The second step is specifying, for each endpoint, which authentication mechanism can be used for interacting with it.
|
The second step is specifying, for each endpoint, which authentication mechanism can be used for interacting with it.
|
||||||
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object for details.
|
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 all the declared security definitions is generated.
|
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 overriden using the
|
||||||
:ref:`SECURITY_REQUIREMENTS <security-definitions-settings>` setting.
|
:ref:`SECURITY_REQUIREMENTS <security-definitions-settings>` setting.
|
||||||
|
|
||||||
|
|||||||
+28
-10
@@ -43,6 +43,14 @@ The possible settings and their default values are as follows:
|
|||||||
Default classes
|
Default classes
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
DEFAULT_GENERATOR_CLASS
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
:class:`~.generators.OpenAPISchemaGenerator` subclass that will be used by default for generating the final
|
||||||
|
:class:`.Schema` object. Can be overriden by the ``generator_class`` argument to :func:`.get_schema_view`.
|
||||||
|
|
||||||
|
**Default**: :class:`drf_yasg.generators.OpenAPISchemaGenerator`
|
||||||
|
|
||||||
DEFAULT_AUTO_SCHEMA_CLASS
|
DEFAULT_AUTO_SCHEMA_CLASS
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
@@ -67,6 +75,7 @@ to this list.
|
|||||||
:class:`'drf_yasg.inspectors.FileFieldInspector' <.inspectors.FileFieldInspector>`, |br| \
|
:class:`'drf_yasg.inspectors.FileFieldInspector' <.inspectors.FileFieldInspector>`, |br| \
|
||||||
:class:`'drf_yasg.inspectors.DictFieldInspector' <.inspectors.DictFieldInspector>`, |br| \
|
:class:`'drf_yasg.inspectors.DictFieldInspector' <.inspectors.DictFieldInspector>`, |br| \
|
||||||
:class:`'drf_yasg.inspectors.HiddenFieldInspector' <.inspectors.HiddenFieldInspector>`, |br| \
|
:class:`'drf_yasg.inspectors.HiddenFieldInspector' <.inspectors.HiddenFieldInspector>`, |br| \
|
||||||
|
:class:`'drf_yasg.inspectors.RecursiveFieldInspector' <.inspectors.RecursiveFieldInspector>`, |br| \
|
||||||
:class:`'drf_yasg.inspectors.SimpleFieldInspector' <.inspectors.SimpleFieldInspector>`, |br| \
|
:class:`'drf_yasg.inspectors.SimpleFieldInspector' <.inspectors.SimpleFieldInspector>`, |br| \
|
||||||
:class:`'drf_yasg.inspectors.StringDefaultFieldInspector' <.inspectors.StringDefaultFieldInspector>`, |br| \
|
:class:`'drf_yasg.inspectors.StringDefaultFieldInspector' <.inspectors.StringDefaultFieldInspector>`, |br| \
|
||||||
``]``
|
``]``
|
||||||
@@ -101,7 +110,7 @@ DEFAULT_INFO
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
An import string to an :class:`.openapi.Info` object. This will be used when running the ``generate_swagger``
|
An import string to an :class:`.openapi.Info` object. This will be used when running the ``generate_swagger``
|
||||||
management command, or if no ``info`` argument is passed to ``get_schema_view``.
|
management command, or if no ``info`` argument is passed to :func:`.get_schema_view`.
|
||||||
|
|
||||||
**Default**: :python:`None`
|
**Default**: :python:`None`
|
||||||
|
|
||||||
@@ -190,8 +199,8 @@ OPERATIONS_SORTER
|
|||||||
Sorting order for the operation list of each tag.
|
Sorting order for the operation list of each tag.
|
||||||
|
|
||||||
* :python:`None`: show in the order returned by the server
|
* :python:`None`: show in the order returned by the server
|
||||||
* :python:`alpha`: sort alphabetically by path
|
* :python:`'alpha'`: sort alphabetically by path
|
||||||
* :python:`method`: sort by HTTP method
|
* :python:`'method'`: sort by HTTP method
|
||||||
|
|
||||||
**Default**: :python:`None` |br|
|
**Default**: :python:`None` |br|
|
||||||
*Maps to parameter*: ``operationsSorter``
|
*Maps to parameter*: ``operationsSorter``
|
||||||
@@ -202,7 +211,7 @@ TAGS_SORTER
|
|||||||
Sorting order for tagged operation groups.
|
Sorting order for tagged operation groups.
|
||||||
|
|
||||||
* :python:`None`: Swagger UI default ordering
|
* :python:`None`: Swagger UI default ordering
|
||||||
* :python:`alpha`: sort alphabetically
|
* :python:`'alpha'`: sort alphabetically
|
||||||
|
|
||||||
**Default**: :python:`None` |br|
|
**Default**: :python:`None` |br|
|
||||||
*Maps to parameter*: ``tagsSorter``
|
*Maps to parameter*: ``tagsSorter``
|
||||||
@@ -212,9 +221,9 @@ DOC_EXPANSION
|
|||||||
|
|
||||||
Controls the default expansion setting for the operations and tags.
|
Controls the default expansion setting for the operations and tags.
|
||||||
|
|
||||||
* :python:`None`: everything is collapsed
|
* :python:`'none'`: everything is collapsed
|
||||||
* :python:`list`: only tags are expanded
|
* :python:`'list'`: only tags are expanded
|
||||||
* :python:`full`: all operations are expanded
|
* :python:`'full'`: all operations are expanded
|
||||||
|
|
||||||
**Default**: :python:`'list'` |br|
|
**Default**: :python:`'list'` |br|
|
||||||
*Maps to parameter*: ``docExpansion``
|
*Maps to parameter*: ``docExpansion``
|
||||||
@@ -240,8 +249,8 @@ DEFAULT_MODEL_RENDERING
|
|||||||
|
|
||||||
Controls whether operations show the model structure or the example value by default.
|
Controls whether operations show the model structure or the example value by default.
|
||||||
|
|
||||||
* :python:`model`: show the model fields by default
|
* :python:`'model'`: show the model fields by default
|
||||||
* :python:`example`: show the example value by default
|
* :python:`'example'`: show the example value by default
|
||||||
|
|
||||||
**Default**: :python:`'model'` |br|
|
**Default**: :python:`'model'` |br|
|
||||||
*Maps to parameter*: ``defaultModelRendering``
|
*Maps to parameter*: ``defaultModelRendering``
|
||||||
@@ -254,6 +263,15 @@ Controls how many levels are expaned by default when showing nested models.
|
|||||||
**Default**: :python:`3` |br|
|
**Default**: :python:`3` |br|
|
||||||
*Maps to parameter*: ``defaultModelExpandDepth``
|
*Maps to parameter*: ``defaultModelExpandDepth``
|
||||||
|
|
||||||
|
SHOW_COMMON_EXTENSIONS
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Controls the display of extensions (``pattern``, ``maxLength``, ``minLength``, ``maximum``, ``minimum``) fields and
|
||||||
|
values for Parameters.
|
||||||
|
|
||||||
|
**Default**: :python:`True` |br|
|
||||||
|
*Maps to parameter*: ``showCommonExtensions``
|
||||||
|
|
||||||
.. _oauth2-settings:
|
.. _oauth2-settings:
|
||||||
|
|
||||||
OAUTH2_REDIRECT_URL
|
OAUTH2_REDIRECT_URL
|
||||||
@@ -295,7 +313,7 @@ ReDoc UI settings
|
|||||||
=================
|
=================
|
||||||
|
|
||||||
ReDoc UI configuration settings. |br|
|
ReDoc UI configuration settings. |br|
|
||||||
See https://github.com/Rebilly/ReDoc#redoc-tag-attributes.
|
See https://github.com/Rebilly/ReDoc#configuration.
|
||||||
|
|
||||||
LAZY_RENDERING
|
LAZY_RENDERING
|
||||||
--------------
|
--------------
|
||||||
|
|||||||
Generated
+381
-231
@@ -8,50 +8,68 @@
|
|||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"sprintf-js": "1.0.3"
|
"sprintf-js": "~1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autolinker": {
|
"asap": {
|
||||||
"version": "0.15.3",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/autolinker/-/autolinker-0.15.3.tgz",
|
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
|
||||||
"integrity": "sha1-NCQX2PLzRhsUzwkIjV7fh5HcmDI="
|
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
|
||||||
},
|
},
|
||||||
"builtin-status-codes": {
|
"base64-js": {
|
||||||
"version": "3.0.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
|
||||||
"integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug="
|
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
|
||||||
|
},
|
||||||
|
"buffer": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-nUJyfChH7PMJy75eRDCCKtszSEFokUNXC1hNVSe+o+VdcgvDPLs20k3v8UXI8ruRYAJiYtyRea8mYyqPxoHWDw==",
|
||||||
|
"requires": {
|
||||||
|
"base64-js": "^1.0.2",
|
||||||
|
"ieee754": "^1.1.4"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"call-me-maybe": {
|
"call-me-maybe": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
|
||||||
"integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms="
|
"integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms="
|
||||||
},
|
},
|
||||||
|
"classnames": {
|
||||||
|
"version": "2.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz",
|
||||||
|
"integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q=="
|
||||||
|
},
|
||||||
"clipboard": {
|
"clipboard": {
|
||||||
"version": "1.7.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.1.tgz",
|
||||||
"integrity": "sha1-Ng1taUbpmnof7zleQrqStem1oWs=",
|
"integrity": "sha512-7yhQBmtN+uYZmfRjjVjKa0dZdWuabzpSKGtyQZN+9C8xlC788SSJjOHWh7tzurfwTqTD5UDYAhIv5fRJg3sHjQ==",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"good-listener": "1.2.2",
|
"good-listener": "^1.2.2",
|
||||||
"select": "1.1.2",
|
"select": "^1.1.2",
|
||||||
"tiny-emitter": "2.0.2"
|
"tiny-emitter": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"commander": {
|
|
||||||
"version": "2.14.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz",
|
|
||||||
"integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==",
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "2.5.3",
|
"version": "1.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
|
||||||
"integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4="
|
"integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"css-color-keywords": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
"integrity": "sha1-/qJhbcZ2spYmhrOvjb2+GAskTgU="
|
||||||
|
},
|
||||||
|
"css-to-react-native": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-v++LRcf633phJiYZBDqtmGPj3+BVof0isd2jgwYLWZJ5YSuhCkrfYtDsNhM6oJthiEco0f9tDVJ1vUkDJNgGEA==",
|
||||||
|
"requires": {
|
||||||
|
"css-color-keywords": "^1.0.0",
|
||||||
|
"fbjs": "^0.8.5",
|
||||||
|
"postcss-value-parser": "^3.3.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
@@ -61,26 +79,63 @@
|
|||||||
"ms": "2.0.0"
|
"ms": "2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"decko": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/decko/-/decko-1.2.0.tgz",
|
||||||
|
"integrity": "sha1-/UPHNelnuAEzBohKVvvmZZlraBc="
|
||||||
|
},
|
||||||
"delegate": {
|
"delegate": {
|
||||||
"version": "3.2.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
|
||||||
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"dropkickjs": {
|
"dom-walk": {
|
||||||
"version": "2.1.10",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/dropkickjs/-/dropkickjs-2.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
|
||||||
"integrity": "sha1-8TyUAhQdoJ50rfTmN5jXkiBEOPI="
|
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||||
},
|
},
|
||||||
"es6-promise": {
|
"dompurify": {
|
||||||
"version": "4.2.4",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-1.0.7.tgz",
|
||||||
"integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ=="
|
"integrity": "sha512-1xK0JEda/jvIm3SgqHXKvRCh3AbEKCyBbUAGpNCMVIljBD145cPvBR66JSj3O4SdscFUx5NXsDkJpz6vDT8KLg=="
|
||||||
|
},
|
||||||
|
"encoding": {
|
||||||
|
"version": "0.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||||
|
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
|
||||||
|
"requires": {
|
||||||
|
"iconv-lite": "~0.4.13"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"esprima": {
|
"esprima": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
|
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||||
|
},
|
||||||
|
"eventemitter3": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA=="
|
||||||
|
},
|
||||||
|
"fast-levenshtein": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
||||||
|
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
|
||||||
|
},
|
||||||
|
"fbjs": {
|
||||||
|
"version": "0.8.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
|
||||||
|
"integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
|
||||||
|
"requires": {
|
||||||
|
"core-js": "^1.0.0",
|
||||||
|
"isomorphic-fetch": "^2.1.1",
|
||||||
|
"loose-envify": "^1.0.0",
|
||||||
|
"object-assign": "^4.1.0",
|
||||||
|
"promise": "^7.1.1",
|
||||||
|
"setimmediate": "^1.0.5",
|
||||||
|
"ua-parser-js": "^0.7.18"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"foreach": {
|
"foreach": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
@@ -92,42 +147,73 @@
|
|||||||
"resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.3.tgz",
|
||||||
"integrity": "sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU="
|
"integrity": "sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU="
|
||||||
},
|
},
|
||||||
|
"global": {
|
||||||
|
"version": "4.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz",
|
||||||
|
"integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=",
|
||||||
|
"requires": {
|
||||||
|
"min-document": "^2.19.0",
|
||||||
|
"process": "~0.5.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"good-listener": {
|
"good-listener": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
|
||||||
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
|
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"delegate": "3.2.0"
|
"delegate": "^3.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hint.css": {
|
"has-flag": {
|
||||||
"version": "2.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/hint.css/-/hint.css-2.5.0.tgz",
|
|
||||||
"integrity": "sha1-OMrjZn5C2R392+UDEAqzSTL2/WU="
|
|
||||||
},
|
|
||||||
"https-browserify": {
|
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
|
||||||
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM="
|
"integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo="
|
||||||
},
|
},
|
||||||
"inherits": {
|
"hoist-non-react-statics": {
|
||||||
"version": "2.0.3",
|
"version": "2.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",
|
||||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
"integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="
|
||||||
},
|
},
|
||||||
"isarray": {
|
"iconv-lite": {
|
||||||
"version": "1.0.0",
|
"version": "0.4.23",
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
|
||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
"integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==",
|
||||||
|
"requires": {
|
||||||
|
"safer-buffer": ">= 2.1.2 < 3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ieee754": {
|
||||||
|
"version": "1.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz",
|
||||||
|
"integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA=="
|
||||||
|
},
|
||||||
|
"is-stream": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
|
||||||
|
},
|
||||||
|
"isomorphic-fetch": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
|
||||||
|
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
|
||||||
|
"requires": {
|
||||||
|
"node-fetch": "^1.0.1",
|
||||||
|
"whatwg-fetch": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"js-tokens": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
||||||
},
|
},
|
||||||
"js-yaml": {
|
"js-yaml": {
|
||||||
"version": "3.10.0",
|
"version": "3.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
|
||||||
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
|
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"argparse": "1.0.10",
|
"argparse": "^1.0.7",
|
||||||
"esprima": "4.0.0"
|
"esprima": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"json-pointer": {
|
"json-pointer": {
|
||||||
@@ -135,148 +221,219 @@
|
|||||||
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.0.tgz",
|
||||||
"integrity": "sha1-jlAFUKaqxUZKRzN32leqbMIoKNc=",
|
"integrity": "sha1-jlAFUKaqxUZKRzN32leqbMIoKNc=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"foreach": "2.0.5"
|
"foreach": "^2.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"json-schema-ref-parser": {
|
"json-schema-ref-parser": {
|
||||||
"version": "3.3.1",
|
"version": "5.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-5.1.2.tgz",
|
||||||
"integrity": "sha512-stQTMhec2R/p2L9dH4XXRlpNCP0mY8QrLd/9Kl+8SHJQmwHtE1nDfXH4wbsSM+GkJMl8t92yZbI0OIol432CIQ==",
|
"integrity": "sha512-gP0mSqqkG99xNeA4F6bf2pXQYv5fFqe9SybbKO9qSMmyzzfFFIqd16s9Y65mRWKzZ0muTjyEtcSE/hLZLvIjZw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"call-me-maybe": "1.0.1",
|
"call-me-maybe": "^1.0.1",
|
||||||
"debug": "3.1.0",
|
"debug": "^3.1.0",
|
||||||
"es6-promise": "4.2.4",
|
"js-yaml": "^3.12.0",
|
||||||
"js-yaml": "3.10.0",
|
"ono": "^4.0.5"
|
||||||
"ono": "4.0.3",
|
|
||||||
"z-schema": "3.19.1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash.get": {
|
"loose-envify": {
|
||||||
"version": "4.4.2",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||||
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
|
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||||
},
|
"requires": {
|
||||||
"lodash.isequal": {
|
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||||
"version": "4.5.0",
|
}
|
||||||
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
|
|
||||||
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
|
|
||||||
},
|
},
|
||||||
"lunr": {
|
"lunr": {
|
||||||
"version": "1.0.0",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/lunr/-/lunr-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.1.tgz",
|
||||||
"integrity": "sha1-XJJ2ySyRrDWpJBtQGNRnI9kuL18="
|
"integrity": "sha1-ETYWorYC3cEJMqe/ik5uV+v+zfI="
|
||||||
},
|
},
|
||||||
"mark.js": {
|
"mark.js": {
|
||||||
"version": "8.11.1",
|
"version": "8.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz",
|
||||||
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
"integrity": "sha1-GA8fnr74sOY45BZq1S24eb6y/8U="
|
||||||
},
|
},
|
||||||
|
"marked": {
|
||||||
|
"version": "0.3.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.18.tgz",
|
||||||
|
"integrity": "sha512-49i2QYhfULqaXzNZpxC808PisuCTGT2fgG0zrzdCI9N3rIfAWfW0nggvbXr6zvpynZdOG5+9xNxdzP0kwZnERw=="
|
||||||
|
},
|
||||||
|
"memoize-one": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-wdpOJ4XBejprGn/xhd1i2XR8Dv1A25FJeIvR7syQhQlz9eXsv+06llcvcmBxlWVGv4C73QBsWA8kxvZozzNwiQ=="
|
||||||
|
},
|
||||||
|
"min-document": {
|
||||||
|
"version": "2.19.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz",
|
||||||
|
"integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=",
|
||||||
|
"requires": {
|
||||||
|
"dom-walk": "^0.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mobx-react": {
|
||||||
|
"version": "5.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-5.2.3.tgz",
|
||||||
|
"integrity": "sha512-OuSlF2nJEa1PGookZcZnINbvEK4iWNNYiqUh6aebk2AkWxj3sG8OafDOQMcMYApQALTHRsrBIjOx/K8TFxcz7w==",
|
||||||
|
"requires": {
|
||||||
|
"hoist-non-react-statics": "^2.5.0",
|
||||||
|
"react-lifecycles-compat": "^3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
},
|
},
|
||||||
"ono": {
|
"node-fetch": {
|
||||||
"version": "4.0.3",
|
"version": "1.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
||||||
"integrity": "sha512-7QIxG4UB00H7CR7fhXC/U7VhB5DK9wsYLwaYBui1JmQoXtLkhIBn3fbuk6FgAP+ctWeBsWVTM+R/bThvUZN+ww==",
|
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"format-util": "1.0.3"
|
"encoding": "^0.1.11",
|
||||||
|
"is-stream": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object-assign": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||||
|
},
|
||||||
|
"ono": {
|
||||||
|
"version": "4.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/ono/-/ono-4.0.5.tgz",
|
||||||
|
"integrity": "sha512-ZVNuV9kJbr/2tWs83I2snrYo+WIS0DISF/xUfX9p9b6GyDD6F5N9PzHjW+p/dep6IGwSYylf1HCub5I/nM0R5Q==",
|
||||||
|
"requires": {
|
||||||
|
"format-util": "^1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"openapi-sampler": {
|
"openapi-sampler": {
|
||||||
"version": "1.0.0-beta.8",
|
"version": "1.0.0-beta.13",
|
||||||
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.0.0-beta.8.tgz",
|
"resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.0.0-beta.13.tgz",
|
||||||
"integrity": "sha1-v0P/R3N/xOH5iNDiCC1JeI9B3q0=",
|
"integrity": "sha512-NReKJh92NlUmY9CDo86L1Skkx3DMDeWmiLoqMxQSX7xBpoSx8WJ1JdTb7nEwz6M7S+WDPrQsEfS5BaIW27nMrQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"json-pointer": "0.6.0"
|
"json-pointer": "^0.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"perfect-scrollbar": {
|
"perfect-scrollbar": {
|
||||||
"version": "0.8.1",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/perfect-scrollbar/-/perfect-scrollbar-0.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/perfect-scrollbar/-/perfect-scrollbar-1.4.0.tgz",
|
||||||
"integrity": "sha512-RNC5tX/JMRYR+qVdJTEAWnRxw0Yf9lvbO8lTuAOvgDODkiA8lveTSkvrNMhmaGKEyimJpJl+myb/syVS9YyPuw=="
|
"integrity": "sha512-/2Sk/khljhdrsamjJYS5NjrH+GKEHEwh7zFSiYyxROyYKagkE4kSn2zDQDRTOMo8mpT2jikxx6yI1dG7lNP/hw=="
|
||||||
|
},
|
||||||
|
"polished": {
|
||||||
|
"version": "1.9.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/polished/-/polished-1.9.3.tgz",
|
||||||
|
"integrity": "sha512-4NmSD7fMFlM8roNxs7YXPv7UFRbYzb0gufR5zBxJLRzY54+zFsavxBo6zsQzP9ep6Hh3pC2pTyrpSTBEaB6IkQ=="
|
||||||
|
},
|
||||||
|
"postcss-value-parser": {
|
||||||
|
"version": "3.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz",
|
||||||
|
"integrity": "sha1-h/OPnxj3dKSrTIojL1xc6IcqnRU="
|
||||||
},
|
},
|
||||||
"prismjs": {
|
"prismjs": {
|
||||||
"version": "1.11.0",
|
"version": "1.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.15.0.tgz",
|
||||||
"integrity": "sha1-KXrvM+t5Qhv9sZJzpQkspRWXDSk=",
|
"integrity": "sha512-Lf2JrFYx8FanHrjoV5oL8YHCclLQgbJcVZR+gikGGMqz6ub5QVWDTM6YIwm3BuPxM/LOV+rKns3LssXNLIf+DA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"clipboard": "1.7.1"
|
"clipboard": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"process-nextick-args": {
|
"process": {
|
||||||
"version": "2.0.0",
|
"version": "0.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz",
|
||||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
"integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8="
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
"promise": {
|
||||||
"version": "2.3.5",
|
"version": "7.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
|
||||||
"integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
|
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"core-util-is": "1.0.2",
|
"asap": "~2.0.3"
|
||||||
"inherits": "2.0.3",
|
}
|
||||||
"isarray": "1.0.0",
|
},
|
||||||
"process-nextick-args": "2.0.0",
|
"prop-types": {
|
||||||
"safe-buffer": "5.1.1",
|
"version": "15.6.2",
|
||||||
"string_decoder": "1.0.3",
|
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz",
|
||||||
"util-deprecate": "1.0.2"
|
"integrity": "sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==",
|
||||||
|
"requires": {
|
||||||
|
"loose-envify": "^1.3.1",
|
||||||
|
"object-assign": "^4.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"react-dropdown": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-dropdown/-/react-dropdown-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-rRv3a7NiP++yC1rzdjzkviC5ujq759i4SRa0M3C0Cr7loYT4Z3+JhSPekv1/04JiZNXX46cV3/g6A9kS7rkI4Q==",
|
||||||
|
"requires": {
|
||||||
|
"classnames": "^2.2.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"react-hot-loader": {
|
||||||
|
"version": "4.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-hot-loader/-/react-hot-loader-4.3.4.tgz",
|
||||||
|
"integrity": "sha512-LlKjtHq+RhDq9xm6crXojbkzrEvli5F4/RaeJ//XtDWrwwsAHDjEqKfZZiPCxv7gWV2cxE3YE8TXeE9BDzLqOA==",
|
||||||
|
"requires": {
|
||||||
|
"fast-levenshtein": "^2.0.6",
|
||||||
|
"global": "^4.3.0",
|
||||||
|
"hoist-non-react-statics": "^2.5.0",
|
||||||
|
"prop-types": "^15.6.1",
|
||||||
|
"react-lifecycles-compat": "^3.0.4",
|
||||||
|
"shallowequal": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"react-is": {
|
||||||
|
"version": "16.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.4.2.tgz",
|
||||||
|
"integrity": "sha512-rI3cGFj/obHbBz156PvErrS5xc6f1eWyTwyV4mo0vF2lGgXgS+mm7EKD5buLJq6jNgIagQescGSVG2YzgXt8Yg=="
|
||||||
|
},
|
||||||
|
"react-lifecycles-compat": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
||||||
|
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
||||||
|
},
|
||||||
|
"react-tabs": {
|
||||||
|
"version": "2.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-tabs/-/react-tabs-2.2.2.tgz",
|
||||||
|
"integrity": "sha512-jZGAAoq1yknr/XF60/2kH5X3UJdR1X8ItcsLZ1mJnHfoniKcCr3shT2TK5wiS2sO0LOmqwX2BtJQX3snKd50sg==",
|
||||||
|
"requires": {
|
||||||
|
"classnames": "^2.2.0",
|
||||||
|
"prop-types": "^15.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redoc": {
|
"redoc": {
|
||||||
"version": "1.21.2",
|
"version": "2.0.0-alpha.32",
|
||||||
"resolved": "https://registry.npmjs.org/redoc/-/redoc-1.21.2.tgz",
|
"resolved": "https://registry.npmjs.org/redoc/-/redoc-2.0.0-alpha.32.tgz",
|
||||||
"integrity": "sha1-uMeLfDxtwFjmeZniwvYbqFjewaY=",
|
"integrity": "sha512-hqQlQ8lnXszLOJGyrRCLtCH+yPJfS22FjbqJ9X6/KM3U46UXk7rv3jZG/quV0IIRhcyehRm6h8a6Eu18KRupng==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"core-js": "2.5.3",
|
"classnames": "^2.2.6",
|
||||||
"dropkickjs": "2.1.10",
|
"decko": "^1.2.0",
|
||||||
"hint.css": "2.5.0",
|
"dompurify": "^1.0.6",
|
||||||
"https-browserify": "1.0.0",
|
"eventemitter3": "^3.0.0",
|
||||||
"json-pointer": "0.6.0",
|
"json-pointer": "^0.6.0",
|
||||||
"json-schema-ref-parser": "3.3.1",
|
"json-schema-ref-parser": "^5.1.1",
|
||||||
"lunr": "1.0.0",
|
"lunr": "^2.3.0",
|
||||||
"mark.js": "8.11.1",
|
"mark.js": "^8.11.1",
|
||||||
"openapi-sampler": "1.0.0-beta.8",
|
"marked": "0.3.18",
|
||||||
"perfect-scrollbar": "0.8.1",
|
"memoize-one": "^4.0.0",
|
||||||
"prismjs": "1.11.0",
|
"mobx-react": "^5.2.3",
|
||||||
"remarkable": "1.7.1",
|
"openapi-sampler": "1.0.0-beta.13",
|
||||||
"scrollparent": "2.0.1",
|
"perfect-scrollbar": "^1.4.0",
|
||||||
"slugify": "1.2.9",
|
"polished": "^1.9.3",
|
||||||
"stream-http": "2.8.0",
|
"prismjs": "^1.15.0",
|
||||||
"ts-helpers": "1.1.2",
|
"prop-types": "^15.6.2",
|
||||||
"zone.js": "0.8.20"
|
"react-dropdown": "^1.3.0",
|
||||||
|
"react-hot-loader": "^4.3.3",
|
||||||
|
"react-tabs": "^2.0.0",
|
||||||
|
"slugify": "^1.2.1",
|
||||||
|
"stickyfill": "^1.1.1",
|
||||||
|
"styled-components": "^3.3.3",
|
||||||
|
"tslib": "^1.9.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"remarkable": {
|
"safer-buffer": {
|
||||||
"version": "1.7.1",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/remarkable/-/remarkable-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha1-qspJchALZqZCpjoQIcpLrBvjv/Y=",
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||||
"requires": {
|
|
||||||
"argparse": "0.1.16",
|
|
||||||
"autolinker": "0.15.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"argparse": {
|
|
||||||
"version": "0.1.16",
|
|
||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz",
|
|
||||||
"integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=",
|
|
||||||
"requires": {
|
|
||||||
"underscore": "1.7.0",
|
|
||||||
"underscore.string": "2.4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"safe-buffer": {
|
|
||||||
"version": "5.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
|
||||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
|
||||||
},
|
|
||||||
"scrollparent": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/scrollparent/-/scrollparent-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-cV1bnMV3YPsivczDvvtb/gaxoxc="
|
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
@@ -284,40 +441,69 @@
|
|||||||
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
|
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"setimmediate": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||||
|
"integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
|
||||||
|
},
|
||||||
|
"shallowequal": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ=="
|
||||||
|
},
|
||||||
"slugify": {
|
"slugify": {
|
||||||
"version": "1.2.9",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.3.0.tgz",
|
||||||
"integrity": "sha512-n0cdJ+kN3slJu8SbZXt/EHjljBqF6MxvMGSg/NPpBzoY7yyXoH38wp/ox20a1JaG1KgmdTN5Lf3aS9+xB2Y2aQ=="
|
"integrity": "sha512-vvz+9ANt7CtdTHwJpfrsHOnGkgxky+CUPnvtzDZBZYFo/H/CdZkd5lJL7z7RqtH/x9QW/ItYYfHlcGf38CBK1w=="
|
||||||
},
|
},
|
||||||
"sprintf-js": {
|
"sprintf-js": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
||||||
},
|
},
|
||||||
"stream-http": {
|
"stickyfill": {
|
||||||
"version": "2.8.0",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/stickyfill/-/stickyfill-1.1.1.tgz",
|
||||||
"integrity": "sha512-sZOFxI/5xw058XIRHl4dU3dZ+TTOIGJR78Dvo0oEAejIt4ou27k+3ne1zYmCV+v7UucbxIFQuOgnkTVHh8YPnw==",
|
"integrity": "sha1-OUE/7p0CXHSn5ZzuyyN4TMDxfwI="
|
||||||
|
},
|
||||||
|
"styled-components": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-3.4.0.tgz",
|
||||||
|
"integrity": "sha1-0lb7RmfmwRWn7WGrePEgKDtD3QA=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"builtin-status-codes": "3.0.0",
|
"buffer": "^5.0.3",
|
||||||
"inherits": "2.0.3",
|
"css-to-react-native": "^2.0.3",
|
||||||
"readable-stream": "2.3.5",
|
"fbjs": "^0.8.16",
|
||||||
"to-arraybuffer": "1.0.1",
|
"hoist-non-react-statics": "^2.5.0",
|
||||||
"xtend": "4.0.1"
|
"prop-types": "^15.5.4",
|
||||||
|
"react-is": "^16.3.1",
|
||||||
|
"stylis": "^3.5.0",
|
||||||
|
"stylis-rule-sheet": "^0.0.10",
|
||||||
|
"supports-color": "^3.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
"stylis": {
|
||||||
"version": "1.0.3",
|
"version": "3.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/stylis/-/stylis-3.5.3.tgz",
|
||||||
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
"integrity": "sha512-TxU0aAscJghF9I3V9q601xcK3Uw1JbXvpsBGj/HULqexKOKlOEzzlIpLFRbKkCK990ccuxfXUqmPbIIo7Fq/cQ=="
|
||||||
|
},
|
||||||
|
"stylis-rule-sheet": {
|
||||||
|
"version": "0.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/stylis-rule-sheet/-/stylis-rule-sheet-0.0.10.tgz",
|
||||||
|
"integrity": "sha512-nTbZoaqoBnmK+ptANthb10ZRZOGC+EmTLLUxeYIuHNkEKcmKgXX1XWKkUBT2Ac4es3NybooPe0SmvKdhKJZAuw=="
|
||||||
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "3.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz",
|
||||||
|
"integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "5.1.1"
|
"has-flag": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"swagger-ui-dist": {
|
"swagger-ui-dist": {
|
||||||
"version": "3.13.0",
|
"version": "3.17.6",
|
||||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.17.6.tgz",
|
||||||
"integrity": "sha1-NPpclKDx3EAWVBmIEV38rhOKirE="
|
"integrity": "sha1-37Y7uHZdOKNzjPWUZYad4W3Uczk="
|
||||||
},
|
},
|
||||||
"tiny-emitter": {
|
"tiny-emitter": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
@@ -325,56 +511,20 @@
|
|||||||
"integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow==",
|
"integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"to-arraybuffer": {
|
"tslib": {
|
||||||
"version": "1.0.1",
|
"version": "1.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
|
||||||
"integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M="
|
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||||
},
|
},
|
||||||
"ts-helpers": {
|
"ua-parser-js": {
|
||||||
"version": "1.1.2",
|
"version": "0.7.18",
|
||||||
"resolved": "https://registry.npmjs.org/ts-helpers/-/ts-helpers-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz",
|
||||||
"integrity": "sha1-/Gm+nx87rtAfsaDvjUz+dIgU2DU="
|
"integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA=="
|
||||||
},
|
},
|
||||||
"underscore": {
|
"whatwg-fetch": {
|
||||||
"version": "1.7.0",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
|
||||||
"integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk="
|
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
|
||||||
},
|
|
||||||
"underscore.string": {
|
|
||||||
"version": "2.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz",
|
|
||||||
"integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs="
|
|
||||||
},
|
|
||||||
"util-deprecate": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
|
||||||
},
|
|
||||||
"validator": {
|
|
||||||
"version": "9.4.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/validator/-/validator-9.4.1.tgz",
|
|
||||||
"integrity": "sha512-YV5KjzvRmSyJ1ee/Dm5UED0G+1L4GZnLN3w6/T+zZm8scVua4sOhYKWTUrKa0H/tMiJyO9QLHMPN+9mB/aMunA=="
|
|
||||||
},
|
|
||||||
"xtend": {
|
|
||||||
"version": "4.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
|
||||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
|
||||||
},
|
|
||||||
"z-schema": {
|
|
||||||
"version": "3.19.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.19.1.tgz",
|
|
||||||
"integrity": "sha512-jPNzqmOu3+AGbb4krDODqo4QBzwUGDVzyfGyy1HtWaUnafltQotatSpxxWd6Mp0iSZOUwHU5sqKYi+U8HsHMkg==",
|
|
||||||
"requires": {
|
|
||||||
"commander": "2.14.1",
|
|
||||||
"lodash.get": "4.4.2",
|
|
||||||
"lodash.isequal": "4.5.0",
|
|
||||||
"validator": "9.4.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"zone.js": {
|
|
||||||
"version": "0.8.20",
|
|
||||||
"resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.8.20.tgz",
|
|
||||||
"integrity": "sha512-FXlA37ErSXCMy5RNBcGFgCI/Zivqzr0D19GuvDxhcYIJc7xkFp6c29DKyODJu0Zo+EMyur/WPPgcBh1EHjB9jA=="
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "drf-yasg",
|
"name": "drf-yasg",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"redoc": "^1.21.2",
|
"redoc": "^2.0.0-alpha.32",
|
||||||
"swagger-ui-dist": "^3.13.0"
|
"swagger-ui-dist": "^3.17.6"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ six>=1.10.0
|
|||||||
uritemplate>=3.0.0
|
uritemplate>=3.0.0
|
||||||
|
|
||||||
djangorestframework>=3.7.7
|
djangorestframework>=3.7.7
|
||||||
Django>=1.11.7,<2.0; python_version <= "2.7"
|
Django>=1.11.7
|
||||||
Django>=1.11.7; python_version >= "3.4"
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ pytest>=2.9
|
|||||||
pytest-pythonpath>=0.7.1
|
pytest-pythonpath>=0.7.1
|
||||||
pytest-cov>=2.5.1
|
pytest-cov>=2.5.1
|
||||||
pytest-xdist>=1.22.0
|
pytest-xdist>=1.22.0
|
||||||
# latest pip version of pytest-django is more than a year old and does not support Django 2.0
|
pytest-django>=3.2.0
|
||||||
git+https://github.com/pytest-dev/pytest-django.git@94cccb956435dd7a719606744ee7608397e1eafb
|
|
||||||
datadiff==2.0.0
|
datadiff==2.0.0
|
||||||
|
|
||||||
-r testproj.txt
|
-r testproj.txt
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ django-cors-headers>=2.1.0
|
|||||||
django-filter>=1.1.0,<2.0; python_version == "2.7"
|
django-filter>=1.1.0,<2.0; python_version == "2.7"
|
||||||
django-filter>=1.1.0; python_version >= "3.4"
|
django-filter>=1.1.0; python_version >= "3.4"
|
||||||
djangorestframework-camel-case>=0.2.0
|
djangorestframework-camel-case>=0.2.0
|
||||||
|
djangorestframework-recursive>=0.1.2
|
||||||
dj-database-url>=0.4.2
|
dj-database-url>=0.4.2
|
||||||
user_agents>=1.1.0
|
user_agents>=1.1.0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# requirements for building and running tox
|
# requirements for building and running tox
|
||||||
tox>=2.9.1
|
tox>=2.9.1,<3.0.0
|
||||||
detox>=0.11
|
detox>=0.11
|
||||||
|
|
||||||
-r setup.txt
|
-r setup.txt
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
[bdist_wheel]
|
[bdist_wheel]
|
||||||
universal = 1
|
universal = 1
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
license_file = LICENSE.rst
|
||||||
|
|||||||
@@ -2,16 +2,18 @@ from django.conf import settings
|
|||||||
from rest_framework.settings import perform_import
|
from rest_framework.settings import perform_import
|
||||||
|
|
||||||
SWAGGER_DEFAULTS = {
|
SWAGGER_DEFAULTS = {
|
||||||
|
'DEFAULT_GENERATOR_CLASS': 'drf_yasg.generators.OpenAPISchemaGenerator',
|
||||||
'DEFAULT_AUTO_SCHEMA_CLASS': 'drf_yasg.inspectors.SwaggerAutoSchema',
|
'DEFAULT_AUTO_SCHEMA_CLASS': 'drf_yasg.inspectors.SwaggerAutoSchema',
|
||||||
|
|
||||||
'DEFAULT_FIELD_INSPECTORS': [
|
'DEFAULT_FIELD_INSPECTORS': [
|
||||||
'drf_yasg.inspectors.CamelCaseJSONFilter',
|
'drf_yasg.inspectors.CamelCaseJSONFilter',
|
||||||
|
'drf_yasg.inspectors.RecursiveFieldInspector',
|
||||||
'drf_yasg.inspectors.ReferencingSerializerInspector',
|
'drf_yasg.inspectors.ReferencingSerializerInspector',
|
||||||
'drf_yasg.inspectors.RelatedFieldInspector',
|
|
||||||
'drf_yasg.inspectors.ChoiceFieldInspector',
|
'drf_yasg.inspectors.ChoiceFieldInspector',
|
||||||
'drf_yasg.inspectors.FileFieldInspector',
|
'drf_yasg.inspectors.FileFieldInspector',
|
||||||
'drf_yasg.inspectors.DictFieldInspector',
|
'drf_yasg.inspectors.DictFieldInspector',
|
||||||
'drf_yasg.inspectors.HiddenFieldInspector',
|
'drf_yasg.inspectors.HiddenFieldInspector',
|
||||||
|
'drf_yasg.inspectors.RelatedFieldInspector',
|
||||||
'drf_yasg.inspectors.SimpleFieldInspector',
|
'drf_yasg.inspectors.SimpleFieldInspector',
|
||||||
'drf_yasg.inspectors.StringDefaultFieldInspector',
|
'drf_yasg.inspectors.StringDefaultFieldInspector',
|
||||||
],
|
],
|
||||||
@@ -44,6 +46,7 @@ SWAGGER_DEFAULTS = {
|
|||||||
'SHOW_EXTENSIONS': True,
|
'SHOW_EXTENSIONS': True,
|
||||||
'DEFAULT_MODEL_RENDERING': 'model',
|
'DEFAULT_MODEL_RENDERING': 'model',
|
||||||
'DEFAULT_MODEL_DEPTH': 3,
|
'DEFAULT_MODEL_DEPTH': 3,
|
||||||
|
'SHOW_COMMON_EXTENSIONS': True,
|
||||||
'OAUTH2_REDIRECT_URL': None,
|
'OAUTH2_REDIRECT_URL': None,
|
||||||
'OAUTH2_CONFIG': {},
|
'OAUTH2_CONFIG': {},
|
||||||
'SUPPORTED_SUBMIT_METHODS': [
|
'SUPPORTED_SUBMIT_METHODS': [
|
||||||
@@ -66,6 +69,7 @@ REDOC_DEFAULTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IMPORT_STRINGS = [
|
IMPORT_STRINGS = [
|
||||||
|
'DEFAULT_GENERATOR_CLASS',
|
||||||
'DEFAULT_AUTO_SCHEMA_CLASS',
|
'DEFAULT_AUTO_SCHEMA_CLASS',
|
||||||
'DEFAULT_FIELD_INSPECTORS',
|
'DEFAULT_FIELD_INSPECTORS',
|
||||||
'DEFAULT_FILTER_INSPECTORS',
|
'DEFAULT_FILTER_INSPECTORS',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import json
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from coreapi.compat import force_bytes
|
from coreapi.compat import force_bytes
|
||||||
|
from django.utils.safestring import SafeData, SafeText
|
||||||
from ruamel import yaml
|
from ruamel import yaml
|
||||||
|
|
||||||
from . import openapi
|
from . import openapi
|
||||||
|
|||||||
+42
-18
@@ -5,7 +5,6 @@ from collections import OrderedDict, defaultdict
|
|||||||
|
|
||||||
import uritemplate
|
import uritemplate
|
||||||
from coreapi.compat import urlparse
|
from coreapi.compat import urlparse
|
||||||
from django.utils.encoding import force_text
|
|
||||||
from rest_framework import versioning
|
from rest_framework import versioning
|
||||||
from rest_framework.compat import URLPattern, URLResolver, get_original_route
|
from rest_framework.compat import URLPattern, URLResolver, get_original_route
|
||||||
from rest_framework.schemas.generators import EndpointEnumerator as _EndpointEnumerator
|
from rest_framework.schemas.generators import EndpointEnumerator as _EndpointEnumerator
|
||||||
@@ -18,7 +17,7 @@ from .app_settings import swagger_settings
|
|||||||
from .errors import SwaggerGenerationError
|
from .errors import SwaggerGenerationError
|
||||||
from .inspectors.field import get_basic_type_info, get_queryset_field
|
from .inspectors.field import get_basic_type_info, get_queryset_field
|
||||||
from .openapi import ReferenceResolver
|
from .openapi import ReferenceResolver
|
||||||
from .utils import get_consumes, get_produces
|
from .utils import force_real_str, get_consumes, get_produces
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ class EndpointEnumerator(_EndpointEnumerator):
|
|||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def get_api_endpoints(self, patterns=None, prefix='', app_name=None, namespace=None):
|
def get_api_endpoints(self, patterns=None, prefix='', app_name=None, namespace=None, ignored_endpoints=None):
|
||||||
"""
|
"""
|
||||||
Return a list of all available API endpoints by inspecting the URL conf.
|
Return a list of all available API endpoints by inspecting the URL conf.
|
||||||
|
|
||||||
@@ -82,25 +81,38 @@ class EndpointEnumerator(_EndpointEnumerator):
|
|||||||
patterns = self.patterns
|
patterns = self.patterns
|
||||||
|
|
||||||
api_endpoints = []
|
api_endpoints = []
|
||||||
|
if ignored_endpoints is None:
|
||||||
|
ignored_endpoints = set()
|
||||||
|
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
path_regex = prefix + get_original_route(pattern)
|
path_regex = prefix + get_original_route(pattern)
|
||||||
if isinstance(pattern, URLPattern):
|
if isinstance(pattern, URLPattern):
|
||||||
path = self.get_path_from_regex(path_regex)
|
try:
|
||||||
callback = pattern.callback
|
path = self.get_path_from_regex(path_regex)
|
||||||
url_name = pattern.name
|
callback = pattern.callback
|
||||||
if self.should_include_endpoint(path, callback, app_name or '', namespace or '', url_name):
|
url_name = pattern.name
|
||||||
path = self.replace_version(path, callback)
|
if self.should_include_endpoint(path, callback, app_name or '', namespace or '', url_name):
|
||||||
for method in self.get_allowed_methods(callback):
|
path = self.replace_version(path, callback)
|
||||||
endpoint = (path, method, callback)
|
|
||||||
api_endpoints.append(endpoint)
|
# avoid adding endpoints that have already been seen,
|
||||||
|
# as Django resolves urls in top-down order
|
||||||
|
if path in ignored_endpoints:
|
||||||
|
continue
|
||||||
|
ignored_endpoints.add(path)
|
||||||
|
|
||||||
|
for method in self.get_allowed_methods(callback):
|
||||||
|
endpoint = (path, method, callback)
|
||||||
|
api_endpoints.append(endpoint)
|
||||||
|
except Exception: # pragma: no cover
|
||||||
|
logger.warning('failed to enumerate view', exc_info=True)
|
||||||
|
|
||||||
elif isinstance(pattern, URLResolver):
|
elif isinstance(pattern, URLResolver):
|
||||||
nested_endpoints = self.get_api_endpoints(
|
nested_endpoints = self.get_api_endpoints(
|
||||||
patterns=pattern.url_patterns,
|
patterns=pattern.url_patterns,
|
||||||
prefix=path_regex,
|
prefix=path_regex,
|
||||||
app_name="%s:%s" % (app_name, pattern.app_name) if app_name else pattern.app_name,
|
app_name="%s:%s" % (app_name, pattern.app_name) if app_name else pattern.app_name,
|
||||||
namespace="%s:%s" % (namespace, pattern.namespace) if namespace else pattern.namespace
|
namespace="%s:%s" % (namespace, pattern.namespace) if namespace else pattern.namespace,
|
||||||
|
ignored_endpoints=ignored_endpoints
|
||||||
)
|
)
|
||||||
api_endpoints.extend(nested_endpoints)
|
api_endpoints.extend(nested_endpoints)
|
||||||
else:
|
else:
|
||||||
@@ -204,9 +216,15 @@ class OpenAPISchemaGenerator(object):
|
|||||||
paths, prefix = self.get_paths(endpoints, components, request, public)
|
paths, prefix = self.get_paths(endpoints, components, request, public)
|
||||||
|
|
||||||
security_definitions = swagger_settings.SECURITY_DEFINITIONS
|
security_definitions = swagger_settings.SECURITY_DEFINITIONS
|
||||||
|
if security_definitions is not None:
|
||||||
|
security_definitions = OrderedDict(sorted([(key, OrderedDict(sorted(sd.items())))
|
||||||
|
for key, sd in swagger_settings.SECURITY_DEFINITIONS.items()]))
|
||||||
security_requirements = swagger_settings.SECURITY_REQUIREMENTS
|
security_requirements = swagger_settings.SECURITY_REQUIREMENTS
|
||||||
if security_requirements is None:
|
if security_requirements is None:
|
||||||
security_requirements = [{security_scheme: [] for security_scheme in swagger_settings.SECURITY_DEFINITIONS}]
|
security_requirements = [{security_scheme: []} for security_scheme in swagger_settings.SECURITY_DEFINITIONS]
|
||||||
|
|
||||||
|
security_requirements = sorted(security_requirements, key=lambda od: list(sorted(od)))
|
||||||
|
security_requirements = [OrderedDict(sorted(sr.items())) for sr in security_requirements]
|
||||||
|
|
||||||
url = self.url
|
url = self.url
|
||||||
if url is None and request is not None:
|
if url is None and request is not None:
|
||||||
@@ -234,6 +252,8 @@ class OpenAPISchemaGenerator(object):
|
|||||||
view_method = getattr(view, method, None)
|
view_method = getattr(view, method, None)
|
||||||
if view_method is not None: # pragma: no cover
|
if view_method is not None: # pragma: no cover
|
||||||
setattr(view_method.__func__, '_swagger_auto_schema', overrides)
|
setattr(view_method.__func__, '_swagger_auto_schema', overrides)
|
||||||
|
|
||||||
|
setattr(view, 'swagger_fake_view', True)
|
||||||
return view
|
return view
|
||||||
|
|
||||||
def get_endpoints(self, request):
|
def get_endpoints(self, request):
|
||||||
@@ -315,7 +335,9 @@ class OpenAPISchemaGenerator(object):
|
|||||||
if not public and not self._gen.has_view_permissions(path, method, view):
|
if not public and not self._gen.has_view_permissions(path, method, view):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
operations[method.lower()] = self.get_operation(view, path, prefix, method, components, request)
|
operation = self.get_operation(view, path, prefix, method, components, request)
|
||||||
|
if operation is not None:
|
||||||
|
operations[method.lower()] = operation
|
||||||
|
|
||||||
if operations:
|
if operations:
|
||||||
# since the common prefix is used as the API basePath, it must be stripped
|
# since the common prefix is used as the API basePath, it must be stripped
|
||||||
@@ -356,6 +378,9 @@ class OpenAPISchemaGenerator(object):
|
|||||||
|
|
||||||
view_inspector = view_inspector_cls(view, path, method, components, request, overrides)
|
view_inspector = view_inspector_cls(view, path, method, components, request, overrides)
|
||||||
operation = view_inspector.get_operation(operation_keys)
|
operation = view_inspector.get_operation(operation_keys)
|
||||||
|
if operation is None:
|
||||||
|
return None
|
||||||
|
|
||||||
if 'consumes' in operation and set(operation.consumes) == set(self.consumes):
|
if 'consumes' in operation and set(operation.consumes) == set(self.consumes):
|
||||||
del operation.consumes
|
del operation.consumes
|
||||||
if 'produces' in operation and set(operation.produces) == set(self.produces):
|
if 'produces' in operation and set(operation.produces) == set(self.produces):
|
||||||
@@ -401,16 +426,15 @@ class OpenAPISchemaGenerator(object):
|
|||||||
"""
|
"""
|
||||||
parameters = []
|
parameters = []
|
||||||
queryset = getattr(view_cls, 'queryset', None)
|
queryset = getattr(view_cls, 'queryset', None)
|
||||||
model = getattr(getattr(view_cls, 'queryset', None), 'model', None)
|
|
||||||
|
|
||||||
for variable in uritemplate.variables(path):
|
for variable in sorted(uritemplate.variables(path)):
|
||||||
model, model_field = get_queryset_field(queryset, variable)
|
model, model_field = get_queryset_field(queryset, variable)
|
||||||
attrs = get_basic_type_info(model_field) or {'type': openapi.TYPE_STRING}
|
attrs = get_basic_type_info(model_field) or {'type': openapi.TYPE_STRING}
|
||||||
if getattr(view_cls, 'lookup_field', None) == variable and attrs['type'] == openapi.TYPE_STRING:
|
if getattr(view_cls, 'lookup_field', None) == variable and attrs['type'] == openapi.TYPE_STRING:
|
||||||
attrs['pattern'] = getattr(view_cls, 'lookup_value_regex', attrs.get('pattern', None))
|
attrs['pattern'] = getattr(view_cls, 'lookup_value_regex', attrs.get('pattern', None))
|
||||||
|
|
||||||
if model_field and getattr(model_field, 'help_text', False):
|
if model_field and getattr(model_field, 'help_text', False):
|
||||||
description = force_text(model_field.help_text)
|
description = model_field.help_text
|
||||||
elif model_field and getattr(model_field, 'primary_key', False):
|
elif model_field and getattr(model_field, 'primary_key', False):
|
||||||
description = get_pk_description(model, model_field)
|
description = get_pk_description(model, model_field)
|
||||||
else:
|
else:
|
||||||
@@ -418,7 +442,7 @@ class OpenAPISchemaGenerator(object):
|
|||||||
|
|
||||||
field = openapi.Parameter(
|
field = openapi.Parameter(
|
||||||
name=variable,
|
name=variable,
|
||||||
description=description,
|
description=force_real_str(description),
|
||||||
required=True,
|
required=True,
|
||||||
in_=openapi.IN_PATH,
|
in_=openapi.IN_PATH,
|
||||||
**attrs
|
**attrs
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ from .base import (
|
|||||||
)
|
)
|
||||||
from .field import (
|
from .field import (
|
||||||
CamelCaseJSONFilter, ChoiceFieldInspector, DictFieldInspector, FileFieldInspector, HiddenFieldInspector,
|
CamelCaseJSONFilter, ChoiceFieldInspector, DictFieldInspector, FileFieldInspector, HiddenFieldInspector,
|
||||||
InlineSerializerInspector, ReferencingSerializerInspector, RelatedFieldInspector, SimpleFieldInspector,
|
InlineSerializerInspector, RecursiveFieldInspector, ReferencingSerializerInspector, RelatedFieldInspector,
|
||||||
StringDefaultFieldInspector
|
SimpleFieldInspector, StringDefaultFieldInspector
|
||||||
)
|
)
|
||||||
from .query import CoreAPICompatInspector, DjangoRestResponsePagination
|
from .query import CoreAPICompatInspector, DjangoRestResponsePagination
|
||||||
from .view import SwaggerAutoSchema
|
from .view import SwaggerAutoSchema
|
||||||
@@ -23,9 +23,9 @@ __all__ = [
|
|||||||
'CoreAPICompatInspector', 'DjangoRestResponsePagination',
|
'CoreAPICompatInspector', 'DjangoRestResponsePagination',
|
||||||
|
|
||||||
# field inspectors
|
# field inspectors
|
||||||
'InlineSerializerInspector', 'ReferencingSerializerInspector', 'RelatedFieldInspector', 'SimpleFieldInspector',
|
'InlineSerializerInspector', 'RecursiveFieldInspector', 'ReferencingSerializerInspector', 'RelatedFieldInspector',
|
||||||
'FileFieldInspector', 'ChoiceFieldInspector', 'DictFieldInspector', 'StringDefaultFieldInspector',
|
'SimpleFieldInspector', 'FileFieldInspector', 'ChoiceFieldInspector', 'DictFieldInspector',
|
||||||
'CamelCaseJSONFilter', 'HiddenFieldInspector',
|
'StringDefaultFieldInspector', 'CamelCaseJSONFilter', 'HiddenFieldInspector',
|
||||||
|
|
||||||
# view inspectors
|
# view inspectors
|
||||||
'SwaggerAutoSchema',
|
'SwaggerAutoSchema',
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.utils.encoding import force_text
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.utils import encoders, json
|
from rest_framework.utils import encoders, json
|
||||||
|
|
||||||
from .. import openapi
|
from .. import openapi
|
||||||
from ..utils import decimal_as_float, is_list_view
|
from ..utils import decimal_as_float, force_real_str, is_list_view
|
||||||
|
|
||||||
#: Sentinel value that inspectors must return to signal that they do not know how to handle an object
|
#: Sentinel value that inspectors must return to signal that they do not know how to handle an object
|
||||||
NotHandled = object()
|
NotHandled = object()
|
||||||
@@ -196,9 +195,9 @@ class FieldInspector(BaseInspector):
|
|||||||
"""
|
"""
|
||||||
assert swagger_object_type in (openapi.Schema, openapi.Parameter, openapi.Items)
|
assert swagger_object_type in (openapi.Schema, openapi.Parameter, openapi.Items)
|
||||||
assert not isinstance(field, openapi.SwaggerDict), "passed field is already a SwaggerDict object"
|
assert not isinstance(field, openapi.SwaggerDict), "passed field is already a SwaggerDict object"
|
||||||
title = force_text(field.label) if field.label else None
|
title = force_real_str(field.label) if field.label else None
|
||||||
title = title if swagger_object_type == openapi.Schema else None # only Schema has title
|
title = title if swagger_object_type == openapi.Schema else None # only Schema has title
|
||||||
description = force_text(field.help_text) if field.help_text else None
|
description = force_real_str(field.help_text) if field.help_text else None
|
||||||
description = description if swagger_object_type != openapi.Items else None # Items has no description either
|
description = description if swagger_object_type != openapi.Items else None # Items has no description either
|
||||||
|
|
||||||
def SwaggerType(existing_object=None, **instance_kwargs):
|
def SwaggerType(existing_object=None, **instance_kwargs):
|
||||||
@@ -276,7 +275,10 @@ class SerializerInspector(FieldInspector):
|
|||||||
|
|
||||||
|
|
||||||
class ViewInspector(BaseInspector):
|
class ViewInspector(BaseInspector):
|
||||||
body_methods = ('PUT', 'PATCH', 'POST') #: methods that are allowed to have a request body
|
body_methods = ('PUT', 'PATCH', 'POST', 'DELETE') #: methods that are allowed to have a request body
|
||||||
|
|
||||||
|
#: methods that are assumed to require a request body determined by the view's ``serializer_class``
|
||||||
|
implicit_body_methods = ('PUT', 'PATCH', 'POST')
|
||||||
|
|
||||||
# real values set in __init__ to prevent import errors
|
# real values set in __init__ to prevent import errors
|
||||||
field_inspectors = [] #:
|
field_inspectors = [] #:
|
||||||
@@ -368,7 +370,7 @@ class ViewInspector(BaseInspector):
|
|||||||
|
|
||||||
:param serializers.BaseSerializer serializer: the ``Serializer`` instance
|
:param serializers.BaseSerializer serializer: the ``Serializer`` instance
|
||||||
:returns: the converted :class:`.Schema`, or ``None`` in case of an unknown serializer
|
:returns: the converted :class:`.Schema`, or ``None`` in case of an unknown serializer
|
||||||
:rtype: openapi.Schema,openapi.SchemaRef,None
|
:rtype: openapi.Schema,openapi.SchemaRef
|
||||||
"""
|
"""
|
||||||
return self.probe_inspectors(
|
return self.probe_inspectors(
|
||||||
self.field_inspectors, 'get_schema', serializer, {'field_inspectors': self.field_inspectors}
|
self.field_inspectors, 'get_schema', serializer, {'field_inspectors': self.field_inspectors}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from rest_framework.settings import api_settings as rest_framework_settings
|
|||||||
|
|
||||||
from .. import openapi
|
from .. import openapi
|
||||||
from ..errors import SwaggerGenerationError
|
from ..errors import SwaggerGenerationError
|
||||||
from ..utils import decimal_as_float, filter_none
|
from ..utils import decimal_as_float, filter_none, get_serializer_ref_name
|
||||||
from .base import FieldInspector, NotHandled, SerializerInspector
|
from .base import FieldInspector, NotHandled, SerializerInspector
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -22,12 +22,36 @@ class InlineSerializerInspector(SerializerInspector):
|
|||||||
#: whether to output :class:`.Schema` definitions inline or into the ``definitions`` section
|
#: whether to output :class:`.Schema` definitions inline or into the ``definitions`` section
|
||||||
use_definitions = False
|
use_definitions = False
|
||||||
|
|
||||||
|
def add_manual_fields(self, serializer, schema):
|
||||||
|
"""Set fields from the ``swagger_schem_fields`` attribute on the serializer's Meta class. This method is called
|
||||||
|
only for serializers that are converted into ``openapi.Schema`` objects.
|
||||||
|
|
||||||
|
:param serializer: serializer instance
|
||||||
|
:param openapi.Schema schema: the schema object to be modified in-place
|
||||||
|
"""
|
||||||
|
serializer_meta = getattr(serializer, 'Meta', None)
|
||||||
|
swagger_schema_fields = getattr(serializer_meta, 'swagger_schema_fields', {})
|
||||||
|
if swagger_schema_fields:
|
||||||
|
for attr, val in swagger_schema_fields.items():
|
||||||
|
setattr(schema, attr, val)
|
||||||
|
|
||||||
def get_schema(self, serializer):
|
def get_schema(self, serializer):
|
||||||
return self.probe_field_inspectors(serializer, openapi.Schema, self.use_definitions)
|
return self.probe_field_inspectors(serializer, openapi.Schema, self.use_definitions)
|
||||||
|
|
||||||
|
def add_manual_parameters(self, serializer, parameters):
|
||||||
|
"""Add/replace parameters from the given list of automatically generated request parameters. This method
|
||||||
|
is called only when the serializer is converted into a list of parameters for use in a form data request.
|
||||||
|
|
||||||
|
:param serializer: serializer instance
|
||||||
|
:param list[openapi.Parameter] parameters: genereated parameters
|
||||||
|
:return: modified parameters
|
||||||
|
:rtype: list[openapi.Parameter]
|
||||||
|
"""
|
||||||
|
return parameters
|
||||||
|
|
||||||
def get_request_parameters(self, serializer, in_):
|
def get_request_parameters(self, serializer, in_):
|
||||||
fields = getattr(serializer, 'fields', {})
|
fields = getattr(serializer, 'fields', {})
|
||||||
return [
|
parameters = [
|
||||||
self.probe_field_inspectors(
|
self.probe_field_inspectors(
|
||||||
value, openapi.Parameter, self.use_definitions,
|
value, openapi.Parameter, self.use_definitions,
|
||||||
name=self.get_parameter_name(key), in_=in_
|
name=self.get_parameter_name(key), in_=in_
|
||||||
@@ -36,12 +60,17 @@ class InlineSerializerInspector(SerializerInspector):
|
|||||||
in fields.items()
|
in fields.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
return self.add_manual_parameters(serializer, parameters)
|
||||||
|
|
||||||
def get_property_name(self, field_name):
|
def get_property_name(self, field_name):
|
||||||
return field_name
|
return field_name
|
||||||
|
|
||||||
def get_parameter_name(self, field_name):
|
def get_parameter_name(self, field_name):
|
||||||
return field_name
|
return field_name
|
||||||
|
|
||||||
|
def get_serializer_ref_name(self, serializer):
|
||||||
|
return get_serializer_ref_name(serializer)
|
||||||
|
|
||||||
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
||||||
SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
|
SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
|
||||||
|
|
||||||
@@ -55,33 +84,24 @@ class InlineSerializerInspector(SerializerInspector):
|
|||||||
if swagger_object_type != openapi.Schema:
|
if swagger_object_type != openapi.Schema:
|
||||||
raise SwaggerGenerationError("cannot instantiate nested serializer as " + swagger_object_type.__name__)
|
raise SwaggerGenerationError("cannot instantiate nested serializer as " + swagger_object_type.__name__)
|
||||||
|
|
||||||
serializer = field
|
ref_name = self.get_serializer_ref_name(field)
|
||||||
serializer_meta = getattr(serializer, 'Meta', None)
|
|
||||||
serializer_name = type(serializer).__name__
|
|
||||||
if hasattr(serializer_meta, 'ref_name'):
|
|
||||||
ref_name = serializer_meta.ref_name
|
|
||||||
elif serializer_name == 'NestedSerializer' and isinstance(serializer, serializers.ModelSerializer):
|
|
||||||
logger.debug("Forcing inline output for ModelSerializer named 'NestedSerializer': " + str(serializer))
|
|
||||||
ref_name = None
|
|
||||||
else:
|
|
||||||
ref_name = serializer_name
|
|
||||||
if ref_name.endswith('Serializer'):
|
|
||||||
ref_name = ref_name[:-len('Serializer')]
|
|
||||||
|
|
||||||
def make_schema_definition():
|
def make_schema_definition():
|
||||||
properties = OrderedDict()
|
properties = OrderedDict()
|
||||||
required = []
|
required = []
|
||||||
for property_name, child in serializer.fields.items():
|
for property_name, child in field.fields.items():
|
||||||
property_name = self.get_property_name(property_name)
|
property_name = self.get_property_name(property_name)
|
||||||
prop_kwargs = {
|
prop_kwargs = {
|
||||||
'read_only': child.read_only or None
|
'read_only': bool(child.read_only) or None
|
||||||
}
|
}
|
||||||
prop_kwargs = filter_none(prop_kwargs)
|
prop_kwargs = filter_none(prop_kwargs)
|
||||||
|
|
||||||
properties[property_name] = self.probe_field_inspectors(
|
child_schema = self.probe_field_inspectors(
|
||||||
child, ChildSwaggerType, use_references, **prop_kwargs
|
child, ChildSwaggerType, use_references, **prop_kwargs
|
||||||
)
|
)
|
||||||
if child.required:
|
properties[property_name] = child_schema
|
||||||
|
|
||||||
|
if child.required and not getattr(child_schema, 'read_only', False):
|
||||||
required.append(property_name)
|
required.append(property_name)
|
||||||
|
|
||||||
result = SwaggerType(
|
result = SwaggerType(
|
||||||
@@ -94,6 +114,10 @@ class InlineSerializerInspector(SerializerInspector):
|
|||||||
# but is visually displayed like the model name, which is confusing
|
# but is visually displayed like the model name, which is confusing
|
||||||
# it is better to just remove title from inline models
|
# it is better to just remove title from inline models
|
||||||
del result.title
|
del result.title
|
||||||
|
|
||||||
|
# Provide an option to add manual paremeters to a schema
|
||||||
|
# for example, to add examples
|
||||||
|
self.add_manual_fields(field, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if not ref_name or not use_references:
|
if not ref_name or not use_references:
|
||||||
@@ -292,6 +316,10 @@ def find_limits(field):
|
|||||||
if attr not in limits or improves(limit_value, limits[attr]):
|
if attr not in limits or improves(limit_value, limits[attr]):
|
||||||
limits[attr] = limit_value
|
limits[attr] = limit_value
|
||||||
|
|
||||||
|
if hasattr(field, "allow_blank") and not field.allow_blank:
|
||||||
|
if limits.get('min_length', 0) < 1:
|
||||||
|
limits['min_length'] = 1
|
||||||
|
|
||||||
return OrderedDict(sorted(limits.items()))
|
return OrderedDict(sorted(limits.items()))
|
||||||
|
|
||||||
|
|
||||||
@@ -410,7 +438,9 @@ class ChoiceFieldInspector(FieldInspector):
|
|||||||
model = getattr(getattr(serializer, 'Meta'), 'model')
|
model = getattr(getattr(serializer, 'Meta'), 'model')
|
||||||
model_field = get_model_field(model, field.source)
|
model_field = get_model_field(model, field.source)
|
||||||
if model_field:
|
if model_field:
|
||||||
enum_type = get_basic_type_info(model_field).get('type', enum_type)
|
model_type = get_basic_type_info(model_field)
|
||||||
|
if model_type:
|
||||||
|
enum_type = model_type.get('type', enum_type)
|
||||||
|
|
||||||
if isinstance(field, serializers.MultipleChoiceField):
|
if isinstance(field, serializers.MultipleChoiceField):
|
||||||
return SwaggerType(
|
return SwaggerType(
|
||||||
@@ -529,3 +559,24 @@ else:
|
|||||||
return camelize_schema(result, self.components)
|
return camelize_schema(result, self.components)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
try:
|
||||||
|
from rest_framework_recursive.fields import RecursiveField
|
||||||
|
except ImportError: # pragma: no cover
|
||||||
|
class RecursiveFieldInspector(FieldInspector):
|
||||||
|
"""Provides conversion for RecursiveField (https://github.com/heywbj/django-rest-framework-recursive)"""
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
class RecursiveFieldInspector(FieldInspector):
|
||||||
|
"""Provides conversion for RecursiveField (https://github.com/heywbj/django-rest-framework-recursive)"""
|
||||||
|
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
|
||||||
|
if isinstance(field, RecursiveField) and swagger_object_type == openapi.Schema:
|
||||||
|
assert use_references is True, "Can not create schema for RecursiveField when use_references is False"
|
||||||
|
|
||||||
|
ref_name = get_serializer_ref_name(field.proxied)
|
||||||
|
assert ref_name is not None, "Can not create RecursiveField schema for inline ModelSerializer"
|
||||||
|
|
||||||
|
return openapi.SchemaRef(self.components.with_scope(openapi.SCHEMA_DEFINITIONS), ref_name,
|
||||||
|
ignore_unresolved=True)
|
||||||
|
|
||||||
|
return NotHandled
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ from collections import OrderedDict
|
|||||||
import coreschema
|
import coreschema
|
||||||
from rest_framework.pagination import CursorPagination, LimitOffsetPagination, PageNumberPagination
|
from rest_framework.pagination import CursorPagination, LimitOffsetPagination, PageNumberPagination
|
||||||
|
|
||||||
|
from drf_yasg.utils import force_real_str
|
||||||
|
|
||||||
from .. import openapi
|
from .. import openapi
|
||||||
from .base import FilterInspector, PaginatorInspector
|
from .base import FilterInspector, PaginatorInspector
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ class CoreAPICompatInspector(PaginatorInspector, FilterInspector):
|
|||||||
in_=location_to_in[field.location],
|
in_=location_to_in[field.location],
|
||||||
type=coreapi_types.get(type(field.schema), openapi.TYPE_STRING),
|
type=coreapi_types.get(type(field.schema), openapi.TYPE_STRING),
|
||||||
required=field.required,
|
required=field.required,
|
||||||
description=field.schema.description,
|
description=force_real_str(field.schema.description) if field.schema else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -70,7 +72,10 @@ class DjangoRestResponsePagination(PaginatorInspector):
|
|||||||
('previous', openapi.Schema(type=openapi.TYPE_STRING, format=openapi.FORMAT_URI)),
|
('previous', openapi.Schema(type=openapi.TYPE_STRING, format=openapi.FORMAT_URI)),
|
||||||
('results', response_schema),
|
('results', response_schema),
|
||||||
)),
|
)),
|
||||||
required=['count', 'results']
|
required=['results']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if has_count:
|
||||||
|
paged_schema.required.insert(0, 'count')
|
||||||
|
|
||||||
return paged_schema
|
return paged_schema
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from rest_framework.request import is_form_media_type
|
from rest_framework.request import is_form_media_type
|
||||||
@@ -7,11 +8,13 @@ from rest_framework.status import is_success
|
|||||||
from .. import openapi
|
from .. import openapi
|
||||||
from ..errors import SwaggerGenerationError
|
from ..errors import SwaggerGenerationError
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
force_serializer_instance, get_consumes, get_produces, guess_response_status, is_list_view, no_body,
|
force_real_str, force_serializer_instance, get_consumes, get_produces, guess_response_status, is_list_view, no_body,
|
||||||
param_list_to_odict
|
param_list_to_odict
|
||||||
)
|
)
|
||||||
from .base import ViewInspector
|
from .base import ViewInspector
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SwaggerAutoSchema(ViewInspector):
|
class SwaggerAutoSchema(ViewInspector):
|
||||||
def __init__(self, view, path, method, components, request, overrides):
|
def __init__(self, view, path, method, components, request, overrides):
|
||||||
@@ -39,7 +42,7 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
|
|
||||||
return openapi.Operation(
|
return openapi.Operation(
|
||||||
operation_id=operation_id,
|
operation_id=operation_id,
|
||||||
description=description,
|
description=force_real_str(description),
|
||||||
responses=responses,
|
responses=responses,
|
||||||
parameters=parameters,
|
parameters=parameters,
|
||||||
consumes=consumes,
|
consumes=consumes,
|
||||||
@@ -83,12 +86,17 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
"""
|
"""
|
||||||
if not hasattr(self.view, 'get_serializer'):
|
if not hasattr(self.view, 'get_serializer'):
|
||||||
return None
|
return None
|
||||||
return self.view.get_serializer()
|
try:
|
||||||
|
return self.view.get_serializer()
|
||||||
|
except Exception:
|
||||||
|
log.warning("view's get_serializer raised exception (%s %s %s)",
|
||||||
|
self.method, self.path, type(self.view).__name__, exc_info=True)
|
||||||
|
return None
|
||||||
|
|
||||||
def get_request_serializer(self):
|
def _get_request_body_override(self):
|
||||||
"""Return the request serializer (used for parsing the request payload) for this endpoint.
|
"""Parse the request_body key in the override dict. This method is not public API.
|
||||||
|
|
||||||
:return: the request serializer, or one of :class:`.Schema`, :class:`.SchemaRef`, ``None``
|
:return:
|
||||||
"""
|
"""
|
||||||
body_override = self.overrides.get('request_body', None)
|
body_override = self.overrides.get('request_body', None)
|
||||||
|
|
||||||
@@ -101,10 +109,20 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
if isinstance(body_override, openapi.Schema.OR_REF):
|
if isinstance(body_override, openapi.Schema.OR_REF):
|
||||||
return body_override
|
return body_override
|
||||||
return force_serializer_instance(body_override)
|
return force_serializer_instance(body_override)
|
||||||
elif self.method in self.body_methods:
|
|
||||||
|
return body_override
|
||||||
|
|
||||||
|
def get_request_serializer(self):
|
||||||
|
"""Return the request serializer (used for parsing the request payload) for this endpoint.
|
||||||
|
|
||||||
|
:return: the request serializer, or one of :class:`.Schema`, :class:`.SchemaRef`, ``None``
|
||||||
|
"""
|
||||||
|
body_override = self._get_request_body_override()
|
||||||
|
|
||||||
|
if body_override is None and self.method in self.implicit_body_methods:
|
||||||
return self.get_view_serializer()
|
return self.get_view_serializer()
|
||||||
|
|
||||||
return None
|
return body_override
|
||||||
|
|
||||||
def get_request_form_parameters(self, serializer):
|
def get_request_form_parameters(self, serializer):
|
||||||
"""Given a Serializer, return a list of ``in: formData`` :class:`.Parameter`\ s.
|
"""Given a Serializer, return a list of ``in: formData`` :class:`.Parameter`\ s.
|
||||||
@@ -144,8 +162,11 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
raise SwaggerGenerationError("specify the body parameter as a Schema or Serializer in request_body")
|
raise SwaggerGenerationError("specify the body parameter as a Schema or Serializer in request_body")
|
||||||
if any(param.in_ == openapi.IN_FORM for param in manual_parameters): # pragma: no cover
|
if any(param.in_ == openapi.IN_FORM for param in manual_parameters): # pragma: no cover
|
||||||
if any(param.in_ == openapi.IN_BODY for param in parameters.values()):
|
if any(param.in_ == openapi.IN_BODY for param in parameters.values()):
|
||||||
raise SwaggerGenerationError("cannot add form parameters when the request has a request schema; "
|
raise SwaggerGenerationError("cannot add form parameters when the request has a request body; "
|
||||||
"did you forget to set an appropriate parser class on the view?")
|
"did you forget to set an appropriate parser class on the view?")
|
||||||
|
if self.method not in self.body_methods:
|
||||||
|
raise SwaggerGenerationError("form parameters can only be applied to (" + ','.join(self.body_methods) +
|
||||||
|
") HTTP methods")
|
||||||
|
|
||||||
parameters.update(param_list_to_odict(manual_parameters))
|
parameters.update(param_list_to_odict(manual_parameters))
|
||||||
return list(parameters.values())
|
return list(parameters.values())
|
||||||
@@ -161,6 +182,14 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
responses=self.get_response_schemas(response_serializers)
|
responses=self.get_response_schemas(response_serializers)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_default_response_serializer(self):
|
||||||
|
"""Return the default response serializer for this endpoint. This is derived from either the ``request_body``
|
||||||
|
override or the request serializer (:meth:`.get_view_serializer`).
|
||||||
|
|
||||||
|
:return: response serializer, :class:`.Schema`, :class:`.SchemaRef`, ``None``
|
||||||
|
"""
|
||||||
|
return self._get_request_body_override() or self.get_view_serializer()
|
||||||
|
|
||||||
def get_default_responses(self):
|
def get_default_responses(self):
|
||||||
"""Get the default responses determined for this view from the request serializer and request method.
|
"""Get the default responses determined for this view from the request serializer and request method.
|
||||||
|
|
||||||
@@ -171,7 +200,7 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
default_status = guess_response_status(method)
|
default_status = guess_response_status(method)
|
||||||
default_schema = ''
|
default_schema = ''
|
||||||
if method in ('get', 'post', 'put', 'patch'):
|
if method in ('get', 'post', 'put', 'patch'):
|
||||||
default_schema = self.get_request_serializer() or self.get_view_serializer()
|
default_schema = self.get_default_response_serializer()
|
||||||
|
|
||||||
default_schema = default_schema or ''
|
default_schema = default_schema or ''
|
||||||
if any(is_form_media_type(encoding) for encoding in self.get_consumes()):
|
if any(is_form_media_type(encoding) for encoding in self.get_consumes()):
|
||||||
@@ -217,8 +246,10 @@ class SwaggerAutoSchema(ViewInspector):
|
|||||||
for sc, serializer in response_serializers.items():
|
for sc, serializer in response_serializers.items():
|
||||||
if isinstance(serializer, str):
|
if isinstance(serializer, str):
|
||||||
response = openapi.Response(
|
response = openapi.Response(
|
||||||
description=serializer
|
description=force_real_str(serializer)
|
||||||
)
|
)
|
||||||
|
elif not serializer:
|
||||||
|
continue
|
||||||
elif isinstance(serializer, openapi.Response):
|
elif isinstance(serializer, openapi.Response):
|
||||||
response = serializer
|
response = serializer
|
||||||
if hasattr(response, 'schema') and not isinstance(response.schema, openapi.Schema.OR_REF):
|
if hasattr(response, 'schema') and not isinstance(response.schema, openapi.Schema.OR_REF):
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth import get_user_model
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from rest_framework.test import APIRequestFactory, force_authenticate
|
from rest_framework.test import APIRequestFactory, force_authenticate
|
||||||
@@ -12,7 +13,15 @@ from rest_framework.views import APIView
|
|||||||
from ... import openapi
|
from ... import openapi
|
||||||
from ...app_settings import swagger_settings
|
from ...app_settings import swagger_settings
|
||||||
from ...codecs import OpenAPICodecJson, OpenAPICodecYaml
|
from ...codecs import OpenAPICodecJson, OpenAPICodecYaml
|
||||||
from ...generators import OpenAPISchemaGenerator
|
|
||||||
|
|
||||||
|
def import_class(import_string):
|
||||||
|
if not import_string:
|
||||||
|
return None
|
||||||
|
|
||||||
|
module_path, class_name = import_string.rsplit('.', 1)
|
||||||
|
module = import_module(module_path)
|
||||||
|
return getattr(module, class_name)
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -50,9 +59,13 @@ class Command(BaseCommand):
|
|||||||
help='Use a mock request when generating the swagger schema. This is useful if your views or serializers'
|
help='Use a mock request when generating the swagger schema. This is useful if your views or serializers'
|
||||||
'depend on context from a request in order to function.'
|
'depend on context from a request in order to function.'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--api-version', dest='api_version',
|
||||||
|
type=str,
|
||||||
|
help='Version to use to generate schema. This option implies --mock-request.'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--user', dest='user',
|
'--user', dest='user',
|
||||||
default='',
|
|
||||||
help='Username of an existing user to use for mocked authentication. This option implies --mock-request.'
|
help='Username of an existing user to use for mocked authentication. This option implies --mock-request.'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -64,6 +77,11 @@ class Command(BaseCommand):
|
|||||||
'OpenAPISchemaGenerator.get_schema().\n'
|
'OpenAPISchemaGenerator.get_schema().\n'
|
||||||
'This option implies --mock-request.'
|
'This option implies --mock-request.'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-g', '--generator-class', dest='generator_class_name',
|
||||||
|
default='',
|
||||||
|
help='Import string pointing to an OpenAPISchemaGenerator subclass to use for schema generation.'
|
||||||
|
)
|
||||||
|
|
||||||
def write_schema(self, schema, stream, format):
|
def write_schema(self, schema, stream, format):
|
||||||
if format == 'json':
|
if format == 'json':
|
||||||
@@ -89,7 +107,8 @@ class Command(BaseCommand):
|
|||||||
request = APIView().initialize_request(request)
|
request = APIView().initialize_request(request)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
def handle(self, output_file, overwrite, format, api_url, mock, user, private, *args, **options):
|
def handle(self, output_file, overwrite, format, api_url, mock, api_version, user, private, generator_class_name,
|
||||||
|
*args, **kwargs):
|
||||||
# disable logs of WARNING and below
|
# disable logs of WARNING and below
|
||||||
logging.disable(logging.WARNING)
|
logging.disable(logging.WARNING)
|
||||||
|
|
||||||
@@ -107,19 +126,30 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
api_url = api_url or swagger_settings.DEFAULT_API_URL
|
api_url = api_url or swagger_settings.DEFAULT_API_URL
|
||||||
|
|
||||||
user = User.objects.get(username=user) if user else None
|
if user:
|
||||||
mock = mock or private or (user is not None)
|
# Only call get_user_model if --user was passed in order to
|
||||||
|
# avoid crashing if auth is not configured in the project
|
||||||
|
user = get_user_model().objects.get(username=user)
|
||||||
|
|
||||||
|
mock = mock or private or (user is not None) or (api_version is not None)
|
||||||
if mock and not api_url:
|
if mock and not api_url:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
'--mock-request requires an API url; either provide '
|
'--mock-request requires an API url; either provide '
|
||||||
'the --url argument or set the DEFAULT_API_URL setting'
|
'the --url argument or set the DEFAULT_API_URL setting'
|
||||||
)
|
)
|
||||||
|
|
||||||
request = self.get_mock_request(api_url, format, user) if mock else None
|
request = None
|
||||||
|
if mock:
|
||||||
|
request = self.get_mock_request(api_url, format, user)
|
||||||
|
|
||||||
generator = OpenAPISchemaGenerator(
|
if request and api_version:
|
||||||
|
request.version = api_version
|
||||||
|
|
||||||
|
generator_class = import_class(generator_class_name) or swagger_settings.DEFAULT_GENERATOR_CLASS
|
||||||
|
generator = generator_class(
|
||||||
info=info,
|
info=info,
|
||||||
url=api_url
|
version=api_version,
|
||||||
|
url=api_url,
|
||||||
)
|
)
|
||||||
schema = generator.get_schema(request=request, public=not private)
|
schema = generator.get_schema(request=request, public=not private)
|
||||||
|
|
||||||
|
|||||||
+12
-9
@@ -116,7 +116,7 @@ class SwaggerDict(OrderedDict):
|
|||||||
which would result in the extra attributes being added first. For this reason, we defer the insertion of the
|
which would result in the extra attributes being added first. For this reason, we defer the insertion of the
|
||||||
attributes and require that subclasses call ._insert_extras__ at the end of their __init__ method.
|
attributes and require that subclasses call ._insert_extras__ at the end of their __init__ method.
|
||||||
"""
|
"""
|
||||||
for attr, val in self._extras__.items():
|
for attr, val in sorted(self._extras__.items()):
|
||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -221,7 +221,7 @@ class Swagger(SwaggerDict):
|
|||||||
:param str _prefix: api path prefix to use in setting basePath; this will be appended to the wsgi
|
:param str _prefix: api path prefix to use in setting basePath; this will be appended to the wsgi
|
||||||
SCRIPT_NAME prefix or Django's FORCE_SCRIPT_NAME if applicable
|
SCRIPT_NAME prefix or Django's FORCE_SCRIPT_NAME if applicable
|
||||||
:param str _version: version string to override Info
|
:param str _version: version string to override Info
|
||||||
:param list[dict] security_definitions: list of supported authentication mechanisms
|
:param dict[str,dict[str,str]] security_definitions: list of supported authentication mechanisms
|
||||||
:param list[dict] security: authentication mechanisms accepted by default; can be overriden in Operation
|
:param list[dict] security: authentication mechanisms accepted by default; can be overriden in Operation
|
||||||
:param list[str] consumes: consumed MIME types; can be overriden in Operation
|
:param list[str] consumes: consumed MIME types; can be overriden in Operation
|
||||||
:param list[str] produces: produced MIME types; can be overriden in Operation
|
:param list[str] produces: produced MIME types; can be overriden in Operation
|
||||||
@@ -437,7 +437,7 @@ class Schema(SwaggerDict):
|
|||||||
super(Schema, self).__init__(**extra)
|
super(Schema, self).__init__(**extra)
|
||||||
if required is True or required is False:
|
if required is True or required is False:
|
||||||
# common error
|
# common error
|
||||||
raise AssertionError("the `requires` attribute of schema must be an "
|
raise AssertionError("the `required` attribute of schema must be an "
|
||||||
"array of required property names, not a boolean!")
|
"array of required property names, not a boolean!")
|
||||||
assert type, "type is required!"
|
assert type, "type is required!"
|
||||||
self.title = title
|
self.title = title
|
||||||
@@ -466,7 +466,7 @@ class Schema(SwaggerDict):
|
|||||||
class _Ref(SwaggerDict):
|
class _Ref(SwaggerDict):
|
||||||
ref_name_re = re.compile(r"#/(?P<scope>.+)/(?P<name>[^/]+)$")
|
ref_name_re = re.compile(r"#/(?P<scope>.+)/(?P<name>[^/]+)$")
|
||||||
|
|
||||||
def __init__(self, resolver, name, scope, expected_type):
|
def __init__(self, resolver, name, scope, expected_type, ignore_unresolved=False):
|
||||||
"""Base class for all reference types. A reference object has only one property, ``$ref``, which must be a JSON
|
"""Base class for all reference types. A reference object has only one property, ``$ref``, which must be a JSON
|
||||||
reference to a valid object in the specification, e.g. ``#/definitions/Article`` to refer to an article model.
|
reference to a valid object in the specification, e.g. ``#/definitions/Article`` to refer to an article model.
|
||||||
|
|
||||||
@@ -474,13 +474,15 @@ class _Ref(SwaggerDict):
|
|||||||
:param str name: referenced object name, e.g. "Article"
|
:param str name: referenced object name, e.g. "Article"
|
||||||
:param str scope: reference scope, e.g. "definitions"
|
:param str scope: reference scope, e.g. "definitions"
|
||||||
:param type[.SwaggerDict] expected_type: the expected type that will be asserted on the object found in resolver
|
:param type[.SwaggerDict] expected_type: the expected type that will be asserted on the object found in resolver
|
||||||
|
:param bool ignore_unresolved: allow the reference to be not defined in resolver
|
||||||
"""
|
"""
|
||||||
super(_Ref, self).__init__()
|
super(_Ref, self).__init__()
|
||||||
assert not type(self) == _Ref, "do not instantiate _Ref directly"
|
assert not type(self) == _Ref, "do not instantiate _Ref directly"
|
||||||
ref_name = "#/{scope}/{name}".format(scope=scope, name=name)
|
ref_name = "#/{scope}/{name}".format(scope=scope, name=name)
|
||||||
obj = resolver.get(name, scope)
|
if not ignore_unresolved:
|
||||||
assert isinstance(obj, expected_type), ref_name + " is a {actual}, not a {expected}" \
|
obj = resolver.get(name, scope)
|
||||||
.format(actual=type(obj).__name__, expected=expected_type.__name__)
|
assert isinstance(obj, expected_type), ref_name + " is a {actual}, not a {expected}" \
|
||||||
|
.format(actual=type(obj).__name__, expected=expected_type.__name__)
|
||||||
self.ref = ref_name
|
self.ref = ref_name
|
||||||
|
|
||||||
def resolve(self, resolver):
|
def resolve(self, resolver):
|
||||||
@@ -502,14 +504,15 @@ class _Ref(SwaggerDict):
|
|||||||
|
|
||||||
|
|
||||||
class SchemaRef(_Ref):
|
class SchemaRef(_Ref):
|
||||||
def __init__(self, resolver, schema_name):
|
def __init__(self, resolver, schema_name, ignore_unresolved=False):
|
||||||
"""Adds a reference to a named Schema defined in the ``#/definitions/`` object.
|
"""Adds a reference to a named Schema defined in the ``#/definitions/`` object.
|
||||||
|
|
||||||
:param .ReferenceResolver resolver: component resolver which must contain the definition
|
:param .ReferenceResolver resolver: component resolver which must contain the definition
|
||||||
:param str schema_name: schema name
|
:param str schema_name: schema name
|
||||||
|
:param bool ignore_unresolved: allow the reference to be not defined in resolver
|
||||||
"""
|
"""
|
||||||
assert SCHEMA_DEFINITIONS in resolver.scopes
|
assert SCHEMA_DEFINITIONS in resolver.scopes
|
||||||
super(SchemaRef, self).__init__(resolver, schema_name, SCHEMA_DEFINITIONS, Schema)
|
super(SchemaRef, self).__init__(resolver, schema_name, SCHEMA_DEFINITIONS, Schema, ignore_unresolved)
|
||||||
|
|
||||||
|
|
||||||
Schema.OR_REF = (Schema, SchemaRef)
|
Schema.OR_REF = (Schema, SchemaRef)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from django.shortcuts import render, resolve_url
|
from django.shortcuts import render, resolve_url
|
||||||
from rest_framework.renderers import BaseRenderer, TemplateHTMLRenderer
|
from rest_framework.renderers import BaseRenderer, JSONRenderer, TemplateHTMLRenderer
|
||||||
from rest_framework.utils import json
|
from rest_framework.utils import json
|
||||||
|
|
||||||
from drf_yasg.openapi import Swagger
|
from drf_yasg.openapi import Swagger
|
||||||
@@ -10,7 +10,7 @@ from .codecs import VALIDATORS, OpenAPICodecJson, OpenAPICodecYaml
|
|||||||
|
|
||||||
class _SpecRenderer(BaseRenderer):
|
class _SpecRenderer(BaseRenderer):
|
||||||
"""Base class for text renderers. Handles encoding and validation."""
|
"""Base class for text renderers. Handles encoding and validation."""
|
||||||
charset = None
|
charset = 'utf-8'
|
||||||
validators = []
|
validators = []
|
||||||
codec_class = None
|
codec_class = None
|
||||||
|
|
||||||
@@ -22,6 +22,12 @@ class _SpecRenderer(BaseRenderer):
|
|||||||
def render(self, data, media_type=None, renderer_context=None):
|
def render(self, data, media_type=None, renderer_context=None):
|
||||||
assert self.codec_class, "must override codec_class"
|
assert self.codec_class, "must override codec_class"
|
||||||
codec = self.codec_class(self.validators)
|
codec = self.codec_class(self.validators)
|
||||||
|
|
||||||
|
if not isinstance(data, Swagger): # pragma: no cover
|
||||||
|
# if `swagger` is not a ``Swagger`` object, it means we somehow got a non-success ``Response``
|
||||||
|
# in that case, it's probably better to let the default ``TemplateHTMLRenderer`` render it
|
||||||
|
# see https://github.com/axnsan12/drf-yasg/issues/58
|
||||||
|
return JSONRenderer().render(data, media_type, renderer_context)
|
||||||
return codec.encode(data)
|
return codec.encode(data)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +59,7 @@ class _UIRenderer(BaseRenderer):
|
|||||||
template = ''
|
template = ''
|
||||||
|
|
||||||
def render(self, swagger, accepted_media_type=None, renderer_context=None):
|
def render(self, swagger, accepted_media_type=None, renderer_context=None):
|
||||||
if not isinstance(swagger, Swagger):
|
if not isinstance(swagger, Swagger): # pragma: no cover
|
||||||
# if `swagger` is not a ``Swagger`` object, it means we somehow got a non-success ``Response``
|
# if `swagger` is not a ``Swagger`` object, it means we somehow got a non-success ``Response``
|
||||||
# in that case, it's probably better to let the default ``TemplateHTMLRenderer`` render it
|
# in that case, it's probably better to let the default ``TemplateHTMLRenderer`` render it
|
||||||
# see https://github.com/axnsan12/drf-yasg/issues/58
|
# see https://github.com/axnsan12/drf-yasg/issues/58
|
||||||
@@ -93,6 +99,7 @@ class _UIRenderer(BaseRenderer):
|
|||||||
'defaultModelRendering': swagger_settings.DEFAULT_MODEL_RENDERING,
|
'defaultModelRendering': swagger_settings.DEFAULT_MODEL_RENDERING,
|
||||||
'defaultModelExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
'defaultModelExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
||||||
'defaultModelsExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
'defaultModelsExpandDepth': swagger_settings.DEFAULT_MODEL_DEPTH,
|
||||||
|
'showCommonExtensions': swagger_settings.SHOW_COMMON_EXTENSIONS,
|
||||||
'oauth2RedirectUrl': swagger_settings.OAUTH2_REDIRECT_URL,
|
'oauth2RedirectUrl': swagger_settings.OAUTH2_REDIRECT_URL,
|
||||||
'supportedSubmitMethods': swagger_settings.SUPPORTED_SUBMIT_METHODS,
|
'supportedSubmitMethods': swagger_settings.SUPPORTED_SUBMIT_METHODS,
|
||||||
}
|
}
|
||||||
|
|||||||
+113
-3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,18 +0,0 @@
|
|||||||
{% load static %}
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>{{ title }}</title>
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'drf-yasg/style.css' %}"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script id="redoc-settings" type="application/json">{{ redoc_settings | safe }}</script>
|
|
||||||
|
|
||||||
<script src="{% static 'drf-yasg/insQ.min.js' %}"></script>
|
|
||||||
<script src="{% static 'drf-yasg/redoc-init.js' %}"> </script>
|
|
||||||
<script src="{% static 'drf-yasg/redoc-alpha/redoc.standalone.js' %}"> </script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
+49
-9
@@ -3,6 +3,7 @@ import logging
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.encoding import force_text
|
||||||
from rest_framework import serializers, status
|
from rest_framework import serializers, status
|
||||||
from rest_framework.mixins import DestroyModelMixin, RetrieveModelMixin, UpdateModelMixin
|
from rest_framework.mixins import DestroyModelMixin, RetrieveModelMixin, UpdateModelMixin
|
||||||
from rest_framework.request import is_form_media_type
|
from rest_framework.request import is_form_media_type
|
||||||
@@ -66,7 +67,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
|
|
||||||
:param str operation_id: operation ID override; the operation ID must be unique accross the whole API
|
:param str operation_id: operation ID override; the operation ID must be unique accross the whole API
|
||||||
:param str operation_description: operation description override
|
:param str operation_description: operation description override
|
||||||
:param str security: security requirements override; used to specify which authetication mechanism
|
:param list[dict] security: security requirements override; used to specify which authetication mechanism
|
||||||
is requried to call this API; an empty list marks the endpoint as unauthenticated (i.e. removes all accepted
|
is requried to call this API; an empty list marks the endpoint as unauthenticated (i.e. removes all accepted
|
||||||
authentication schemes), and ``None`` will inherit the top-level secuirty requirements
|
authentication schemes), and ``None`` will inherit the top-level secuirty requirements
|
||||||
:param dict[str,(.Schema,.SchemaRef,.Response,str,Serializer)] responses: a dict of documented manual responses
|
:param dict[str,(.Schema,.SchemaRef,.Response,str,Serializer)] responses: a dict of documented manual responses
|
||||||
@@ -76,6 +77,8 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
|
|
||||||
* if a plain string is given as value, a :class:`.Response` with no body and that string as its description
|
* if a plain string is given as value, a :class:`.Response` with no body and that string as its description
|
||||||
will be generated
|
will be generated
|
||||||
|
* if ``None`` is given as a value, the response is ignored; this is mainly useful for disabling default
|
||||||
|
2xx responses, i.e. ``responses={200: None, 302: 'something'}``
|
||||||
* if a :class:`.Schema`, :class:`.SchemaRef` is given, a :class:`.Response` with the schema as its body and
|
* if a :class:`.Schema`, :class:`.SchemaRef` is given, a :class:`.Response` with the schema as its body and
|
||||||
an empty description will be generated
|
an empty description will be generated
|
||||||
* a ``Serializer`` class or instance will be converted into a :class:`.Schema` and treated as above
|
* a ``Serializer`` class or instance will be converted into a :class:`.Schema` and treated as above
|
||||||
@@ -114,7 +117,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
# no overrides to set, no use in doing more work
|
# no overrides to set, no use in doing more work
|
||||||
return
|
return
|
||||||
|
|
||||||
# if the method is a detail_route or list_route, it will have a bind_to_methods attribute
|
# if the method is an @action, it will have a bind_to_methods attribute
|
||||||
bind_to_methods = getattr(view_method, 'bind_to_methods', [])
|
bind_to_methods = getattr(view_method, 'bind_to_methods', [])
|
||||||
# if the method is actually a function based view (@api_view), it will have a 'cls' attribute
|
# if the method is actually a function based view (@api_view), it will have a 'cls' attribute
|
||||||
view_cls = getattr(view_method, 'cls', None)
|
view_cls = getattr(view_method, 'cls', None)
|
||||||
@@ -126,7 +129,7 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
_methods = methods
|
_methods = methods
|
||||||
if methods or method:
|
if methods or method:
|
||||||
assert available_methods or http_method_names, "`method` or `methods` can only be specified " \
|
assert available_methods or http_method_names, "`method` or `methods` can only be specified " \
|
||||||
"on @detail_route or @api_view views"
|
"on @action or @api_view views"
|
||||||
assert bool(methods) != bool(method), "specify either method or methods"
|
assert bool(methods) != bool(method), "specify either method or methods"
|
||||||
assert not isinstance(methods, str), "`methods` expects to receive a list of methods;" \
|
assert not isinstance(methods, str), "`methods` expects to receive a list of methods;" \
|
||||||
" use `method` for a single argument"
|
" use `method` for a single argument"
|
||||||
@@ -138,13 +141,13 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
assert not any(mth in existing_data for mth in _methods), "http method defined multiple times"
|
assert not any(mth in existing_data for mth in _methods), "http method defined multiple times"
|
||||||
|
|
||||||
if available_methods:
|
if available_methods:
|
||||||
# detail_route, list_route or api_view
|
# action or api_view
|
||||||
assert bool(http_method_names) != bool(bind_to_methods), "this should never happen"
|
assert bool(http_method_names) != bool(bind_to_methods), "this should never happen"
|
||||||
|
|
||||||
if len(available_methods) > 1:
|
if len(available_methods) > 1:
|
||||||
assert _methods, \
|
assert _methods, \
|
||||||
"on multi-method api_view, detail_route or list_route, you must specify swagger_auto_schema on " \
|
"on multi-method api_view, action, detail_route or list_route, you must specify " \
|
||||||
"a per-method basis using one of the `method` or `methods` arguments"
|
"swagger_auto_schema on a per-method basis using one of the `method` or `methods` arguments"
|
||||||
else:
|
else:
|
||||||
# for a single-method view we assume that single method as the decorator target
|
# for a single-method view we assume that single method as the decorator target
|
||||||
_methods = _methods or available_methods
|
_methods = _methods or available_methods
|
||||||
@@ -156,8 +159,9 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
|
|||||||
view_method._swagger_auto_schema = existing_data
|
view_method._swagger_auto_schema = existing_data
|
||||||
else:
|
else:
|
||||||
assert not _methods, \
|
assert not _methods, \
|
||||||
"the methods argument should only be specified when decorating a detail_route or list_route; you " \
|
"the methods argument should only be specified when decorating an action, detail_route or " \
|
||||||
"should also ensure that you put the swagger_auto_schema decorator AFTER (above) the _route decorator"
|
"list_route; you should also ensure that you put the swagger_auto_schema decorator " \
|
||||||
|
"AFTER (above) the _route decorator"
|
||||||
assert not existing_data, "swagger_auto_schema applied twice to method"
|
assert not existing_data, "swagger_auto_schema applied twice to method"
|
||||||
view_method._swagger_auto_schema = data
|
view_method._swagger_auto_schema = data
|
||||||
|
|
||||||
@@ -183,7 +187,7 @@ def is_list_view(path, method, view):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if action in ('retrieve', 'update', 'partial_update', 'destroy') or detail is True or suffix == 'Instance':
|
if action in ('retrieve', 'update', 'partial_update', 'destroy') or detail is True or suffix == 'Instance':
|
||||||
# a detail_route is surely not a list route
|
# a detail action is surely not a list route
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# for GenericAPIView, if it's a detail view it can't also be a list view
|
# for GenericAPIView, if it's a detail view it can't also be a list view
|
||||||
@@ -294,3 +298,39 @@ def decimal_as_float(field):
|
|||||||
if isinstance(field, serializers.DecimalField) or isinstance(field, models.DecimalField):
|
if isinstance(field, serializers.DecimalField) or isinstance(field, models.DecimalField):
|
||||||
return not getattr(field, 'coerce_to_string', rest_framework_settings.COERCE_DECIMAL_TO_STRING)
|
return not getattr(field, 'coerce_to_string', rest_framework_settings.COERCE_DECIMAL_TO_STRING)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def get_serializer_ref_name(serializer):
|
||||||
|
"""
|
||||||
|
Get serializer's ref_name (or None for ModelSerializer if it is named 'NestedSerializer')
|
||||||
|
|
||||||
|
:param serializer: Serializer instance
|
||||||
|
:return: Serializer's ``ref_name`` or ``None`` for inline serializer
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
serializer_meta = getattr(serializer, 'Meta', None)
|
||||||
|
serializer_name = type(serializer).__name__
|
||||||
|
if hasattr(serializer_meta, 'ref_name'):
|
||||||
|
ref_name = serializer_meta.ref_name
|
||||||
|
elif serializer_name == 'NestedSerializer' and isinstance(serializer, serializers.ModelSerializer):
|
||||||
|
logger.debug("Forcing inline output for ModelSerializer named 'NestedSerializer': " + str(serializer))
|
||||||
|
ref_name = None
|
||||||
|
else:
|
||||||
|
ref_name = serializer_name
|
||||||
|
if ref_name.endswith('Serializer'):
|
||||||
|
ref_name = ref_name[:-len('Serializer')]
|
||||||
|
return ref_name
|
||||||
|
|
||||||
|
|
||||||
|
def force_real_str(s, encoding='utf-8', strings_only=False, errors='strict'):
|
||||||
|
"""
|
||||||
|
Force `s` into a ``str`` instance.
|
||||||
|
|
||||||
|
Fix for https://github.com/axnsan12/drf-yasg/issues/159
|
||||||
|
"""
|
||||||
|
if s is not None:
|
||||||
|
s = force_text(s, encoding, strings_only, errors)
|
||||||
|
if type(s) != str:
|
||||||
|
s = '' + s
|
||||||
|
|
||||||
|
return s
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from rest_framework.settings import api_settings
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
from .app_settings import swagger_settings
|
from .app_settings import swagger_settings
|
||||||
from .generators import OpenAPISchemaGenerator
|
|
||||||
from .renderers import OpenAPIRenderer, ReDocRenderer, SwaggerJSONRenderer, SwaggerUIRenderer, SwaggerYAMLRenderer
|
from .renderers import OpenAPIRenderer, ReDocRenderer, SwaggerJSONRenderer, SwaggerUIRenderer, SwaggerYAMLRenderer
|
||||||
|
|
||||||
SPEC_RENDERERS = (SwaggerYAMLRenderer, SwaggerJSONRenderer, OpenAPIRenderer)
|
SPEC_RENDERERS = (SwaggerYAMLRenderer, SwaggerJSONRenderer, OpenAPIRenderer)
|
||||||
@@ -46,7 +45,7 @@ def deferred_never_cache(view_func):
|
|||||||
|
|
||||||
|
|
||||||
def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=False, validators=None,
|
def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=False, validators=None,
|
||||||
generator_class=OpenAPISchemaGenerator,
|
generator_class=swagger_settings.DEFAULT_GENERATOR_CLASS,
|
||||||
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
|
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
|
||||||
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES):
|
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES):
|
||||||
"""Create a SchemaView class with default renderers and generators.
|
"""Create a SchemaView class with default renderers and generators.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ArticleSerializer(serializers.ModelSerializer):
|
|||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
uuid = serializers.UUIDField(help_text="should articles have UUIDs?", read_only=True)
|
uuid = serializers.UUIDField(help_text="should articles have UUIDs?", read_only=True)
|
||||||
cover_name = serializers.FileField(use_url=False, source='cover', read_only=True)
|
cover_name = serializers.FileField(use_url=False, source='cover', required=True)
|
||||||
group = serializers.SlugRelatedField(slug_field='uuid', queryset=ArticleGroup.objects.all())
|
group = serializers.SlugRelatedField(slug_field='uuid', queryset=ArticleGroup.objects.all())
|
||||||
original_group = serializers.SlugRelatedField(slug_field='uuid', read_only=True)
|
original_group = serializers.SlugRelatedField(slug_field='uuid', read_only=True)
|
||||||
|
|
||||||
|
|||||||
+42
-16
@@ -3,6 +3,7 @@ import datetime
|
|||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
# noinspection PyDeprecation
|
||||||
from rest_framework.decorators import detail_route, list_route
|
from rest_framework.decorators import detail_route, list_route
|
||||||
from rest_framework.filters import OrderingFilter
|
from rest_framework.filters import OrderingFilter
|
||||||
from rest_framework.pagination import LimitOffsetPagination
|
from rest_framework.pagination import LimitOffsetPagination
|
||||||
@@ -89,23 +90,48 @@ class ArticleViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
swagger_schema = NoTitleAutoSchema
|
swagger_schema = NoTitleAutoSchema
|
||||||
|
|
||||||
@swagger_auto_schema(auto_schema=NoPagingAutoSchema, filter_inspectors=[DjangoFilterDescriptionInspector])
|
try:
|
||||||
@list_route(methods=['get'])
|
from rest_framework.decorators import action
|
||||||
def today(self, request):
|
|
||||||
today_min = datetime.datetime.combine(datetime.date.today(), datetime.time.min)
|
|
||||||
today_max = datetime.datetime.combine(datetime.date.today(), datetime.time.max)
|
|
||||||
articles = self.get_queryset().filter(date_created__range=(today_min, today_max)).all()
|
|
||||||
serializer = self.serializer_class(articles, many=True)
|
|
||||||
return Response(serializer.data)
|
|
||||||
|
|
||||||
@swagger_auto_schema(method='get', operation_description="image GET description override")
|
@swagger_auto_schema(auto_schema=NoPagingAutoSchema, filter_inspectors=[DjangoFilterDescriptionInspector])
|
||||||
@swagger_auto_schema(method='post', request_body=serializers.ImageUploadSerializer)
|
@action(detail=False, methods=['get'])
|
||||||
@detail_route(methods=['get', 'post'], parser_classes=(MultiPartParser,))
|
def today(self, request):
|
||||||
def image(self, request, slug=None):
|
today_min = datetime.datetime.combine(datetime.date.today(), datetime.time.min)
|
||||||
"""
|
today_max = datetime.datetime.combine(datetime.date.today(), datetime.time.max)
|
||||||
image method docstring
|
articles = self.get_queryset().filter(date_created__range=(today_min, today_max)).all()
|
||||||
"""
|
serializer = self.serializer_class(articles, many=True)
|
||||||
pass
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
@swagger_auto_schema(method='get', operation_description="image GET description override")
|
||||||
|
@swagger_auto_schema(method='post', request_body=serializers.ImageUploadSerializer)
|
||||||
|
@action(detail=True, methods=['get', 'post'], parser_classes=(MultiPartParser,))
|
||||||
|
def image(self, request, slug=None):
|
||||||
|
"""
|
||||||
|
image method docstring
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
except ImportError:
|
||||||
|
action = None
|
||||||
|
|
||||||
|
# noinspection PyDeprecation
|
||||||
|
@swagger_auto_schema(auto_schema=NoPagingAutoSchema, filter_inspectors=[DjangoFilterDescriptionInspector])
|
||||||
|
@list_route(methods=['get'])
|
||||||
|
def today(self, request):
|
||||||
|
today_min = datetime.datetime.combine(datetime.date.today(), datetime.time.min)
|
||||||
|
today_max = datetime.datetime.combine(datetime.date.today(), datetime.time.max)
|
||||||
|
articles = self.get_queryset().filter(date_created__range=(today_min, today_max)).all()
|
||||||
|
serializer = self.serializer_class(articles, many=True)
|
||||||
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
# noinspection PyDeprecation
|
||||||
|
@swagger_auto_schema(method='get', operation_description="image GET description override")
|
||||||
|
@swagger_auto_schema(method='post', request_body=serializers.ImageUploadSerializer)
|
||||||
|
@detail_route(methods=['get', 'post'], parser_classes=(MultiPartParser,))
|
||||||
|
def image(self, request, slug=None):
|
||||||
|
"""
|
||||||
|
image method docstring
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def update(self, request, *args, **kwargs):
|
def update(self, request, *args, **kwargs):
|
||||||
"""update method docstring"""
|
"""update method docstring"""
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
|
|
||||||
class Identity(models.Model):
|
class Identity(models.Model):
|
||||||
firstName = models.CharField(max_length=30, null=True)
|
firstName = models.CharField(max_length=30, null=True)
|
||||||
lastName = models.CharField(max_length=30, null=True)
|
lastName = models.CharField(max_length=30, null=True, help_text=mark_safe("<strong>Here's some HTML!</strong>"))
|
||||||
|
|
||||||
|
|
||||||
class Person(models.Model):
|
class Person(models.Model):
|
||||||
|
|||||||
+35
-12
@@ -33,6 +33,21 @@ class SnippetList(generics.ListCreateAPIView):
|
|||||||
"""post method docstring"""
|
"""post method docstring"""
|
||||||
return super(SnippetList, self).post(request, *args, **kwargs)
|
return super(SnippetList, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@swagger_auto_schema(
|
||||||
|
operation_id='snippets_delete_bulk',
|
||||||
|
request_body=openapi.Schema(
|
||||||
|
type=openapi.TYPE_OBJECT,
|
||||||
|
properties={
|
||||||
|
'body': openapi.Schema(
|
||||||
|
type=openapi.TYPE_STRING,
|
||||||
|
description='this should not crash (request body on DELETE method)'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def delete(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
|
class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
"""
|
"""
|
||||||
@@ -56,18 +71,26 @@ class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
"""patch method docstring"""
|
"""patch method docstring"""
|
||||||
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
||||||
|
|
||||||
@swagger_auto_schema(manual_parameters=[
|
@swagger_auto_schema(
|
||||||
openapi.Parameter(
|
manual_parameters=[
|
||||||
name='id', in_=openapi.IN_PATH,
|
openapi.Parameter(
|
||||||
type=openapi.TYPE_INTEGER,
|
name='id', in_=openapi.IN_PATH,
|
||||||
description="path parameter override",
|
type=openapi.TYPE_INTEGER,
|
||||||
required=True
|
description="path parameter override",
|
||||||
),
|
required=True
|
||||||
], responses={
|
),
|
||||||
status.HTTP_204_NO_CONTENT: openapi.Response(
|
openapi.Parameter(
|
||||||
description="This should not crash"
|
name='delete_form_param', in_=openapi.IN_FORM,
|
||||||
)
|
type=openapi.TYPE_INTEGER,
|
||||||
})
|
description="this should not crash (form parameter on DELETE method)"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
responses={
|
||||||
|
status.HTTP_204_NO_CONTENT: openapi.Response(
|
||||||
|
description="this should not crash (response object with no schema)"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
def delete(self, request, *args, **kwargs):
|
def delete(self, request, *args, **kwargs):
|
||||||
"""delete method docstring"""
|
"""delete method docstring"""
|
||||||
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
return super(SnippetDetail, self).patch(request, *args, **kwargs)
|
||||||
|
|||||||
@@ -94,7 +94,18 @@ SWAGGER_SETTINGS = {
|
|||||||
'LOGIN_URL': '/admin/login',
|
'LOGIN_URL': '/admin/login',
|
||||||
'LOGOUT_URL': '/admin/logout',
|
'LOGOUT_URL': '/admin/logout',
|
||||||
|
|
||||||
'DEFAULT_INFO': 'testproj.urls.swagger_info'
|
'DEFAULT_INFO': 'testproj.urls.swagger_info',
|
||||||
|
|
||||||
|
'SECURITY_DEFINITIONS': {
|
||||||
|
'Basic': {
|
||||||
|
'type': 'basic'
|
||||||
|
},
|
||||||
|
'Bearer': {
|
||||||
|
'type': 'apiKey',
|
||||||
|
'name': 'Authorization',
|
||||||
|
'in': 'header'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 2.0.4 on 2018-04-26 13:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('todo', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TodoTree',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=50)),
|
||||||
|
('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name='children', to='todo.TodoTree')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -13,3 +13,8 @@ class TodoAnother(models.Model):
|
|||||||
class TodoYetAnother(models.Model):
|
class TodoYetAnother(models.Model):
|
||||||
todo = models.ForeignKey(TodoAnother, on_delete=models.CASCADE)
|
todo = models.ForeignKey(TodoAnother, on_delete=models.CASCADE)
|
||||||
title = models.CharField(max_length=50)
|
title = models.CharField(max_length=50)
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTree(models.Model):
|
||||||
|
parent = models.ForeignKey('self', on_delete=models.CASCADE, related_name='children', null=True)
|
||||||
|
title = models.CharField(max_length=50)
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from rest_framework_recursive.fields import RecursiveField
|
||||||
|
|
||||||
from .models import Todo, TodoAnother, TodoYetAnother
|
from .models import Todo, TodoAnother, TodoTree, TodoYetAnother
|
||||||
|
|
||||||
|
|
||||||
class TodoSerializer(serializers.ModelSerializer):
|
class TodoSerializer(serializers.ModelSerializer):
|
||||||
@@ -25,3 +28,31 @@ class TodoYetAnotherSerializer(serializers.ModelSerializer):
|
|||||||
model = TodoYetAnother
|
model = TodoYetAnother
|
||||||
fields = ('title', 'todo')
|
fields = ('title', 'todo')
|
||||||
depth = 2
|
depth = 2
|
||||||
|
swagger_schema_fields = {
|
||||||
|
'example': OrderedDict([
|
||||||
|
('title', 'parent'),
|
||||||
|
('todo', OrderedDict([
|
||||||
|
('title', 'child'),
|
||||||
|
('todo', None),
|
||||||
|
])),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTreeSerializer(serializers.ModelSerializer):
|
||||||
|
children = serializers.ListField(child=RecursiveField(), source='children.all')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = TodoTree
|
||||||
|
fields = ('id', 'title', 'children')
|
||||||
|
|
||||||
|
|
||||||
|
class TodoRecursiveSerializer(serializers.ModelSerializer):
|
||||||
|
parent = RecursiveField(read_only=True)
|
||||||
|
parent_id = serializers.PrimaryKeyRelatedField(queryset=TodoTree.objects.all(), pk_field=serializers.IntegerField(),
|
||||||
|
write_only=True, allow_null=True, required=False, default=None,
|
||||||
|
source='parent')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = TodoTree
|
||||||
|
fields = ('id', 'title', 'parent', 'parent_id')
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from django.conf.urls import url
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
|
|
||||||
from todo import views
|
from todo import views
|
||||||
@@ -6,5 +7,12 @@ router = routers.DefaultRouter()
|
|||||||
router.register(r'', views.TodoViewSet)
|
router.register(r'', views.TodoViewSet)
|
||||||
router.register(r'another', views.TodoAnotherViewSet)
|
router.register(r'another', views.TodoAnotherViewSet)
|
||||||
router.register(r'yetanother', views.TodoYetAnotherViewSet)
|
router.register(r'yetanother', views.TodoYetAnotherViewSet)
|
||||||
|
router.register(r'tree', views.TodoTreeView)
|
||||||
|
router.register(r'recursive', views.TodoRecursiveView)
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
|
|
||||||
|
urlpatterns += [
|
||||||
|
url(r'^(?P<todo_id>\d+)/yetanothers/(?P<yetanother_id>\d+)/$',
|
||||||
|
views.NestedTodoView.as_view(), ),
|
||||||
|
]
|
||||||
|
|||||||
+57
-2
@@ -1,7 +1,12 @@
|
|||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
from rest_framework.generics import RetrieveAPIView
|
||||||
|
|
||||||
from .models import Todo, TodoAnother, TodoYetAnother
|
from drf_yasg.utils import swagger_auto_schema
|
||||||
from .serializer import TodoAnotherSerializer, TodoSerializer, TodoYetAnotherSerializer
|
|
||||||
|
from .models import Todo, TodoAnother, TodoTree, TodoYetAnother
|
||||||
|
from .serializer import (
|
||||||
|
TodoAnotherSerializer, TodoRecursiveSerializer, TodoSerializer, TodoTreeSerializer, TodoYetAnotherSerializer
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TodoViewSet(viewsets.ReadOnlyModelViewSet):
|
class TodoViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
@@ -20,3 +25,53 @@ class TodoAnotherViewSet(viewsets.ReadOnlyModelViewSet):
|
|||||||
class TodoYetAnotherViewSet(viewsets.ReadOnlyModelViewSet):
|
class TodoYetAnotherViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = TodoYetAnother.objects.all()
|
queryset = TodoYetAnother.objects.all()
|
||||||
serializer_class = TodoYetAnotherSerializer
|
serializer_class = TodoYetAnotherSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class NestedTodoView(RetrieveAPIView):
|
||||||
|
serializer_class = TodoYetAnotherSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTreeView(viewsets.ReadOnlyModelViewSet):
|
||||||
|
queryset = TodoTree.objects.all()
|
||||||
|
|
||||||
|
def get_serializer_class(self):
|
||||||
|
if getattr(self, 'swagger_fake_view', False):
|
||||||
|
return TodoTreeSerializer
|
||||||
|
|
||||||
|
raise NotImplementedError("must not call this")
|
||||||
|
|
||||||
|
|
||||||
|
class TodoRecursiveView(viewsets.ModelViewSet):
|
||||||
|
queryset = TodoTree.objects.all()
|
||||||
|
|
||||||
|
def get_serializer(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("must not call this")
|
||||||
|
|
||||||
|
def get_serializer_class(self):
|
||||||
|
raise NotImplementedError("must not call this")
|
||||||
|
|
||||||
|
def get_serializer_context(self):
|
||||||
|
raise NotImplementedError("must not call this")
|
||||||
|
|
||||||
|
@swagger_auto_schema(request_body=TodoRecursiveSerializer)
|
||||||
|
def create(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).create(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@swagger_auto_schema(responses={200: None, 302: 'Redirect somewhere'})
|
||||||
|
def retrieve(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).retrieve(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@swagger_auto_schema(request_body=TodoRecursiveSerializer)
|
||||||
|
def update(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).update(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@swagger_auto_schema(request_body=TodoRecursiveSerializer)
|
||||||
|
def partial_update(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).update(request, *args, **kwargs)
|
||||||
|
|
||||||
|
def destroy(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@swagger_auto_schema(responses={200: TodoRecursiveSerializer(many=True)})
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
return super(TodoRecursiveView, self).list(request, *args, **kwargs)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from six import StringIO
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -6,6 +8,7 @@ from collections import OrderedDict
|
|||||||
import pytest
|
import pytest
|
||||||
from datadiff.tools import assert_equal
|
from datadiff.tools import assert_equal
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.core.management import call_command
|
||||||
from rest_framework.test import APIRequestFactory
|
from rest_framework.test import APIRequestFactory
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
@@ -64,6 +67,21 @@ def validate_schema(db):
|
|||||||
return validate_schema
|
return validate_schema
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def call_generate_swagger():
|
||||||
|
def call_generate_swagger(output_file='-', overwrite=False, format='', api_url='',
|
||||||
|
mock=False, user=None, private=False, generator_class_name='', **kwargs):
|
||||||
|
out = StringIO()
|
||||||
|
call_command(
|
||||||
|
'generate_swagger', stdout=out,
|
||||||
|
output_file=output_file, overwrite=overwrite, format=format, api_url=api_url, mock=mock, user=user,
|
||||||
|
private=private, generator_class_name=generator_class_name, **kwargs
|
||||||
|
)
|
||||||
|
return out.getvalue()
|
||||||
|
|
||||||
|
return call_generate_swagger
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def compare_schemas():
|
def compare_schemas():
|
||||||
def compare_schemas(schema1, schema2):
|
def compare_schemas(schema1, schema2):
|
||||||
|
|||||||
+234
-3
@@ -21,10 +21,15 @@ consumes:
|
|||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
basic:
|
Basic:
|
||||||
type: basic
|
type: basic
|
||||||
|
Bearer:
|
||||||
|
in: header
|
||||||
|
name: Authorization
|
||||||
|
type: apiKey
|
||||||
security:
|
security:
|
||||||
- basic: []
|
- Basic: []
|
||||||
|
- Bearer: []
|
||||||
paths:
|
paths:
|
||||||
/articles/:
|
/articles/:
|
||||||
get:
|
get:
|
||||||
@@ -202,6 +207,7 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
pattern: ^69$
|
pattern: ^69$
|
||||||
default: '69'
|
default: '69'
|
||||||
|
minLength: 1
|
||||||
- name: image_styles
|
- name: image_styles
|
||||||
in: formData
|
in: formData
|
||||||
description: Parameter with Items
|
description: Parameter with Items
|
||||||
@@ -382,6 +388,24 @@ paths:
|
|||||||
$ref: '#/definitions/Snippet'
|
$ref: '#/definitions/Snippet'
|
||||||
tags:
|
tags:
|
||||||
- snippets
|
- snippets
|
||||||
|
delete:
|
||||||
|
operationId: snippetsDeleteBulk
|
||||||
|
description: SnippetList classdoc
|
||||||
|
parameters:
|
||||||
|
- name: data
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
body:
|
||||||
|
description: this should not crash (request body on DELETE method)
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- snippets
|
||||||
parameters: []
|
parameters: []
|
||||||
/snippets/{id}/:
|
/snippets/{id}/:
|
||||||
get:
|
get:
|
||||||
@@ -436,9 +460,13 @@ paths:
|
|||||||
description: path parameter override
|
description: path parameter override
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
|
- name: delete_form_param
|
||||||
|
in: formData
|
||||||
|
description: this should not crash (form parameter on DELETE method)
|
||||||
|
type: integer
|
||||||
responses:
|
responses:
|
||||||
'204':
|
'204':
|
||||||
description: This should not crash
|
description: this should not crash (response object with no schema)
|
||||||
tags:
|
tags:
|
||||||
- snippets
|
- snippets
|
||||||
parameters:
|
parameters:
|
||||||
@@ -495,6 +523,127 @@ paths:
|
|||||||
description: A unique integer value identifying this todo another.
|
description: A unique integer value identifying this todo another.
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
|
/todo/recursive/:
|
||||||
|
get:
|
||||||
|
operationId: todo_recursive_list
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
post:
|
||||||
|
operationId: todo_recursive_create
|
||||||
|
description: ''
|
||||||
|
parameters:
|
||||||
|
- name: data
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
parameters: []
|
||||||
|
/todo/recursive/{id}/:
|
||||||
|
get:
|
||||||
|
operationId: todo_recursive_read
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'302':
|
||||||
|
description: Redirect somewhere
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
put:
|
||||||
|
operationId: todo_recursive_update
|
||||||
|
description: ''
|
||||||
|
parameters:
|
||||||
|
- name: data
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
patch:
|
||||||
|
operationId: todo_recursive_partial_update
|
||||||
|
description: ''
|
||||||
|
parameters:
|
||||||
|
- name: data
|
||||||
|
in: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
delete:
|
||||||
|
operationId: todo_recursive_delete
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
description: A unique integer value identifying this todo tree.
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
/todo/tree/:
|
||||||
|
get:
|
||||||
|
operationId: todo_tree_list
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/TodoTree'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
parameters: []
|
||||||
|
/todo/tree/{id}/:
|
||||||
|
get:
|
||||||
|
operationId: todo_tree_read
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoTree'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
description: A unique integer value identifying this todo tree.
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
/todo/yetanother/:
|
/todo/yetanother/:
|
||||||
get:
|
get:
|
||||||
operationId: todo_yetanother_list
|
operationId: todo_yetanother_list
|
||||||
@@ -546,6 +695,27 @@ paths:
|
|||||||
description: A unique integer value identifying this todo.
|
description: A unique integer value identifying this todo.
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
|
/todo/{todo_id}/yetanothers/{yetanother_id}/:
|
||||||
|
get:
|
||||||
|
operationId: todo_yetanothers_read
|
||||||
|
description: ''
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: ''
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/TodoYetAnother'
|
||||||
|
tags:
|
||||||
|
- todo
|
||||||
|
parameters:
|
||||||
|
- name: todo_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- name: yetanother_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
/users/:
|
/users/:
|
||||||
get:
|
get:
|
||||||
operationId: users_list
|
operationId: users_list
|
||||||
@@ -556,6 +726,7 @@ paths:
|
|||||||
description: this field is generated from a query_serializer
|
description: this field is generated from a query_serializer
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
- name: is_staff
|
- name: is_staff
|
||||||
in: query
|
in: query
|
||||||
description: this one too!
|
description: this one too!
|
||||||
@@ -656,6 +827,7 @@ definitions:
|
|||||||
description: title model help_text
|
description: title model help_text
|
||||||
type: string
|
type: string
|
||||||
maxLength: 255
|
maxLength: 255
|
||||||
|
minLength: 1
|
||||||
author:
|
author:
|
||||||
description: The ID of the user that created this article; if none is provided,
|
description: The ID of the user that created this article; if none is provided,
|
||||||
defaults to the currently logged in user.
|
defaults to the currently logged in user.
|
||||||
@@ -665,6 +837,7 @@ definitions:
|
|||||||
description: body serializer help_text
|
description: body serializer help_text
|
||||||
type: string
|
type: string
|
||||||
maxLength: 5000
|
maxLength: 5000
|
||||||
|
minLength: 1
|
||||||
slug:
|
slug:
|
||||||
description: slug model help_text
|
description: slug model help_text
|
||||||
type: string
|
type: string
|
||||||
@@ -686,6 +859,7 @@ definitions:
|
|||||||
description: but i needed to test these 2 fields somehow
|
description: but i needed to test these 2 fields somehow
|
||||||
type: string
|
type: string
|
||||||
format: uri
|
format: uri
|
||||||
|
minLength: 1
|
||||||
readOnly: true
|
readOnly: true
|
||||||
uuid:
|
uuid:
|
||||||
description: should articles have UUIDs?
|
description: should articles have UUIDs?
|
||||||
@@ -728,10 +902,13 @@ definitions:
|
|||||||
title: FirstName
|
title: FirstName
|
||||||
type: string
|
type: string
|
||||||
maxLength: 30
|
maxLength: 30
|
||||||
|
minLength: 1
|
||||||
lastName:
|
lastName:
|
||||||
title: LastName
|
title: LastName
|
||||||
|
description: <strong>Here's some HTML!</strong>
|
||||||
type: string
|
type: string
|
||||||
maxLength: 30
|
maxLength: 30
|
||||||
|
minLength: 1
|
||||||
Person:
|
Person:
|
||||||
required:
|
required:
|
||||||
- identity
|
- identity
|
||||||
@@ -753,10 +930,12 @@ definitions:
|
|||||||
title: Project name
|
title: Project name
|
||||||
description: Name of the project
|
description: Name of the project
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
githubRepo:
|
githubRepo:
|
||||||
title: Github repo
|
title: Github repo
|
||||||
description: Github repository of the project
|
description: Github repository of the project
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
Snippet:
|
Snippet:
|
||||||
required:
|
required:
|
||||||
- code
|
- code
|
||||||
@@ -778,6 +957,7 @@ definitions:
|
|||||||
description: The ID of the user that created this snippet.
|
description: The ID of the user that created this snippet.
|
||||||
type: string
|
type: string
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
minLength: 1
|
||||||
title: Owner as string
|
title: Owner as string
|
||||||
title:
|
title:
|
||||||
title: Title
|
title: Title
|
||||||
@@ -786,6 +966,7 @@ definitions:
|
|||||||
code:
|
code:
|
||||||
title: Code
|
title: Code
|
||||||
type: string
|
type: string
|
||||||
|
minLength: 1
|
||||||
linenos:
|
linenos:
|
||||||
title: Linenos
|
title: Linenos
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -1304,6 +1485,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
TodoAnother:
|
TodoAnother:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1314,8 +1496,47 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
$ref: '#/definitions/Todo'
|
$ref: '#/definitions/Todo'
|
||||||
|
TodoRecursive:
|
||||||
|
required:
|
||||||
|
- title
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
title: ID
|
||||||
|
type: integer
|
||||||
|
readOnly: true
|
||||||
|
title:
|
||||||
|
title: Title
|
||||||
|
type: string
|
||||||
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
|
parent:
|
||||||
|
$ref: '#/definitions/TodoRecursive'
|
||||||
|
parent_id:
|
||||||
|
type: integer
|
||||||
|
title: Parent id
|
||||||
|
TodoTree:
|
||||||
|
required:
|
||||||
|
- title
|
||||||
|
- children
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
title: ID
|
||||||
|
type: integer
|
||||||
|
readOnly: true
|
||||||
|
title:
|
||||||
|
title: Title
|
||||||
|
type: string
|
||||||
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
|
children:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/TodoTree'
|
||||||
TodoYetAnother:
|
TodoYetAnother:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1325,6 +1546,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1338,6 +1560,7 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
todo:
|
todo:
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
@@ -1351,8 +1574,14 @@ definitions:
|
|||||||
title: Title
|
title: Title
|
||||||
type: string
|
type: string
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
|
minLength: 1
|
||||||
readOnly: true
|
readOnly: true
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
example:
|
||||||
|
title: parent
|
||||||
|
todo:
|
||||||
|
title: child
|
||||||
|
todo: null
|
||||||
UserSerializerrr:
|
UserSerializerrr:
|
||||||
required:
|
required:
|
||||||
- username
|
- username
|
||||||
@@ -1371,6 +1600,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
pattern: ^[\w.@+-]+$
|
pattern: ^[\w.@+-]+$
|
||||||
maxLength: 150
|
maxLength: 150
|
||||||
|
minLength: 1
|
||||||
email:
|
email:
|
||||||
title: Email address
|
title: Email address
|
||||||
type: string
|
type: string
|
||||||
@@ -1392,6 +1622,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
format: ipv4
|
format: ipv4
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
minLength: 1
|
||||||
last_connected_at:
|
last_connected_at:
|
||||||
title: Last connected at
|
title: Last connected at
|
||||||
description: really?
|
description: really?
|
||||||
|
|||||||
+17
-17
@@ -9,24 +9,13 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.management import call_command
|
|
||||||
|
|
||||||
|
from drf_yasg import openapi
|
||||||
from drf_yasg.codecs import yaml_sane_load
|
from drf_yasg.codecs import yaml_sane_load
|
||||||
|
from drf_yasg.generators import OpenAPISchemaGenerator
|
||||||
|
|
||||||
|
|
||||||
def call_generate_swagger(output_file='-', overwrite=False, format='', api_url='',
|
def test_reference_schema(call_generate_swagger, db, reference_schema):
|
||||||
mock=False, user='', private=False, **kwargs):
|
|
||||||
out = StringIO()
|
|
||||||
call_command(
|
|
||||||
'generate_swagger', stdout=out,
|
|
||||||
output_file=output_file, overwrite=overwrite, format=format,
|
|
||||||
api_url=api_url, mock=mock, user=user, private=private,
|
|
||||||
**kwargs
|
|
||||||
)
|
|
||||||
return out.getvalue()
|
|
||||||
|
|
||||||
|
|
||||||
def test_reference_schema(db, reference_schema):
|
|
||||||
User.objects.create_superuser('admin', 'admin@admin.admin', 'blabla')
|
User.objects.create_superuser('admin', 'admin@admin.admin', 'blabla')
|
||||||
|
|
||||||
output = call_generate_swagger(format='yaml', api_url='http://test.local:8002/', user='admin')
|
output = call_generate_swagger(format='yaml', api_url='http://test.local:8002/', user='admin')
|
||||||
@@ -34,18 +23,29 @@ def test_reference_schema(db, reference_schema):
|
|||||||
assert output_schema == reference_schema
|
assert output_schema == reference_schema
|
||||||
|
|
||||||
|
|
||||||
def test_non_public(db):
|
def test_non_public(call_generate_swagger, db):
|
||||||
output = call_generate_swagger(format='yaml', api_url='http://test.local:8002/', private=True)
|
output = call_generate_swagger(format='yaml', api_url='http://test.local:8002/', private=True)
|
||||||
output_schema = yaml_sane_load(output)
|
output_schema = yaml_sane_load(output)
|
||||||
assert len(output_schema['paths']) == 0
|
assert len(output_schema['paths']) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_no_mock(db):
|
def test_no_mock(call_generate_swagger, db):
|
||||||
output = call_generate_swagger()
|
output = call_generate_swagger()
|
||||||
output_schema = json.loads(output, object_pairs_hook=OrderedDict)
|
output_schema = json.loads(output, object_pairs_hook=OrderedDict)
|
||||||
assert len(output_schema['paths']) > 0
|
assert len(output_schema['paths']) > 0
|
||||||
|
|
||||||
|
|
||||||
|
class EmptySchemaGenerator(OpenAPISchemaGenerator):
|
||||||
|
def get_paths(self, endpoints, components, request, public):
|
||||||
|
return openapi.Paths(paths={}), ''
|
||||||
|
|
||||||
|
|
||||||
|
def test_generator_class(call_generate_swagger, db):
|
||||||
|
output = call_generate_swagger(generator_class_name='test_management.EmptySchemaGenerator')
|
||||||
|
output_schema = json.loads(output, object_pairs_hook=OrderedDict)
|
||||||
|
assert len(output_schema['paths']) == 0
|
||||||
|
|
||||||
|
|
||||||
def silentremove(filename):
|
def silentremove(filename):
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
@@ -53,7 +53,7 @@ def silentremove(filename):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_file_output(db):
|
def test_file_output(call_generate_swagger, db):
|
||||||
prefix = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix())
|
prefix = os.path.join(tempfile.gettempdir(), tempfile.gettempprefix())
|
||||||
name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8))
|
name = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8))
|
||||||
yaml_file = prefix + name + '.yaml'
|
yaml_file = prefix + name + '.yaml'
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import json
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from django.conf.urls import url
|
||||||
from rest_framework import routers, serializers, viewsets
|
from rest_framework import routers, serializers, viewsets
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from drf_yasg import codecs, openapi
|
from drf_yasg import codecs, openapi
|
||||||
@@ -113,3 +115,35 @@ def test_replaced_serializer():
|
|||||||
responses = swagger['paths']['/details/{id}/']['get']['responses']
|
responses = swagger['paths']['/details/{id}/']['get']['responses']
|
||||||
assert '404' in responses
|
assert '404' in responses
|
||||||
assert responses['404']['schema']['$ref'] == "#/definitions/Detail"
|
assert responses['404']['schema']['$ref'] == "#/definitions/Detail"
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_order():
|
||||||
|
# this view with description override should show up in the schema ...
|
||||||
|
@swagger_auto_schema(method='get', operation_description="description override")
|
||||||
|
@api_view()
|
||||||
|
def test_override(request, pk=None):
|
||||||
|
return Response({"message": "Hello, world!"})
|
||||||
|
|
||||||
|
# ... instead of this view which appears later in the url patterns
|
||||||
|
@api_view()
|
||||||
|
def test_view(request, pk=None):
|
||||||
|
return Response({"message": "Hello, world!"})
|
||||||
|
|
||||||
|
patterns = [
|
||||||
|
url(r'^/test/$', test_override),
|
||||||
|
url(r'^/test/$', test_view),
|
||||||
|
]
|
||||||
|
|
||||||
|
generator = OpenAPISchemaGenerator(
|
||||||
|
info=openapi.Info(title="Test generator", default_version="v1"),
|
||||||
|
version="v2",
|
||||||
|
url='',
|
||||||
|
patterns=patterns
|
||||||
|
)
|
||||||
|
|
||||||
|
# description override is successful
|
||||||
|
swagger = generator.get_schema(None, True)
|
||||||
|
assert swagger['paths']['/test/']['get']['description'] == 'description override'
|
||||||
|
|
||||||
|
# get_endpoints only includes one endpoint
|
||||||
|
assert len(generator.get_endpoints(None)['/test/'][1]) == 1
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
from random import shuffle
|
||||||
|
|
||||||
from drf_yasg import openapi
|
from drf_yasg import openapi
|
||||||
|
|
||||||
|
|
||||||
@@ -51,3 +54,15 @@ def test_trailing_underscore_stripped():
|
|||||||
del sd.in_
|
del sd.in_
|
||||||
assert 'in' not in sd
|
assert 'in' not in sd
|
||||||
assert not hasattr(sd, 'in__')
|
assert not hasattr(sd, 'in__')
|
||||||
|
|
||||||
|
|
||||||
|
def test_extra_ordering():
|
||||||
|
"""Insertion order should also be consistent when setting undeclared parameters (kwargs) in SwaggerDict"""
|
||||||
|
extras = [('beta', 1), ('alpha', 2), ('omega', 3), ('gamma', 4)]
|
||||||
|
shuffled_extras = list(extras)
|
||||||
|
shuffle(shuffled_extras)
|
||||||
|
|
||||||
|
s1 = openapi.SwaggerDict(**OrderedDict(extras))
|
||||||
|
s2 = openapi.SwaggerDict(**OrderedDict(shuffled_extras))
|
||||||
|
|
||||||
|
assert list(s1.items()) == list(s2.items())
|
||||||
|
|||||||
@@ -7,6 +7,18 @@ def _get_versioned_schema(prefix, client, validate_schema):
|
|||||||
response = client.get(prefix + '/swagger.yaml')
|
response = client.get(prefix + '/swagger.yaml')
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
swagger = yaml_sane_load(response.content.decode('utf-8'))
|
swagger = yaml_sane_load(response.content.decode('utf-8'))
|
||||||
|
_check_base(swagger, prefix, validate_schema)
|
||||||
|
return swagger
|
||||||
|
|
||||||
|
|
||||||
|
def _get_versioned_schema_management(prefix, call_generate_swagger, validate_schema, kwargs):
|
||||||
|
output = call_generate_swagger(format='yaml', api_url='http://localhost' + prefix + '/swagger.yaml', **kwargs)
|
||||||
|
swagger = yaml_sane_load(output)
|
||||||
|
_check_base(swagger, prefix, validate_schema)
|
||||||
|
return swagger
|
||||||
|
|
||||||
|
|
||||||
|
def _check_base(swagger, prefix, validate_schema):
|
||||||
assert swagger['basePath'] == prefix
|
assert swagger['basePath'] == prefix
|
||||||
validate_schema(swagger)
|
validate_schema(swagger)
|
||||||
assert '/snippets/' in swagger['paths']
|
assert '/snippets/' in swagger['paths']
|
||||||
@@ -51,3 +63,17 @@ def test_ns_v1(client, validate_schema):
|
|||||||
def test_ns_v2(client, validate_schema):
|
def test_ns_v2(client, validate_schema):
|
||||||
swagger = _get_versioned_schema('/versioned/ns/v2.0', client, validate_schema)
|
swagger = _get_versioned_schema('/versioned/ns/v2.0', client, validate_schema)
|
||||||
_check_v2(swagger)
|
_check_v2(swagger)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.urls('urlconfs.url_versioning')
|
||||||
|
def test_url_v2_management(call_generate_swagger, validate_schema):
|
||||||
|
kwargs = {'api_version': '2.0'}
|
||||||
|
swagger = _get_versioned_schema_management('/versioned/url/v2.0', call_generate_swagger, validate_schema, kwargs)
|
||||||
|
_check_v2(swagger)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.urls('urlconfs.ns_versioning')
|
||||||
|
def test_ns_v2_management(call_generate_swagger, validate_schema):
|
||||||
|
kwargs = {'api_version': '2.0'}
|
||||||
|
swagger = _get_versioned_schema_management('/versioned/ns/v2.0', call_generate_swagger, validate_schema, kwargs)
|
||||||
|
_check_v2(swagger)
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
py27-django111-drf37,
|
py27-django111-drf37,
|
||||||
py{34,35,36}-django{111,20}-drf37,
|
py{34,35,36}-django{111,20}-drf{37,38},
|
||||||
py36-django20-drfmaster,
|
py36-django20-drfmaster,
|
||||||
lint, docs
|
lint, docs
|
||||||
|
|
||||||
[travis:env]
|
[travis:env]
|
||||||
DRF =
|
DRF =
|
||||||
3.7: drf37
|
3.7: drf37
|
||||||
|
3.8: drf38
|
||||||
master: drfmaster
|
master: drfmaster
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
@@ -16,6 +17,7 @@ deps =
|
|||||||
django20: Django>=2.0,<2.1
|
django20: Django>=2.0,<2.1
|
||||||
|
|
||||||
drf37: djangorestframework>=3.7.7,<3.8
|
drf37: djangorestframework>=3.7.7,<3.8
|
||||||
|
drf38: djangorestframework>=3.8.0,<3.9
|
||||||
|
|
||||||
# test with the latest build of django-rest-framework to get early warning of compatibility issues
|
# test with the latest build of django-rest-framework to get early warning of compatibility issues
|
||||||
drfmaster: https://github.com/encode/django-rest-framework/archive/master.tar.gz
|
drfmaster: https://github.com/encode/django-rest-framework/archive/master.tar.gz
|
||||||
@@ -44,7 +46,7 @@ commands =
|
|||||||
[pytest]
|
[pytest]
|
||||||
DJANGO_SETTINGS_MODULE = testproj.settings.local
|
DJANGO_SETTINGS_MODULE = testproj.settings.local
|
||||||
python_paths = testproj
|
python_paths = testproj
|
||||||
addopts = -n 3
|
addopts = -n 3 --ignore=node_modules
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
@@ -63,7 +65,7 @@ known_standard_library =
|
|||||||
collections,copy,distutils,functools,inspect,io,json,logging,operator,os,pkg_resources,re,setuptools,sys,
|
collections,copy,distutils,functools,inspect,io,json,logging,operator,os,pkg_resources,re,setuptools,sys,
|
||||||
types,warnings
|
types,warnings
|
||||||
known_third_party =
|
known_third_party =
|
||||||
coreapi,coreschema,datadiff,dj_database_url,django,django_filters,djangorestframework_camel_case,flex,gunicorn,
|
coreapi,coreschema,datadiff,dj_database_url,django,django_filters,djangorestframework_camel_case,
|
||||||
inflection,pygments,pytest,rest_framework,ruamel,setuptools_scm,swagger_spec_validator,uritemplate,user_agents,
|
rest_framework_recursive,flex,gunicorn,inflection,pygments,pytest,rest_framework,ruamel,setuptools_scm,
|
||||||
whitenoise
|
swagger_spec_validator,uritemplate,user_agents,whitenoise
|
||||||
known_first_party = drf_yasg,testproj,articles,people,snippets,todo,users,urlconfs
|
known_first_party = drf_yasg,testproj,articles,people,snippets,todo,users,urlconfs
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -ev
|
set -ev
|
||||||
npm update
|
npm update
|
||||||
|
|
||||||
cp node_modules/redoc/dist/redoc.min.js src/drf_yasg/static/drf-yasg/redoc/
|
cp node_modules/redoc/bundles/redoc.standalone.js src/drf_yasg/static/drf-yasg/redoc/redoc.min.js
|
||||||
cp -r node_modules/swagger-ui-dist src/drf_yasg/static/drf-yasg/
|
cp -r node_modules/swagger-ui-dist src/drf_yasg/static/drf-yasg/
|
||||||
pushd src/drf_yasg/static/drf-yasg/swagger-ui-dist/ >/dev/null
|
pushd src/drf_yasg/static/drf-yasg/swagger-ui-dist/ >/dev/null
|
||||||
rm -f package.json .npmignore README.md
|
rm -f package.json .npmignore README.md
|
||||||
|
|||||||
Reference in New Issue
Block a user