Skip to content

Commit

Permalink
输入校验 json_to_pydantic: replace(unique_items, Set)
Browse files Browse the repository at this point in the history
  • Loading branch information
yepeiwen01 committed Dec 11, 2024
1 parent 49f4925 commit 959d168
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/utils/json_schema_to_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def json_schema_to_pydantic_model(json_schema: dict, name_override: str) -> Base

class_title = json_schema["title"]
pydantic_models_as_str = sed_pydantic_str(pydantic_models_as_str, class_title)

pydantic_models_as_str = pydantic_models_as_str.replace("unique_items", "Set")

with NamedTemporaryFile(suffix=".py", delete=False) as temp_file:
temp_file_path = Path(temp_file.name).resolve()
temp_file.write(pydantic_models_as_str.encode())
Expand Down Expand Up @@ -119,6 +120,14 @@ def json_schema_to_pydantic_model(json_schema: dict, name_override: str) -> Base
"type": "string",
"description": "待识别图片的文件名,用于生成图片url"
},
"files": {
"type": "array",
"items": {
"type": "string",
},
"uniqueItems": True
}

},
"anyOf": [
{
Expand Down

0 comments on commit 959d168

Please sign in to comment.