mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-28 19:19:52 +00:00
24 lines
563 B
Python
24 lines
563 B
Python
from __future__ import division
|
|
|
|
from six import iteritems
|
|
|
|
|
|
def is_absolute(url):
|
|
return url.startswith('//') or '://' in url
|
|
|
|
|
|
def get_server_default_variables(server):
|
|
if 'variables' not in server:
|
|
return {}
|
|
|
|
defaults = {}
|
|
variables = server / 'variables'
|
|
for name, variable in iteritems(variables):
|
|
defaults[name] = variable['default']
|
|
return defaults
|
|
|
|
|
|
def get_server_url(server, **variables):
|
|
if not variables:
|
|
variables = get_server_default_variables(server)
|
|
return server['url'].format(**variables)
|