Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pdl/pdl_schema_error_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def analyze_errors(defs, schema, data, loc: LocationType) -> list[str]: # noqa:
ret += analyze_errors(
defs, schema["properties"][field], data[field], newloc
)
if "additionalProperties" in schema.keys() and not isinstance(
schema["additionalProperties"], bool
):
for key, value in data.items():
nloc = append(loc, key)
ret += analyze_errors(
defs, schema["additionalProperties"], value, nloc
)

elif is_any_of(schema):
if len(schema["anyOf"]) == 2 and nullable(schema):
Expand Down
11 changes: 11 additions & 0 deletions tests/data/line/hello31.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defs:

# ... several other defs, ~85 lines
get_current_weather:
function:
subject: str
return:
api: https
url: https://api.weatherapi.com/v1/current.json?key=cf601276764642cb96224947230712&q=
input: "{{ subject }}"
show_result: false
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
pathlib.Path("tests") / "data" / "line" / "hello8.pdl",
pathlib.Path("tests") / "data" / "line" / "hello10.pdl",
pathlib.Path("tests") / "data" / "line" / "hello11.pdl",
pathlib.Path("tests") / "data" / "line" / "hello31.pdl",
]


Expand Down
15 changes: 15 additions & 0 deletions tests/test_line_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,18 @@ def test_line29(capsys):

def test_line30(capsys):
do_test(line30, capsys)


line31 = {
"file": "tests/data/line/hello31.pdl",
"errors": [
"",
"tests/data/line/hello31.pdl:0 - Missing required field: function",
"tests/data/line/hello31.pdl:0 - Missing required field: return",
"tests/data/line/hello31.pdl:11 - Field not allowed: show_result",
],
}


def test_line31(capsys):
do_test(line31, capsys)