diff --git a/pdl/pdl_schema_error_analyzer.py b/pdl/pdl_schema_error_analyzer.py index f6aed8e64..be529bbee 100644 --- a/pdl/pdl_schema_error_analyzer.py +++ b/pdl/pdl_schema_error_analyzer.py @@ -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): diff --git a/tests/data/line/hello31.pdl b/tests/data/line/hello31.pdl new file mode 100644 index 000000000..a6a20fbfa --- /dev/null +++ b/tests/data/line/hello31.pdl @@ -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 \ No newline at end of file diff --git a/tests/test_examples.py b/tests/test_examples.py index f7fc9cd8c..f857b94cc 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -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", ] diff --git a/tests/test_line_table.py b/tests/test_line_table.py index 0006b631a..74d55a6ab 100644 --- a/tests/test_line_table.py +++ b/tests/test_line_table.py @@ -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)