mirror of
https://github.com/correl/openapi-core.git
synced 2024-12-28 19:19:23 +00:00
Python 2.7: Remove Yarl from requirements
This commit is contained in:
parent
64ac723e54
commit
1b9bb11114
2 changed files with 19 additions and 4 deletions
|
@ -1,5 +1,21 @@
|
|||
"""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):
|
||||
|
@ -7,6 +23,6 @@ def get_operation_pattern(server_url, request_url_pattern):
|
|||
if server_url[-1] == "/":
|
||||
# operations have to start with a slash, so do not remove it
|
||||
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 URL(request_url_pattern).path_qs.replace(server_url, "", 1)
|
||||
return path_qs(request_url_pattern).replace(server_url, "", 1)
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
openapi-spec-validator
|
||||
six
|
||||
yarl<1.2.0
|
||||
|
|
Loading…
Reference in a new issue