Skip to content

Commit 395d2f6

Browse files
authored
feat: add support for attachments on output (#1107)
1 parent a51f664 commit 395d2f6

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

src/uipath/functions/runtime.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ async def get_schema(self) -> UiPathRuntimeSchema:
174174
input_schema = {}
175175
else:
176176
input_param_name = next(iter(sig.parameters))
177-
schema = get_type_schema(hints.get(input_param_name))
178-
input_schema = transform_attachments(schema)
177+
raw_input_schema = get_type_schema(hints.get(input_param_name))
178+
input_schema = transform_attachments(raw_input_schema)
179179

180180
# Determine output schema
181-
output_schema = get_type_schema(hints.get("return"))
182-
181+
raw_output_schema = get_type_schema(hints.get("return"))
182+
output_schema = transform_attachments(raw_output_schema)
183183
return UiPathRuntimeSchema(
184184
filePath=self.entrypoint_name,
185185
uniqueId=str(uuid.uuid4()),

tests/cli/test_init.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,28 @@ def test_schema_generation_resolves_attachments_pydantic_dataclass(
418418
) -> None:
419419
"""Test that attachments are resolved in entry-points schema"""
420420

421+
def verify_attachment_schema(schema, verify_other_field):
422+
assert "definitions" in schema
423+
assert "job-attachment" in schema["definitions"]
424+
assert schema["definitions"]["job-attachment"]["type"] == "object"
425+
assert (
426+
schema["definitions"]["job-attachment"]["x-uipath-resource-kind"]
427+
== "JobAttachment"
428+
)
429+
assert all(
430+
prop_name in schema["definitions"]["job-attachment"]["properties"]
431+
for prop_name in ["ID", "FullName", "MimeType", "Metadata"]
432+
)
433+
if not verify_other_field:
434+
return
435+
436+
assert len(schema["properties"]) == 2
437+
assert all(
438+
prop_name in schema["properties"]
439+
for prop_name in ["input_file", "other_field"]
440+
)
441+
assert schema["required"] == ["input_file"]
442+
421443
with runner.isolated_filesystem(temp_dir=temp_dir):
422444
with open("main.py", "w") as f:
423445
f.write(f"""
@@ -435,30 +457,10 @@ def main(input: InputModel) -> InputModel: return input""")
435457
assert "Created 'bindings.json' file" in result.output
436458
assert "Created 'entry-points.json' file" in result.output
437459

438-
# Verify entry-points.json contains attachments definition
439460
with open("entry-points.json", "r") as f:
440461
entrypoints = json.load(f)
441462
input_schema = entrypoints["entryPoints"][0]["input"]
442-
assert "definitions" in input_schema
443-
assert "job-attachment" in input_schema["definitions"]
444-
assert input_schema["definitions"]["job-attachment"]["type"] == "object"
445-
assert (
446-
input_schema["definitions"]["job-attachment"][
447-
"x-uipath-resource-kind"
448-
]
449-
== "JobAttachment"
450-
)
451-
assert all(
452-
prop_name
453-
in input_schema["definitions"]["job-attachment"]["properties"]
454-
for prop_name in ["ID", "FullName", "MimeType", "Metadata"]
455-
)
456-
if not verify_other_field:
457-
return
463+
output_schema = entrypoints["entryPoints"][0]["output"]
458464

459-
assert len(input_schema["properties"]) == 2
460-
assert all(
461-
prop_name in input_schema["properties"]
462-
for prop_name in ["input_file", "other_field"]
463-
)
464-
assert input_schema["required"] == ["input_file"]
465+
verify_attachment_schema(input_schema, verify_other_field)
466+
verify_attachment_schema(output_schema, verify_other_field)

0 commit comments

Comments
 (0)