Skip to content

Commit 28ba5e6

Browse files
committed
update
1 parent 28fbab5 commit 28ba5e6

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

re.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"description": "测试description.",
3+
"properties": {
4+
"gender": {
5+
"enum": [
6+
"male",
7+
"female",
8+
"other",
9+
"not_given"
10+
],
11+
"type": "string"
12+
},
13+
"gender_list": {
14+
"description": "this is the value of snap",
15+
"items": {
16+
"enum": [
17+
"male",
18+
"female",
19+
"other",
20+
"not_given"
21+
],
22+
"type": "string"
23+
},
24+
"title": "l",
25+
"type": "array"
26+
}
27+
},
28+
"required": [
29+
"gender_list"
30+
],
31+
"title": "GenderTest",
32+
"type": "object"
33+
}

schema_entry/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def remove_defs_interference(d: Dict[str, Any]) -> Dict[str, Any]:
253253

254254

255255
def replace_refs(d: Dict[str, Any]) -> Dict[str, Any]:
256-
info = jsonref.replace_refs(d, lazy_load=False)
256+
info = jsonref.replace_refs(d, merge_props=True, lazy_load=False)
257257
if info.get("$defs"):
258258
del info["$defs"]
259259
return info

tests/test_entrypoint_with_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class GenderTest(BaseModel):
9393

9494
assert root.name == "gendertest"
9595
assert root.__doc__ == "测试description."
96+
print(root.schema)
9697
root(["-l", "male", "-l", "other"])
9798
self.assertDictEqual(root.config, {
9899
"gender": "male",

tests/test_utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,6 @@ def test_pydantic_schema_to_protocol(self) -> None:
232232
'type': 'object'}
233233
get_schema = pydantic_schema_to_protocol(pdschema)
234234

235-
target = {'properties': {'gender': {'enum': ['male', 'female', 'other', 'not_given'],
236-
'type': 'string'},
237-
'gender_list': {'description': 'this is the value of snap',
238-
'items': {'enum': ['male', 'female', 'other', 'not_given'],
239-
'type': 'string'},
240-
'title': 'l',
241-
'type': 'array'}},
242-
'required': ['gender', 'gender_list'],
243-
'title': 'D',
244-
'type': 'object'}
235+
target = {'properties': {'gender': {'enum': ['male', 'female', 'other', 'not_given'], 'type': 'string', 'description': 'this is the value of snap', 'title': 'g'}, 'gender_list': {
236+
'description': 'this is the value of snap', 'items': {'enum': ['male', 'female', 'other', 'not_given'], 'type': 'string'}, 'title': 'l', 'type': 'array'}}, 'required': ['gender', 'gender_list'], 'title': 'D', 'type': 'object'}
245237
self.assertDictEqual(target, get_schema)

0 commit comments

Comments
 (0)