Skip to content

Commit

Permalink
feat: add default_default and default_annotation control in json_sche…
Browse files Browse the repository at this point in the history
…ma_to_signature
  • Loading branch information
thorwhalen committed Mar 22, 2024
1 parent 3a81571 commit f4a0457
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ju/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ def function_to_json_schema(


def json_schema_to_signature(
json_schema: dict, *, type_mapper: Mapper = DFLT_JSON_PY_TYPE_PAIRS
json_schema: dict,
*,
type_mapper: Mapper = DFLT_JSON_PY_TYPE_PAIRS,
default_default=Parameter.empty,
default_annotation=Parameter.empty,
):
"""
Transforms a JSON schema to a Python function signature.
Expand All @@ -238,7 +242,7 @@ def json_schema_to_signature(
"""
type_mapper = ensure_callable_mapper(type_mapper)
type_mapper = ensure_callable_mapper(type_mapper, default=default_annotation)
properties = json_schema['properties']

def _params():
Expand All @@ -252,7 +256,7 @@ def _params():
py_type = Union[tuple(json_types)]
else:
py_type = Parameter.empty
default = field.get('default', Parameter.empty)
default = field.get('default', default_default)
yield Parameter(
name=name,
annotation=py_type,
Expand Down

0 comments on commit f4a0457

Please sign in to comment.