Skip to content

Commit

Permalink
Clean up for publish to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
axnsan12 committed Dec 12, 2017
1 parent 8883894 commit 71b3fd2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 26 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

36 changes: 21 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Compatible with
- **Django**: 1.11, 2.0
- **Python**: 2.7, 3.4, 3.5, 3.6

**Source**: https://github.com/axnsan12/drf-swagger/ |br|
**Source**: https://github.com/axnsan12/drf-swagger/

**Documentation**: https://drf-swagger.readthedocs.io/en/latest/

********
Expand All @@ -34,22 +35,21 @@ Features
`swagger-spec-validator <https://github.com/Yelp/swagger_spec_validator>`__ or
`flex <https://github.com/pipermerriam/flex>`__


.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/docs/screenshots/redoc-nested-response.png
.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/1.0.1/screenshots/redoc-nested-response.png
:width: 100%
:figwidth: image
:alt: redoc screenshot

**Fully nested request and response schemas.**

.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/docs/screenshots/swagger-ui-list.png
.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/1.0.1/screenshots/swagger-ui-list.png
:width: 100%
:figwidth: image
:alt: swagger-ui screenshot

**Choose between redoc and swagger-ui.**

.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/docs/screenshots/swagger-ui-models.png
.. figure:: https://raw.githubusercontent.com/axnsan12/drf-swagger/1.0.1/screenshots/swagger-ui-models.png
:width: 100%
:figwidth: image
:alt: model definitions screenshot
Expand All @@ -68,15 +68,27 @@ Table of contents
Usage
*****

.. _readme-quickstart:
0. Installation
===============

1. Quickstart
=============
The preferred instalation method is directly from pypi:

.. code:: console
pip install drf-swagger
Additionally, if you want to use the built-in validation mechanisms (see `4. Validation`_), you need to install
some extra requirements:

.. code:: console
pip install drf-swagger[validation]
.. _readme-quickstart:

1. Quickstart
=============

In ``settings.py``:

.. code:: python
Expand Down Expand Up @@ -222,7 +234,7 @@ it still conforms to OpenAPI 2.0. To this end, validation is provided at the gen
libraries, and can be activated by passing :python:`validators=['ssv', 'flex']` to ``get_schema_view``; if the generated
schema is not valid, a :python:`SwaggerValidationError` is raised by the handling codec.

**Warning:** This internal validation can slow down your server. |br|
**Warning:** This internal validation can slow down your server.
Caching can mitigate the speed impact of validation.

The provided validation will catch syntactic errors, but more subtle violations of the spec might slip by them. To
Expand Down Expand Up @@ -258,8 +270,6 @@ If your schema is not accessible from the internet, you can run a local copy of
$ curl http://localhost:8189/debug?url=http://test.local:8002/swagger/?format=openapi
{}
Using ``swagger-cli``
---------------------

Expand Down Expand Up @@ -349,7 +359,3 @@ https://drf-swagger.readthedocs.io/en/latest/

.. |nbsp| unicode:: 0xA0
:trim:

.. |br| raw:: html

<br />
14 changes: 8 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys

import sphinx_rtd_theme
from pkg_resources import get_distribution

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -39,11 +40,12 @@
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'

# The full version, including alpha/beta/rc tags.
release = '1.0.0'
release = get_distribution('drf_swagger').version

# The short X.Y.Z version.
version = '.'.join(release.split('.')[:3])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -194,11 +196,11 @@
sys.path.insert(0, os.path.abspath('../testproj'))
os.putenv('DJANGO_SETTINGS_MODULE', 'testproj.settings')

from django.conf import settings
from django.conf import settings # noqa: E402

settings.configure()

import drf_swagger.views
import drf_swagger.views # noqa: E402

# instantiate a SchemaView in the views module to make it available to autodoc
drf_swagger.views.SchemaView = drf_swagger.views.get_schema_view(None)
3 changes: 3 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# requirements for local development
tox>=2.9.1
tox-battery>=0.5

# do not unpin this (see setup.py)
setuptools_scm==1.15.6
15 changes: 13 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

from setuptools import setup, find_packages

try:
# see https://github.com/pypa/setuptools_scm/issues/190, setuptools_scm includes ALL versioned files from the git
# repo into the sdist by default, and there is no easy way to provide an opt-out;
# this hack is ugly but does the job; because this is not really a documented interface of the module,
# the setuptools_scm version should remain pinned to ensure it keeps working
import setuptools_scm.integration
setuptools_scm.integration.find_files = lambda _: []
except ImportError:
pass


def read_req(req_file):
with open(os.path.join('requirements', req_file)) as req:
Expand All @@ -19,11 +29,12 @@ def read_req(req_file):

setup(
name='drf-swagger',
version='1.0.0rc1',
use_scm_version=True,
packages=find_packages('src', include=['drf_swagger']),
package_dir={'': 'src'},
include_package_data=True,
install_requires=requirements,
setup_requires=['setuptools_scm==1.15.6'],
extras_require={
'validation': requirements_validation,
},
Expand All @@ -40,7 +51,7 @@ def read_req(req_file):
'License :: OSI Approved :: BSD License',
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
'Environment :: Web Environment'
'Environment :: Web Environment',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
Expand Down
9 changes: 8 additions & 1 deletion src/drf_swagger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# coding=utf-8
from pkg_resources import get_distribution, DistributionNotFound

__author__ = """Cristi V."""
__email__ = 'cristi@cvjd.me'
__version__ = '1.0.0rc1'

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
4 changes: 2 additions & 2 deletions src/drf_swagger/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def get_path_parameters(self, path, view_cls):
# Attempt to infer a field description if possible.
try:
model_field = model._meta.get_field(variable)
except Exception:
model_field = None # pragma: no cover
except Exception: # pragma: no cover
model_field = None

if model_field is not None and model_field.help_text:
description = force_text(model_field.help_text)
Expand Down

0 comments on commit 71b3fd2

Please sign in to comment.