Skip to content

Commit c87efb9

Browse files
support in response
1 parent e663f45 commit c87efb9

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

linodecli/baked/request.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Request details for a CLI Operation
33
"""
44

5-
pass
5+
import sys
66

77
from openapi3.schemas import Schema
88

@@ -138,6 +138,13 @@ def _parse_request_model(schema, prefix=None, parent=None, depth=0):
138138
"""
139139
args = []
140140

141+
if depth > 0 and schema.oneOf is not None:
142+
print(
143+
f"WARN: {'.'.join(schema.path)}: "
144+
f"Ignoring oneOf because it is not defined at the request schema's root level.",
145+
file=sys.stderr,
146+
)
147+
141148
if schema.properties is None:
142149
return args
143150

linodecli/baked/response.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from openapi3.paths import MediaType
6+
from openapi3.schemas import Schema
67

78

89
def _is_paginated(response):
@@ -169,10 +170,21 @@ def _parse_response_model(schema, prefix=None, nested_list_depth=0):
169170
)
170171

171172
attrs = []
172-
if schema.properties is None:
173+
174+
properties = dict(schema.properties)
175+
176+
# We dynamically merge oneOf values here to ensure they are all accounted for
177+
# in the response model.
178+
if schema.oneOf is not None:
179+
for entry in schema.oneOf:
180+
properties.update(
181+
dict(Schema(schema.path, entry, schema._root).properties)
182+
)
183+
184+
if properties is None:
173185
return attrs
174186

175-
for k, v in schema.properties.items():
187+
for k, v in properties.items():
176188
pref = prefix + "." + k if prefix else k
177189

178190
if v.type == "object":

0 commit comments

Comments
 (0)