From 3830b1b4c17820804a4501c52a7fc2acf3a9163d Mon Sep 17 00:00:00 2001 From: Haidar Cheaito Date: Thu, 22 Oct 2020 12:57:09 +0300 Subject: [PATCH 1/3] support django 3+ --- .gitignore | 2 + rest_framework_swagger/renderers.py | 5 ++ .../rest_framework_swagger/new_index.html | 70 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 rest_framework_swagger/templates/rest_framework_swagger/new_index.html diff --git a/.gitignore b/.gitignore index 56bea9d5..72a6f1c9 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,5 @@ site/ src/ node_modules/ + +.idea/ diff --git a/rest_framework_swagger/renderers.py b/rest_framework_swagger/renderers.py index a3bc124f..3824588c 100644 --- a/rest_framework_swagger/renderers.py +++ b/rest_framework_swagger/renderers.py @@ -1,4 +1,5 @@ import coreapi +import django from coreapi.compat import force_bytes from django.shortcuts import render, resolve_url from openapi_codec import OpenAPICodec as _OpenAPICodec @@ -47,7 +48,11 @@ def get_customizations(self): class SwaggerUIRenderer(BaseRenderer): media_type = 'text/html' format = 'swagger' + django_version = django.VERSION template = 'rest_framework_swagger/index.html' + if django_version[0] >= 3: + template = 'rest_framework_swagger/new_index.html' + charset = 'utf-8' def render(self, data, accepted_media_type=None, renderer_context=None): diff --git a/rest_framework_swagger/templates/rest_framework_swagger/new_index.html b/rest_framework_swagger/templates/rest_framework_swagger/new_index.html new file mode 100644 index 00000000..13ef5c5e --- /dev/null +++ b/rest_framework_swagger/templates/rest_framework_swagger/new_index.html @@ -0,0 +1,70 @@ +{% load i18n %} +{% load static %} + + + + + Swagger UI + + + + {% block extra_styles %} + {# -- Add any additional CSS scripts here -- #} + {% endblock %} + + + +
+
+
+
+ + Swagger Logo + swagger + +
+ {% if USE_SESSION_AUTH %} + {% if request.user.is_authenticated %} + {% trans "Logout" %} + {% else %} + {% trans "Session Login" %} + {% endif %} + {% endif %} +
+
+
+
+ {% if USE_SESSION_AUTH %} +
+ {% block user_context_message %} + {% if request.user.is_authenticated %} + {% trans "You are logged in as: " %}{{ request.user }} + {% else %} + {% trans "Viewing as an anonymous user" %} + {% endif %} + {% endblock %} +
+ {% endif %} +
+ +
+ {% csrf_token %} + + + + + + + {% block extra_scripts %} + {# -- Add any additional scripts here -- #} + {% endblock %} + + + From e0daff007cc2c9ddd2d45c2034dcdd1ff4184089 Mon Sep 17 00:00:00 2001 From: Haidar Cheaito Date: Fri, 23 Oct 2020 01:00:07 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 32 +++----- .../__init__.py | 0 .../renderers.py | 0 .../settings.py | 0 .../bundles/app.bundle.css | 0 .../bundles/app.bundle.js | 0 .../bundles/vendors.bundle.css | 0 .../bundles/vendors.bundle.js | 0 .../rest_framework_swagger/favicon-16x16.png | Bin .../rest_framework_swagger/favicon-32x32.png | Bin .../rest_framework_swagger/logo_small.png | Bin .../rest_framework_swagger/index.html | 2 +- .../views.py | 0 .../rest_framework_swagger/new_index.html | 70 ------------------ 14 files changed, 10 insertions(+), 94 deletions(-) rename {rest_framework_swagger => django_rest_swagger}/__init__.py (100%) rename {rest_framework_swagger => django_rest_swagger}/renderers.py (100%) rename {rest_framework_swagger => django_rest_swagger}/settings.py (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/bundles/app.bundle.css (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/bundles/app.bundle.js (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/bundles/vendors.bundle.css (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/bundles/vendors.bundle.js (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/favicon-16x16.png (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/favicon-32x32.png (100%) rename {rest_framework_swagger => django_rest_swagger}/static/rest_framework_swagger/logo_small.png (100%) rename {rest_framework_swagger => django_rest_swagger}/templates/rest_framework_swagger/index.html (94%) rename {rest_framework_swagger => django_rest_swagger}/views.py (100%) delete mode 100644 rest_framework_swagger/templates/rest_framework_swagger/new_index.html diff --git a/README.md b/README.md index bd6abc27..892ee6a4 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,9 @@ -# Django REST Swagger: deprecated (2019-06-04) - -This project is no longer being maintained. Please consider **drf-yasg** as an alternative/successor. I haven't personally used it, but it looks feature-complete and is actively maintained. - -### https://github.com/axnsan12/drf-yasg - -Thanks for all the support and contributions over the years. Special thanks to [Lights on Software](https://lightsonsoftware.com/), [Lincoln Loop](https://lincolnloop.com/) and BNOTIONS for generously donating time to work on this project :heart:. - ---- +# Django REST Swagger [![build-status-badge]][build-status] -[![codecov](https://codecov.io/gh/marcgibbons/django-rest-swagger/branch/master/graph/badge.svg)](https://codecov.io/gh/marcgibbons/django-rest-swagger) [![pypi-version]][pypi] -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) - #### An API documentation generator for Swagger UI and Django REST Framework @@ -25,14 +14,14 @@ Full documentation: http://marcgibbons.github.io/django-rest-swagger/ 1. `pip install django-rest-swagger` -2. Add `rest_framework_swagger` to your `INSTALLED_APPS` setting: +2. Add `django_rest_swagger` to your `INSTALLED_APPS` setting: ```python - INSTALLED_APPS = ( - ... - 'rest_framework_swagger', - ) - ``` + INSTALLED_APPS = [ + ... + 'django_rest_swagger', + ] + ``` ## Rendering Swagger Specification and Documentation @@ -59,7 +48,7 @@ urlpatterns = [ ## Requirements * Django 1.8+ * Django REST framework 3.5.1+ -* Python 2.7, 3.5, 3.6 +* Python 2.7, 3.5, 3.6, 3.7, 3.8 ## Testing @@ -75,11 +64,8 @@ Contributions are welcome and are encouraged! ## Special Thanks Many thanks to Tom Christie & all the contributors who have developed [Django REST Framework](http://django-rest-framework.org/) - -[build-status-badge]: https://travis-ci.org/marcgibbons/django-rest-swagger.svg?branch=master [build-status]: https://travis-ci.org/marcgibbons/django-rest-swagger -[pypi-version]: https://img.shields.io/pypi/v/django-rest-swagger.svg [pypi]: https://pypi.python.org/pypi/django-rest-swagger [license]: https://pypi.python.org/pypi/django-rest-swagger/ [docs-badge]: https://readthedocs.io/projects/django-rest-swagger/badge/ -[docs]: http://django-rest-swagger.readthedocs.io/ +[docs]: http://django-rest-swagger.readthedocs.io/ \ No newline at end of file diff --git a/rest_framework_swagger/__init__.py b/django_rest_swagger/__init__.py similarity index 100% rename from rest_framework_swagger/__init__.py rename to django_rest_swagger/__init__.py diff --git a/rest_framework_swagger/renderers.py b/django_rest_swagger/renderers.py similarity index 100% rename from rest_framework_swagger/renderers.py rename to django_rest_swagger/renderers.py diff --git a/rest_framework_swagger/settings.py b/django_rest_swagger/settings.py similarity index 100% rename from rest_framework_swagger/settings.py rename to django_rest_swagger/settings.py diff --git a/rest_framework_swagger/static/rest_framework_swagger/bundles/app.bundle.css b/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.css similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/bundles/app.bundle.css rename to django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.css diff --git a/rest_framework_swagger/static/rest_framework_swagger/bundles/app.bundle.js b/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/bundles/app.bundle.js rename to django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js diff --git a/rest_framework_swagger/static/rest_framework_swagger/bundles/vendors.bundle.css b/django_rest_swagger/static/rest_framework_swagger/bundles/vendors.bundle.css similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/bundles/vendors.bundle.css rename to django_rest_swagger/static/rest_framework_swagger/bundles/vendors.bundle.css diff --git a/rest_framework_swagger/static/rest_framework_swagger/bundles/vendors.bundle.js b/django_rest_swagger/static/rest_framework_swagger/bundles/vendors.bundle.js similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/bundles/vendors.bundle.js rename to django_rest_swagger/static/rest_framework_swagger/bundles/vendors.bundle.js diff --git a/rest_framework_swagger/static/rest_framework_swagger/favicon-16x16.png b/django_rest_swagger/static/rest_framework_swagger/favicon-16x16.png similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/favicon-16x16.png rename to django_rest_swagger/static/rest_framework_swagger/favicon-16x16.png diff --git a/rest_framework_swagger/static/rest_framework_swagger/favicon-32x32.png b/django_rest_swagger/static/rest_framework_swagger/favicon-32x32.png similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/favicon-32x32.png rename to django_rest_swagger/static/rest_framework_swagger/favicon-32x32.png diff --git a/rest_framework_swagger/static/rest_framework_swagger/logo_small.png b/django_rest_swagger/static/rest_framework_swagger/logo_small.png similarity index 100% rename from rest_framework_swagger/static/rest_framework_swagger/logo_small.png rename to django_rest_swagger/static/rest_framework_swagger/logo_small.png diff --git a/rest_framework_swagger/templates/rest_framework_swagger/index.html b/django_rest_swagger/templates/rest_framework_swagger/index.html similarity index 94% rename from rest_framework_swagger/templates/rest_framework_swagger/index.html rename to django_rest_swagger/templates/rest_framework_swagger/index.html index b2de7bb4..47784a8f 100644 --- a/rest_framework_swagger/templates/rest_framework_swagger/index.html +++ b/django_rest_swagger/templates/rest_framework_swagger/index.html @@ -52,7 +52,7 @@ diff --git a/rest_framework_swagger/views.py b/django_rest_swagger/views.py similarity index 100% rename from rest_framework_swagger/views.py rename to django_rest_swagger/views.py diff --git a/rest_framework_swagger/templates/rest_framework_swagger/new_index.html b/rest_framework_swagger/templates/rest_framework_swagger/new_index.html deleted file mode 100644 index 13ef5c5e..00000000 --- a/rest_framework_swagger/templates/rest_framework_swagger/new_index.html +++ /dev/null @@ -1,70 +0,0 @@ -{% load i18n %} -{% load static %} - - - - - Swagger UI - - - - {% block extra_styles %} - {# -- Add any additional CSS scripts here -- #} - {% endblock %} - - - -
-
-
-
- - Swagger Logo - swagger - -
- {% if USE_SESSION_AUTH %} - {% if request.user.is_authenticated %} - {% trans "Logout" %} - {% else %} - {% trans "Session Login" %} - {% endif %} - {% endif %} -
-
-
-
- {% if USE_SESSION_AUTH %} -
- {% block user_context_message %} - {% if request.user.is_authenticated %} - {% trans "You are logged in as: " %}{{ request.user }} - {% else %} - {% trans "Viewing as an anonymous user" %} - {% endif %} - {% endblock %} -
- {% endif %} -
- -
- {% csrf_token %} - - - - - - - {% block extra_scripts %} - {# -- Add any additional scripts here -- #} - {% endblock %} - - - From efe61b2bf25b4429dd9048e8d300540c7597ef63 Mon Sep 17 00:00:00 2001 From: Haidar Cheaito Date: Fri, 23 Oct 2020 01:01:11 +0300 Subject: [PATCH 3/3] change library name to --- .coveragerc | 2 +- Dockerfile | 2 +- LICENSE | 35 ++++++------- MANIFEST.in | 4 +- client/server.js | 2 +- client/webpack.config.js | 4 +- django_rest_swagger/renderers.py | 4 +- .../bundles/app.bundle.js | 2 +- .../rest_framework_swagger/index.html | 12 ++--- docs/customization.md | 2 +- docs/index.md | 52 +++---------------- docs/schema.md | 6 +-- docs/settings.md | 2 +- example_app/tutorial/settings.py | 2 +- example_app/tutorial/urls.py | 2 +- requirements.txt | 2 +- setup.py | 18 ++++--- tests/renderers/test_openapi_renderer.py | 10 ++-- tests/renderers/test_swagger.py | 23 ++------ tests/test_settings.py | 2 +- tests/test_views.py | 2 +- tox.ini | 2 +- 22 files changed, 71 insertions(+), 121 deletions(-) diff --git a/.coveragerc b/.coveragerc index 2155a8d5..61728019 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] branch = True -source = rest_framework_swagger +source = django_rest_swagger [report] exclude_lines = diff --git a/Dockerfile b/Dockerfile index d83e3f80..19a5570f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.5.2 +FROM python:3.8.5 RUN mkdir /code ADD requirements.txt /code RUN pip install -r /code/requirements.txt diff --git a/LICENSE b/LICENSE index a418b262..ba988d15 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,19 @@ -Copyright (c) 2013-2016, Marc Gibbons -All rights reserved. +Copyright (c) 2020 AiiA Solution -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index e2cfbde8..f255e6fa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,5 +5,5 @@ global-exclude __pycache__ global-exclude *.pyc global-exclude *.pyo -recursive-include rest_framework_swagger/static * -recursive-include rest_framework_swagger/templates * +recursive-include django_rest_swagger/static * +recursive-include django_rest_swagger/templates * diff --git a/client/server.js b/client/server.js index 2e69ae1c..8eaf3a7f 100644 --- a/client/server.js +++ b/client/server.js @@ -17,7 +17,7 @@ app.use( ), proxy( [ - '!/static/rest_framework_swagger/bundles/**', + '!/static/django_rest_swagger/bundles/**', ], { target: 'http://localhost:8000', // Assumes Django is running on 8000 diff --git a/client/webpack.config.js b/client/webpack.config.js index 995d68a6..7f44ece8 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -6,7 +6,7 @@ const devMode = process.env.NODE_ENV === 'dev'; const distPath = path.resolve( __dirname, - '../rest_framework_swagger/static/rest_framework_swagger/bundles/' + '../django_rest_swagger/static/django_rest_swagger/bundles/' ) module.exports = { @@ -16,7 +16,7 @@ module.exports = { output: { path: distPath, filename: '[name].bundle.js', - publicPath: '/static/rest_framework_swagger/bundles/', + publicPath: '/static/django_rest_swagger/bundles/', }, module: { rules: [ diff --git a/django_rest_swagger/renderers.py b/django_rest_swagger/renderers.py index 3824588c..9e06cbde 100644 --- a/django_rest_swagger/renderers.py +++ b/django_rest_swagger/renderers.py @@ -49,9 +49,7 @@ class SwaggerUIRenderer(BaseRenderer): media_type = 'text/html' format = 'swagger' django_version = django.VERSION - template = 'rest_framework_swagger/index.html' - if django_version[0] >= 3: - template = 'rest_framework_swagger/new_index.html' + template = 'django_rest_swagger/index.html' charset = 'utf-8' diff --git a/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js b/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js index 0e1044af..cd531ab2 100644 --- a/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js +++ b/django_rest_swagger/static/rest_framework_swagger/bundles/app.bundle.js @@ -1 +1 @@ -!function(e){function n(n){for(var t,a,u=n[0],c=n[1],i=n[2],d=0,p=[];d Swagger UI - - + + {% block extra_styles %} {# -- Add any additional CSS scripts here -- #} {% endblock %} @@ -19,7 +19,7 @@
- Swagger Logo + Swagger Logo swagger
@@ -60,8 +60,8 @@ window.drsSettings = {{ drs_settings|safe }}; window.drsSpec = {{ spec|safe }}; - - + + {% block extra_scripts %} {# -- Add any additional scripts here -- #} {% endblock %} diff --git a/docs/customization.md b/docs/customization.md index 4e26aa30..5ca529c9 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -2,7 +2,7 @@ ## Template The template used for the SwaggerUIRenderer can be customized by overriding -`rest_framework_swagger/index.html`. +`django_rest_swagger/index.html`. Here are a few basic areas which can be customized: diff --git a/docs/index.md b/docs/index.md index 309237c9..eac87d29 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,13 +14,13 @@ Swagger/OpenAPI Documentation Generator for Django REST Framework `$ pip install django-rest-swagger` -Add `'rest_framework_swagger'` to `INSTALLED_APPS` in Django settings. +Add `'django_rest_swagger'` to `INSTALLED_APPS` in Django settings. **settings.py** ```python INSTALLED_APPS = [ ... - 'rest_framework_swagger', + 'django_rest_swagger', ... ] ``` @@ -36,7 +36,7 @@ the schemas section. **urls.py** ```python from django.conf.urls import url -from rest_framework_swagger.views import get_swagger_view +from django_rest_swagger.views import get_swagger_view schema_view = get_swagger_view(title='Pastebin API') @@ -52,9 +52,6 @@ urlpatterns = [ ## Example app An example based on the [Django REST Tutorial](http://www.django-rest-framework.org/tutorial/1-serialization/) ships with the project. It can be deployed locally using Docker, or on heroku (for free). -### Deploy with Heroku -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/marcgibbons/django-rest-swagger) - Log in credentials are: ``` username: amy @@ -67,7 +64,7 @@ Ensure [Docker](https://www.docker.com/) is installed on your system. First, clone the repository: -`$ git clone https://github.com/marcgibbons/django-rest-swagger` +`$ git clone https://github.com/aiia-admin/django-rest-swagger` To quickly get up and running using the Docker image, simply run: @@ -82,45 +79,12 @@ username: amy password: amy ``` -## Changes in 2.0 -Version 2.0 is fundamentally different from previous versions and leverages the new schema generation features introduced in Django REST Framework 3.4. Introspection is performed by the framework and uses CoreAPI to store definitions. This is a breaking change from previous versions which were responsible for introspection as well as overrides. +## Changes in 3.0 +Version 3.0 support new django versions New: -- SwaggerUI and the OpenAPI spec are renderer classes (simpler configuration) -- SwaggerUI 2.1.6 -- Improved performance -- Allow multiple instances of Swagger UI in a single Django project -- Allow rendering the OpenAPI JSON spec independently -- Improved control of authentication mechanisms - -Deprecated: - -- YAML docstrings - +- support Django 3+ ## License -```text -Copyright (c) 2013-2018, Marc Gibbons -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -``` +L diff --git a/docs/schema.md b/docs/schema.md index 3394f167..82eef696 100644 --- a/docs/schema.md +++ b/docs/schema.md @@ -25,7 +25,7 @@ Parameters: #### Example: ```python -from rest_framework_swagger.views import get_swagger_view +from django_rest_swagger.views import get_swagger_view schema_view = get_swagger_view(title='My great API', url='/a-different-path') ``` @@ -45,7 +45,7 @@ from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.schemas import SchemaGenerator from rest_framework.views import APIView -from rest_framework_swagger import renderers +from django_rest_swagger import renderers class SwaggerSchemaView(APIView): @@ -65,7 +65,7 @@ class SwaggerSchemaView(APIView): Example: function based view ```python -from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer +from django_rest_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer from rest_framework.decorators import api_view, renderer_classes from rest_framework import response, schemas diff --git a/docs/settings.md b/docs/settings.md index 56a6019e..0452892a 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -84,7 +84,7 @@ All key/val provided in this dictionary will be set on the request headers for all API requests. ## SwaggerUI Settings -Below are some basic configuration settings for SwaggerUI. Note that for more advanced use cases, you may wish to write your own `rest_framework_swagger/static/init.js` file. +Below are some basic configuration settings for SwaggerUI. Note that for more advanced use cases, you may wish to write your own `django_rest_swagger/static/init.js` file. ### APIS_SORTER Set to `alpha` to enable alphabetical sorting. diff --git a/example_app/tutorial/settings.py b/example_app/tutorial/settings.py index bbc20a93..81eddd08 100644 --- a/example_app/tutorial/settings.py +++ b/example_app/tutorial/settings.py @@ -132,7 +132,7 @@ # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'rest_framework', - 'rest_framework_swagger', + 'django_rest_swagger', 'snippets', ) diff --git a/example_app/tutorial/urls.py b/example_app/tutorial/urls.py index 5eac9532..7cbdab50 100644 --- a/example_app/tutorial/urls.py +++ b/example_app/tutorial/urls.py @@ -1,6 +1,6 @@ from django.conf.urls import url, include from rest_framework.routers import DefaultRouter -from rest_framework_swagger.views import get_swagger_view +from django_rest_swagger.views import get_swagger_view from snippets import views diff --git a/requirements.txt b/requirements.txt index c7e58e96..6f74417a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==2.1.3 +Django==3.1.2 djangorestframework==3.9.0 coreapi==2.3.3 openapi-codec==1.3.2 diff --git a/setup.py b/setup.py index 70bbaf4b..add0f689 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import sys import shutil from setuptools import setup -from rest_framework_swagger import __version__ as VERSION +from django_rest_swagger import __version__ as VERSION if sys.argv[-1] == 'publish': if os.system("wheel version"): @@ -32,7 +32,7 @@ pip install django-rest-swagger -Project @ https://github.com/marcgibbons/django-rest-swagger +Project @ https://github.com/aiia-admin/django-rest-swagger Docs @ https://django-rest-swagger.readthedocs.io/ """ @@ -49,15 +49,15 @@ 'Django>=1.8', 'simplejson' ], - packages=['rest_framework_swagger'], + packages=['django_rest_swagger'], include_package_data=True, - license='FreeBSD License', + license='MIT', description='Swagger UI for Django REST Framework 3.5+', long_description=README, test_suite='tests', - author='Marc Gibbons', - author_email='marc_gibbons@rogers.com', - url='https://github.com/marcgibbons/django-rest-swagger', + author='AiiA Solution', + author_email='technical@aiia-solutions.com', + url='https://github.com/aiia-admin/django-rest-swagger', classifiers=[ 'Environment :: Web Environment', 'Framework :: Django', @@ -67,6 +67,8 @@ 'Framework :: Django :: 1.11', 'Framework :: Django :: 2.0', 'Framework :: Django :: 2.1', + 'Framework :: Django :: 3.0', + 'Framework :: Django :: 3.1', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', @@ -76,6 +78,8 @@ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], diff --git a/tests/renderers/test_openapi_renderer.py b/tests/renderers/test_openapi_renderer.py index 2ea621a7..d3804935 100644 --- a/tests/renderers/test_openapi_renderer.py +++ b/tests/renderers/test_openapi_renderer.py @@ -3,7 +3,7 @@ from django.test import TestCase import simplejson as json -from rest_framework_swagger import renderers +from django_rest_swagger import renderers from ..compat.mock import MagicMock, patch @@ -26,7 +26,7 @@ def test_encode_without_document_instance_raises_assertion_error(self): def test_encode_generates_swagger_object_when_given_valid_document(self): expected = {'fizz': 'buzz'} with patch( - 'rest_framework_swagger.renderers.generate_swagger_object', + 'django_rest_swagger.renderers.generate_swagger_object', return_value={'fizz': 'buzz'} ): result = self.sut(coreapi.Document()) @@ -36,7 +36,7 @@ def test_encode_generates_swagger_object_when_given_valid_document(self): def test_encode_adds_extra_data_provided_to_swagger_object(self): expected = {'foo': 'bar'} with patch( - 'rest_framework_swagger.renderers.generate_swagger_object', + 'django_rest_swagger.renderers.generate_swagger_object', return_value={} ): result = self.sut(coreapi.Document(), **expected) @@ -60,7 +60,7 @@ def test_charset(self): def test_format(self): self.assertEqual('openapi', self.sut.format) - @patch('rest_framework_swagger.renderers.OpenAPICodec.encode') + @patch('django_rest_swagger.renderers.OpenAPICodec.encode') def test_render_encodes_customizations(self, encode_mock): data = coreapi.Document() renderer_context = { @@ -89,7 +89,7 @@ class TestGetCustomizations(TestCase): def setUp(self): self.sut = renderers.OpenAPIRenderer().get_customizations - settings_patcher = patch('rest_framework_swagger.renderers.settings') + settings_patcher = patch('django_rest_swagger.renderers.settings') self.swagger_settings = settings_patcher.start() self.addCleanup(settings_patcher.stop) diff --git a/tests/renderers/test_swagger.py b/tests/renderers/test_swagger.py index ea9e762b..cdb978f9 100644 --- a/tests/renderers/test_swagger.py +++ b/tests/renderers/test_swagger.py @@ -1,7 +1,7 @@ from django.test import TestCase import simplejson as json -from rest_framework_swagger.renderers import SwaggerUIRenderer +from django_rest_swagger.renderers import SwaggerUIRenderer from ..compat.mock import patch, MagicMock @@ -11,13 +11,13 @@ def setUp(self): self.renderer_context = {'request': MagicMock()} swagger_settings_patcher = patch( - 'rest_framework_swagger.renderers.settings', + 'django_rest_swagger.renderers.settings', ) self.swagger_settings = swagger_settings_patcher.start() self.addCleanup(swagger_settings_patcher.stop) openapi_patcher = patch( - 'rest_framework_swagger.renderers.OpenAPIRenderer' + 'django_rest_swagger.renderers.OpenAPIRenderer' ) self.openapi_mock = openapi_patcher.start() self.addCleanup(openapi_patcher.stop) @@ -30,14 +30,14 @@ def test_format(self): def test_template(self): self.assertEqual( - 'rest_framework_swagger/index.html', + 'django_rest_swagger/index.html', self.sut.template ) def test_charset(self): self.assertEqual('utf-8', self.sut.charset) - @patch('rest_framework_swagger.renderers.render') + @patch('django_rest_swagger.renderers.render') def test_render(self, render_mock): data = MagicMock() with patch.object(self.sut, 'set_context') as context_mock: @@ -97,19 +97,6 @@ def test_openapi_spec_is_added_to_context(self): self.renderer_context['spec'] ) - def test_get_auth_urls(self): - self.swagger_settings.LOGIN_URL = '/my-login' - self.swagger_settings.LOGOUT_URL = '/my-logout' - result = self.sut.get_auth_urls() - - self.assertDictEqual( - { - 'LOGIN_URL': self.swagger_settings.LOGIN_URL, - 'LOGOUT_URL': self.swagger_settings.LOGOUT_URL, - }, - result - ) - def test_get_auth_urls_when_none(self): self.swagger_settings.LOGIN_URL = None self.swagger_settings.LOGOUT_URL = None diff --git a/tests/test_settings.py b/tests/test_settings.py index 14d5d97a..91ec93ac 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,5 +1,5 @@ from django.test import override_settings, TestCase -from rest_framework_swagger import settings +from django_rest_swagger import settings class TestSettings(TestCase): diff --git a/tests/test_views.py b/tests/test_views.py index 7d03c95e..f1bee0b5 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -18,7 +18,7 @@ def setUp(self): def test_title_and_urlpassed_to_schema_generator(self): title = 'Vandelay' - url = 'https://github.com/marcgibbons/django-rest-swagger' + url = 'https://github.com/aiia-admin/django-rest-swagger' urlconf = 'fizz' patterns = [] view = self.sut( diff --git a/tox.ini b/tox.ini index 82769430..bcecfaa3 100644 --- a/tox.ini +++ b/tox.ini @@ -41,5 +41,5 @@ deps = [testenv:lint] -commands = pylint rest_framework_swagger tests +commands = pylint django_rest_swagger tests deps = -rrequirements.txt