Skip to content

Commit c9e2140

Browse files
committed
improve file class
1 parent 78282b9 commit c9e2140

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/inferencesh/models/file.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,21 @@ def refresh_metadata(self) -> None:
239239
@classmethod
240240
def model_json_schema(cls, **kwargs):
241241
schema = super().model_json_schema(**kwargs)
242-
schema["$id"] = "/schemas/File"
243242
# Create a schema that accepts either a string or the full object
244-
return {
243+
base_schema = {
245244
"anyOf": [
246245
{"type": "string"}, # Accept string input
247-
schema # Accept full object input
248-
],
249-
"title": "File",
250-
"description": "A class representing a file in the inference.sh ecosystem."
251-
}
246+
{
247+
"type": "object",
248+
"properties": schema["properties"],
249+
"title": schema.get("title", "File"),
250+
"description": "A class representing a file in the inference.sh ecosystem."
251+
}
252+
]
253+
}
254+
# If this is the top-level schema, return as is
255+
if not kwargs.get("ref_template"):
256+
return base_schema
257+
# If this is being used in $defs, include it in the schema
258+
schema.update(base_schema)
259+
return schema

0 commit comments

Comments
 (0)