Skip to content

Commit

Permalink
revert: accdential changes to the build client script
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Jun 9, 2024
1 parent df565a1 commit f20419c
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions open_api_client_build/build_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,58 +55,65 @@ def fix_spec(src: str, path: str | os.PathLike):
"you have to provide a file or url keyword as 1st arg."
)
spec_paths = spec["paths"]
if octet_schema := spec_paths._get_multi(
"/projects/{projectId}/testruns/{testRunId}/actions/importXUnitTestResults",
{},
page_size=100,
page_number=1,
if (
octet_schema := spec_paths.get(
"/projects/{projectId}/testruns/{testRunId}/actions/importXUnitTestResults",
{},
)
.get("post", {})
.get("requestBody", {})
.get("content", {})
.get("application/octet-stream", {})
.get("schema")
):
if (
octet_schema._get_multi("type", page_size=100, page_number=1)
== "object"
):
if octet_schema.get("type") == "object":
octet_schema["type"] = "string"
octet_schema["format"] = "binary"

for spec_path in spec_paths.values():
for operation_description in spec_path.values():
if responses := operation_description._get_multi(
"responses", page_size=100, page_number=1
):
if responses := operation_description.get("responses"):
if "4XX-5XX" in responses:
for code, resp in responses.items():
if error_code_pattern.fullmatch(code):
resp["content"] = responses["4XX-5XX"]["content"]
del responses["4XX-5XX"]

schemas = spec["components"]["schemas"]
if downloads := schemas._get_multi(
"jobsSingleGetResponse", {}, page_size=100, page_number=1
if (
downloads := schemas.get("jobsSingleGetResponse", {})
.get("properties", {})
.get("data", {})
.get("properties", {})
.get("links", {})
.get("properties", {})
.get("downloads")
):
if (
"items" not in downloads
and downloads._get_multi("type", page_size=100, page_number=1)
== "array"
):
if "items" not in downloads and downloads.get("type") == "array":
downloads["items"] = {"type": "string"}

if downloads := schemas._get_multi(
"jobsSinglePostResponse", {}, page_size=100, page_number=1
if (
downloads := schemas.get("jobsSinglePostResponse", {})
.get("properties", {})
.get("data", {})
.get("properties", {})
.get("links", {})
.get("properties", {})
.get("downloads")
):
if (
"items" not in downloads
and downloads._get_multi("type", page_size=100, page_number=1)
== "array"
):
if "items" not in downloads and downloads.get("type") == "array":
downloads["items"] = {"type": "string"}

if error_source := schemas._get_multi(
"errors", {}, page_size=100, page_number=1
if (
error_source := schemas.get("errors", {})
.get("properties", {})
.get("errors", {})
.get("items", {})
.get("properties", {})
.get("source")
):
error_source["nullable"] = True
if resource := error_source._get_multi(
"properties", {}, page_size=100, page_number=1
)._get_multi("resource", page_size=100, page_number=1):
if resource := error_source.get("properties", {}).get("resource"):
resource["nullable"] = True

with tempfile.NamedTemporaryFile("w", delete=False) as f:
Expand Down

0 comments on commit f20419c

Please sign in to comment.