Skip to content

Commit d71948a

Browse files
drop unused function
1 parent 3782bf1 commit d71948a

1 file changed

Lines changed: 1 addition & 60 deletions

File tree

linodecli/baked/response.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Converting the processed OpenAPI Responses into something the CLI can work with
33
"""
44

5-
from typing import Any, Dict
5+
pass
66

77
from openapi3.paths import MediaType
88

@@ -296,62 +296,3 @@ def _fix_nested_list(self, json):
296296
cobj[path_parts[0]] = item
297297
result.append(cobj)
298298
return result
299-
300-
def construct_sample(self) -> Dict[str, Any]:
301-
"""
302-
Reconstructs a sample API response from this response object.
303-
304-
:returns: The reconstructed API response sample.
305-
"""
306-
result = {}
307-
308-
# TODO: Make this whole function less bad
309-
normal_attrs = iter(
310-
attr for attr in self.attrs if attr.datatype != "array"
311-
)
312-
array_attrs = sorted(
313-
iter(attr for attr in self.attrs if attr.datatype == "array"),
314-
key=lambda attr: attr.path,
315-
)
316-
317-
# First, create any necessary structures for list and object values
318-
for attr in array_attrs:
319-
segments = attr.path.split(".")
320-
321-
current = result
322-
for segment in segments[:-1]:
323-
if segment not in current:
324-
current[segment] = {}
325-
326-
current = current[segment]
327-
328-
current[segments[-1]] = []
329-
if attr.example:
330-
current[segments[-1]] = (
331-
attr.example
332-
if isinstance(attr.example, list)
333-
else [attr.example]
334-
)
335-
336-
# Second, populate the rest of the attributes
337-
for attr in normal_attrs:
338-
if attr.example is None:
339-
continue
340-
341-
segments = attr.path.split(".")
342-
343-
current = result
344-
for segment in segments[:-1]:
345-
if segment not in current:
346-
current[segment] = {}
347-
348-
current = current[segment]
349-
350-
if isinstance(current, list):
351-
if len(current) < 1:
352-
current.append({})
353-
current = current[0]
354-
355-
current[segments[-1]] = attr.example
356-
357-
return result

0 commit comments

Comments
 (0)