Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hsz1273327 committed Jun 18, 2024
1 parent 28fbab5 commit 28ba5e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
33 changes: 33 additions & 0 deletions re.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"description": "测试description.",
"properties": {
"gender": {
"enum": [
"male",
"female",
"other",
"not_given"
],
"type": "string"
},
"gender_list": {
"description": "this is the value of snap",
"items": {
"enum": [
"male",
"female",
"other",
"not_given"
],
"type": "string"
},
"title": "l",
"type": "array"
}
},
"required": [
"gender_list"
],
"title": "GenderTest",
"type": "object"
}
2 changes: 1 addition & 1 deletion schema_entry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def remove_defs_interference(d: Dict[str, Any]) -> Dict[str, Any]:


def replace_refs(d: Dict[str, Any]) -> Dict[str, Any]:
info = jsonref.replace_refs(d, lazy_load=False)
info = jsonref.replace_refs(d, merge_props=True, lazy_load=False)
if info.get("$defs"):
del info["$defs"]
return info
Expand Down
1 change: 1 addition & 0 deletions tests/test_entrypoint_with_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class GenderTest(BaseModel):

assert root.name == "gendertest"
assert root.__doc__ == "测试description."
print(root.schema)
root(["-l", "male", "-l", "other"])
self.assertDictEqual(root.config, {
"gender": "male",
Expand Down
12 changes: 2 additions & 10 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ def test_pydantic_schema_to_protocol(self) -> None:
'type': 'object'}
get_schema = pydantic_schema_to_protocol(pdschema)

target = {'properties': {'gender': {'enum': ['male', 'female', 'other', 'not_given'],
'type': 'string'},
'gender_list': {'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'}
target = {'properties': {'gender': {'enum': ['male', 'female', 'other', 'not_given'], 'type': 'string', 'description': 'this is the value of snap', 'title': 'g'}, 'gender_list': {
'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'}
self.assertDictEqual(target, get_schema)

0 comments on commit 28ba5e6

Please sign in to comment.