mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 03:00:11 +00:00
Merge branch 'master' of git://github.com/kcem/openapi-core into kcem-master
This commit is contained in:
commit
f95608493a
9 changed files with 51 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Python 2.7 backward compatibility"""
|
||||||
|
import openapi_core._python27_patch
|
||||||
|
|
||||||
"""OpenAPI core module"""
|
"""OpenAPI core module"""
|
||||||
from openapi_core.shortcuts import (
|
from openapi_core.shortcuts import (
|
||||||
create_spec, validate_parameters, validate_body, validate_data,
|
create_spec, validate_parameters, validate_body, validate_data,
|
||||||
|
|
14
openapi_core/_python27_patch.py
Normal file
14
openapi_core/_python27_patch.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import functools
|
||||||
|
try:
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
from backports.functools_lru_cache import lru_cache
|
||||||
|
functools.lru_cache = lru_cache
|
||||||
|
|
||||||
|
try:
|
||||||
|
from functools import partialmethod
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
from backports.functools_partialmethod import partialmethod
|
||||||
|
functools.partialmethod = partialmethod
|
|
@ -81,7 +81,7 @@ class Schema(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_all_required_properties_names(self):
|
def get_all_required_properties_names(self):
|
||||||
required = self.required.copy()
|
required = self.required[:]
|
||||||
|
|
||||||
for subschema in self.all_of:
|
for subschema in self.all_of:
|
||||||
subschema_req = subschema.get_all_required_properties()
|
subschema_req = subschema.get_all_required_properties()
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
"""OpenAPI core schemas util module"""
|
"""OpenAPI core schemas util module"""
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
from json import dumps
|
from json import dumps
|
||||||
|
from six import string_types
|
||||||
|
|
||||||
|
|
||||||
def forcebool(val):
|
def forcebool(val):
|
||||||
if isinstance(val, str):
|
if isinstance(val, string_types):
|
||||||
val = strtobool(val)
|
val = strtobool(val)
|
||||||
|
|
||||||
return bool(val)
|
return bool(val)
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
"""OpenAPI core validation util module"""
|
"""OpenAPI core validation util module"""
|
||||||
from yarl import URL
|
try:
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
|
||||||
|
def is_absolute(url):
|
||||||
|
return url.startswith('//') or '://' in url
|
||||||
|
|
||||||
|
|
||||||
|
def path_qs(url):
|
||||||
|
pr = urlparse(url)
|
||||||
|
result = pr.path
|
||||||
|
if pr.query:
|
||||||
|
result += '?' + pr.query
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_operation_pattern(server_url, request_url_pattern):
|
def get_operation_pattern(server_url, request_url_pattern):
|
||||||
|
@ -7,6 +23,6 @@ def get_operation_pattern(server_url, request_url_pattern):
|
||||||
if server_url[-1] == "/":
|
if server_url[-1] == "/":
|
||||||
# operations have to start with a slash, so do not remove it
|
# operations have to start with a slash, so do not remove it
|
||||||
server_url = server_url[:-1]
|
server_url = server_url[:-1]
|
||||||
if URL(server_url).is_absolute():
|
if is_absolute(server_url):
|
||||||
return request_url_pattern.replace(server_url, "", 1)
|
return request_url_pattern.replace(server_url, "", 1)
|
||||||
return URL(request_url_pattern).path_qs.replace(server_url, "", 1)
|
return path_qs(request_url_pattern).replace(server_url, "", 1)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
openapi-spec-validator
|
openapi-spec-validator
|
||||||
six
|
six
|
||||||
yarl<1.2.0
|
|
||||||
lazy-object-proxy
|
lazy-object-proxy
|
||||||
|
|
5
requirements_2.7.txt
Normal file
5
requirements_2.7.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
openapi-spec-validator
|
||||||
|
six
|
||||||
|
backports.functools-lru-cache
|
||||||
|
backports.functools-partialmethod
|
||||||
|
enum34
|
5
setup.py
5
setup.py
|
@ -53,6 +53,8 @@ init_path = os.path.join('openapi_core', '__init__.py')
|
||||||
init_py = read_file(init_path)
|
init_py = read_file(init_path)
|
||||||
metadata = get_metadata(init_py)
|
metadata = get_metadata(init_py)
|
||||||
|
|
||||||
|
py27 = '_2.7' if sys.version_info < (3,) else ''
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='openapi-core',
|
name='openapi-core',
|
||||||
|
@ -69,11 +71,12 @@ setup(
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: 3.4',
|
||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
'Topic :: Software Development :: Libraries',
|
'Topic :: Software Development :: Libraries',
|
||||||
],
|
],
|
||||||
install_requires=read_requirements('requirements.txt'),
|
install_requires=read_requirements('requirements{}.txt'.format(py27)),
|
||||||
tests_require=read_requirements('requirements_dev.txt'),
|
tests_require=read_requirements('requirements_dev.txt'),
|
||||||
extras_require={
|
extras_require={
|
||||||
'flask': ["werkzeug"],
|
'flask': ["werkzeug"],
|
||||||
|
|
Loading…
Reference in a new issue