Skip to content

Commit f956084

Browse files
committed
Merge branch 'master' of git://github.com/kcem/openapi-core into kcem-master
2 parents a2ee03f + e3dfee5 commit f956084

File tree

9 files changed

+51
-7
lines changed

9 files changed

+51
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.pytest_cache/
56

67
# C extensions
78
*.so

openapi_core/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""Python 2.7 backward compatibility"""
4+
import openapi_core._python27_patch
5+
16
"""OpenAPI core module"""
27
from openapi_core.shortcuts import (
38
create_spec, validate_parameters, validate_body, validate_data,

openapi_core/_python27_patch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import functools
2+
try:
3+
from functools import lru_cache
4+
5+
except ImportError:
6+
from backports.functools_lru_cache import lru_cache
7+
functools.lru_cache = lru_cache
8+
9+
try:
10+
from functools import partialmethod
11+
12+
except ImportError:
13+
from backports.functools_partialmethod import partialmethod
14+
functools.partialmethod = partialmethod

openapi_core/schema/schemas/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _get_all_required_properties(self):
8181
)
8282

8383
def get_all_required_properties_names(self):
84-
required = self.required.copy()
84+
required = self.required[:]
8585

8686
for subschema in self.all_of:
8787
subschema_req = subschema.get_all_required_properties()

openapi_core/schema/schemas/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""OpenAPI core schemas util module"""
22
from distutils.util import strtobool
33
from json import dumps
4+
from six import string_types
45

56

67
def forcebool(val):
7-
if isinstance(val, str):
8+
if isinstance(val, string_types):
89
val = strtobool(val)
910

1011
return bool(val)

openapi_core/validation/util.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
"""OpenAPI core validation util module"""
2-
from yarl import URL
2+
try:
3+
from urllib.parse import urlparse
4+
5+
except ImportError:
6+
from urlparse import urlparse
7+
8+
9+
def is_absolute(url):
10+
return url.startswith('//') or '://' in url
11+
12+
13+
def path_qs(url):
14+
pr = urlparse(url)
15+
result = pr.path
16+
if pr.query:
17+
result += '?' + pr.query
18+
return result
319

420

521
def get_operation_pattern(server_url, request_url_pattern):
622
"""Return an updated request URL pattern with the server URL removed."""
723
if server_url[-1] == "/":
824
# operations have to start with a slash, so do not remove it
925
server_url = server_url[:-1]
10-
if URL(server_url).is_absolute():
26+
if is_absolute(server_url):
1127
return request_url_pattern.replace(server_url, "", 1)
12-
return URL(request_url_pattern).path_qs.replace(server_url, "", 1)
28+
return path_qs(request_url_pattern).replace(server_url, "", 1)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
openapi-spec-validator
22
six
3-
yarl<1.2.0
43
lazy-object-proxy

requirements_2.7.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
openapi-spec-validator
2+
six
3+
backports.functools-lru-cache
4+
backports.functools-partialmethod
5+
enum34

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def run_tests(self):
5353
init_py = read_file(init_path)
5454
metadata = get_metadata(init_py)
5555

56+
py27 = '_2.7' if sys.version_info < (3,) else ''
57+
5658

5759
setup(
5860
name='openapi-core',
@@ -69,11 +71,12 @@ def run_tests(self):
6971
"Topic :: Software Development :: Libraries :: Python Modules",
7072
"Operating System :: OS Independent",
7173
'Programming Language :: Python :: 3.4',
74+
'Programming Language :: Python :: 3.4',
7275
'Programming Language :: Python :: 3.5',
7376
'Programming Language :: Python :: 3.6',
7477
'Topic :: Software Development :: Libraries',
7578
],
76-
install_requires=read_requirements('requirements.txt'),
79+
install_requires=read_requirements('requirements{}.txt'.format(py27)),
7780
tests_require=read_requirements('requirements_dev.txt'),
7881
extras_require={
7982
'flask': ["werkzeug"],

0 commit comments

Comments
 (0)