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 0f06a41 commit 10f8e53
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions schema_entry/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ def __call__(self, argv: Sequence[str]) -> Optional[Any]:
description=self.__doc__,
usage=self.usage,
formatter_class=argparse.RawDescriptionHelpFormatter)
self.pass_args_to_sub(parser, argv)
return self.pass_args_to_sub(parser, argv)
else:
parser = argparse.ArgumentParser(
prog=self.prog,
epilog=self.epilog,
description=self.__doc__,
usage=self.usage)
self.parse_args(parser, argv)
return self.parse_args(parser, argv)

def pass_args_to_sub(self, parser: argparse.ArgumentParser, argv: Sequence[str]) -> None:
scmds = list(self._subcmds.keys())
Expand Down
10 changes: 4 additions & 6 deletions schema_entry/entrypoint_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@


class PydanticModelLike(Protocol):
def model_json_schema(self,
by_alias: bool,
ref_template: str,
schema_generator: Any,
mode: JsonSchemaMode
) -> Dict[str, Any]:
__name__: str
__doc__: str

def model_json_schema(self, *args: Any, **kwargs: Any) -> Dict[str, Any]:
...


Expand Down
13 changes: 7 additions & 6 deletions schema_entry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def parse_schema_as_cmd(key: str, schema: PropertyType, parser: argparse.Argumen


def _remove_sigal_allOf(x: Dict[str, Any]) -> Dict[str, Any]:
info = {}
info: Dict[str, Any] = {}
if x.get("allOf"):
if len(x["allOf"]) == 1:
info.update(**x["allOf"][0])
Expand All @@ -233,15 +233,16 @@ def _remove_sigal_allOf(x: Dict[str, Any]) -> Dict[str, Any]:


def remove_sigal_allOf(d: Dict[str, Any]) -> Dict[str, Any]:
for key, value in d.get('properties').items():
info = _remove_sigal_allOf(value)
d['properties'][key] = info
if d.get('properties'):
for key, value in d.get('properties').items():
info = _remove_sigal_allOf(value)
d['properties'][key] = info
return d


def remove_defs_interference(d: Dict[str, Any]) -> Dict[str, Any]:
if d.get("$defs"):
for key, value in d["$defs"].items():
if d.get("$defs") and isinstance(d["$defs"], dict):
for _, value in d["$defs"].items():
if value.get("title"):
del value["title"]
if value.get("description"):
Expand Down

0 comments on commit 10f8e53

Please sign in to comment.