Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

2.3.0 #835

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

2.3.0 #835

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
branch = True
source = rest_framework_swagger
source = django_rest_swagger

[report]
exclude_lines =
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ site/
src/

node_modules/

.idea/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 16 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
32 changes: 9 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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/
2 changes: 1 addition & 1 deletion client/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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: [
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -47,7 +48,9 @@ def get_customizations(self):
class SwaggerUIRenderer(BaseRenderer):
media_type = 'text/html'
format = 'swagger'
template = 'rest_framework_swagger/index.html'
django_version = django.VERSION
template = 'django_rest_swagger/index.html'

charset = 'utf-8'

def render(self, data, accepted_media_type=None, renderer_context=None):
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link href="{% static 'rest_framework_swagger/bundles/vendors.bundle.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'rest_framework_swagger/bundles/app.bundle.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'django_rest_swagger/bundles/vendors.bundle.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'django_rest_swagger/bundles/app.bundle.css' %}" rel="stylesheet" type="text/css">
{% block extra_styles %}
{# -- Add any additional CSS scripts here -- #}
{% endblock %}
Expand All @@ -19,7 +19,7 @@
<div class="wrapper">
<div class="topbar-wrapper">
<a href="#" class="link">
<img src="{% static 'rest_framework_swagger/logo_small.png' %}" alt="Swagger Logo">
<img src="{% static 'django_rest_swagger/logo_small.png' %}" alt="Swagger Logo">
<span>swagger</span>
</a>
<div class="download-url-wrapper">
Expand Down Expand Up @@ -52,16 +52,16 @@

<footer class="swagger-ui">
<div class="wrapper">
{% trans "Powered by "%}<a href="https://github.com/marcgibbons/django-rest-swagger" target="_new">Django REST Swagger</a>
{% trans "Powered by "%}<a href="https://github.com/aiia-admin/django-rest-swagger" target="_new">AiiA Solution</a>
</div>
</footer>

<script>
window.drsSettings = {{ drs_settings|safe }};
window.drsSpec = {{ spec|safe }};
</script>
<script src="{% static 'rest_framework_swagger/bundles/vendors.bundle.js' %}"></script>
<script src="{% static 'rest_framework_swagger/bundles/app.bundle.js' %}"></script>
<script src="{% static 'django_rest_swagger/bundles/vendors.bundle.js' %}"></script>
<script src="{% static 'django_rest_swagger/bundles/app.bundle.js' %}"></script>
{% block extra_scripts %}
{# -- Add any additional scripts here -- #}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
52 changes: 8 additions & 44 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
...
]
```
Expand All @@ -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')

Expand All @@ -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
Expand All @@ -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:

Expand All @@ -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
6 changes: 3 additions & 3 deletions docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
Expand All @@ -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):
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion example_app/tutorial/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'rest_framework',
'rest_framework_swagger',
'django_rest_swagger',
'snippets',
)

Expand Down
2 changes: 1 addition & 1 deletion example_app/tutorial/urls.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading