Skip to content

Commit

Permalink
Add compat for Sanic v21.6
Browse files Browse the repository at this point in the history
release v0.6.1
  • Loading branch information
ashleysommer committed Aug 31, 2021
1 parent 7e8da1a commit 24568f9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanic_restplus",
"version": "0.5.6",
"version": "0.6.1",
"description": "Fully featured framework for fast, easy and documented API development with Sanic",
"repository": "ashleysommer/sanic-restplus",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion requirements/install.pip
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
aniso8601>=0.82
jsonschema
methodtools
setuptools>=40.8
sanic>=21.3.4,<22
sanic-jinja2>=0.10.0
sanic-plugin-toolkit>=1.0.1
sanic-plugin-toolkit>=1.1.0.post1
2 changes: 1 addition & 1 deletion sanic_restplus/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: latin-1 -*-
#
__version__ = '0.6.0'
__version__ = '0.6.1'
__description__ = 'Fully featured framework for fast, easy and documented API development with Sanic'
16 changes: 8 additions & 8 deletions sanic_restplus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from functools import wraps, partial, lru_cache, update_wrapper
from types import MethodType

from distutils.version import LooseVersion
from jinja2 import PackageLoader
from sanic_routing.exceptions import RouteExists #, url_hash
from sanic.response import text, BaseHTTPResponse
Expand All @@ -26,7 +26,7 @@
from sanic.handlers import ErrorHandler
from sanic.exceptions import SanicException, InvalidUsage, NotFound
from sanic import exceptions, Sanic, Blueprint
from sanic.models.futures import FutureRoute as FutureRouteActual
from sanic import __version__ as sanic_version
from sanic.base import BaseSanic
try:
from sanic.compat import Header
Expand All @@ -52,7 +52,8 @@

py_36 = (3, 6)
async_req_version = py_36

SANIC_VERSION = LooseVersion(sanic_version)
SANIC_21_6_0 = LooseVersion("21.6.0")
RE_RULES = re.compile('(<.*>)')

# List headers that should never be handled by Flask-RESTPlus
Expand Down Expand Up @@ -357,13 +358,13 @@ def _register_doc(self, api_renderer):
route_kwargs.setdefault('stream', False)
route_kwargs.setdefault('name', None)
route_kwargs.setdefault('version', None)
if hasattr(FutureRouteActual, 'version_prefix'):
route_kwargs.setdefault('version_prefix', None)
route_kwargs.setdefault('ignore_body', False)
route_kwargs.setdefault('websocket', False)
route_kwargs.setdefault('subprotocols', None)
route_kwargs.setdefault('unquote', False)
route_kwargs.setdefault('static', False)
if SANIC_21_6_0 <= SANIC_VERSION:
route_kwargs.setdefault('version_prefix', None)
if self._add_specs and self._doc:
doc_endpoint_name = '{}_doc'.format(str(self._uid))

Expand Down Expand Up @@ -445,14 +446,13 @@ def _register_view(self, resource, namespace, *urls, **kwargs):
kwargs.setdefault('stream', False)
kwargs.setdefault('name', None)
kwargs.setdefault('version', None)
if hasattr(FutureRouteActual, 'version_prefix'):
kwargs.setdefault('version_prefix', None)

kwargs.setdefault('ignore_body', False)
kwargs.setdefault('websocket', False)
kwargs.setdefault('subprotocols', None)
kwargs.setdefault('unquote', False)
kwargs.setdefault('static', False)
if SANIC_21_6_0 <= SANIC_VERSION:
kwargs.setdefault('version_prefix', None)
# Add the url to the application or blueprint
r = FutureRoute(resource_func, rule, (), {'methods': methods, 'with_context': True, **kwargs})
realm._register_route_helper(r, realm, restplus, context, plugin_name, plugin_url_prefix)
Expand Down

0 comments on commit 24568f9

Please sign in to comment.