mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 03:00:11 +00:00
19 lines
458 B
Python
19 lines
458 B
Python
|
from six import iteritems
|
||
|
|
||
|
|
||
|
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)
|