8000 Style tweaks · Pix4D/python-openapi-codec@0fdd8c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fdd8c0

Browse files
committed
Style tweaks
1 parent e315530 commit 0fdd8c0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

openapi_codec/decode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def _parse_document(data, base_url=None):
1212
paths = _get_dict(data, 'paths')
1313
content = {}
1414
for path in paths.keys():
15-
url = urlparse.urljoin(base_url, path.lstrip('/'))
15+
url = base_url + path.lstrip('/')
1616
spec = _get_dict(paths, path)
1717
default_parameters = get_dicts(_get_list(spec, 'parameters'))
1818
for action in spec.keys():
@@ -83,7 +83,7 @@ def _get_document_base_url(data, base_url=None):
8383
Get the base url to use when constructing absolute paths from the
8484
relative ones provided in the schema defination.
8585
"""
86-
prefered_schemes = ['http', 'https']
86+
prefered_schemes = ['https', 'http']
8787
if base_url:
8888
url_components = urlparse.urlparse(base_url)
8989
default_host = url_components.netloc

openapi_codec/encode.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ def generate_swagger_object(document):
1010

1111
return {
1212
'swagger': '2.0',
13-
'info': _get_info_object(document),
13+
'info': {
14+
'title': document.title,
15+
'version': '' # Required by the spec
16+
},
1417
'paths': _get_paths_object(document),
1518
'host': parsed_url.netloc,
1619
'schemes': [parsed_url.scheme]
1720
}
1821

1922

20-
def _get_info_object(document):
21-
return {
22-
'title': document.title,
23-
'version': '' # Required by the spec
24-
}
25-
26-
2723
def _get_paths_object(document):
2824
paths = {}
2925

@@ -142,8 +138,8 @@ def _get_responses(link):
142138
on action / method type.
143139
"""
144140
template = {'description': ''}
145-
if link.action == 'post':
141+
if link.action.lower() == 'post':
146142
return {'201': template}
147-
if link.action == 'delete':
143+
if link.action.lower() == 'delete':
148144
return {'204': template}
149145
return {'200': template}

0 commit comments

Comments
 (0)
0