Skip to content

Commit c59f2d8

Browse files
authored
feat(generator): handle multiple response codes per operation (#73)
## Description Support OpenAPI specs having multiple status codes per operation.
1 parent fbb1391 commit c59f2d8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

exoscale/api/generator.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def _get_ref(api_spec, path):
5252
}
5353

5454

55-
def _return_docstring(api_spec, operation):
56-
[status_code] = operation["responses"].keys()
55+
def _status_code_docstring(api_spec, operation, status_code):
5756
[ctype] = operation["responses"][status_code]["content"].keys()
5857
return_schema = operation["responses"][status_code]["content"][ctype][
5958
"schema"
@@ -96,6 +95,17 @@ def _return_docstring(api_spec, operation):
9695
return doc
9796

9897

98+
def _return_docstring(api_spec, operation):
99+
status_codes_docs = [
100+
"{status_code}: {ret_type}".format(
101+
status_code=status_code,
102+
ret_type=_status_code_docstring(api_spec, operation, status_code),
103+
)
104+
for status_code in operation["responses"].keys()
105+
]
106+
107+
return "\n ".join(status_codes_docs)
108+
99109
class BaseClient:
100110
_api_spec = None
101111
_by_operation = None

0 commit comments

Comments
 (0)