diff --git a/tests/schema/__snapshots__/test_schema.ambr b/tests/schema/__snapshots__/test_schema.ambr index 70cadf12c..3f811ecb2 100644 --- a/tests/schema/__snapshots__/test_schema.ambr +++ b/tests/schema/__snapshots__/test_schema.ambr @@ -5090,6 +5090,48 @@ }), }) # --- +# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error] + ''' + ERROR: Need 'SPEC_1' has schema violations: + Severity: violation + Need path: IMPL_1 > links > SPEC_1 + Schema path: [0] > validate > network > links > items > local > unevaluatedProperties + Schema message: Unevaluated properties are not allowed ('asil' was unexpected) [sn_schema_violation.network_local_fail] + + ''' +# --- +# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error].1 + dict({ + 'validated_needs_count': 2, + 'validation_warnings': dict({ + 'IMPL_1': list([ + dict({ + 'children': list([ + ]), + 'details': dict({ + 'need_path': 'IMPL_1 > links > SPEC_1', + 'schema_path': '[0] > validate > network > links > items > local > unevaluatedProperties', + 'severity': 'violation', + 'validation_msg': "Unevaluated properties are not allowed ('asil' was unexpected)", + }), + 'log_lvl': 'error', + 'subtype': 'network_local_fail', + 'type': 'sn_schema_violation', + }), + ]), + }), + }) +# --- +# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok] + '' +# --- +# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok].1 + dict({ + 'validated_needs_count': 2, + 'validation_warnings': dict({ + }), + }) +# --- # name: test_schemas[schema/fixtures/network-no_error_empty_links] ''' ERROR: Need 'IMPL_SAFE' has schema violations: diff --git a/tests/schema/fixtures/network.yml b/tests/schema/fixtures/network.yml index b0d0505f3..43d71df4c 100644 --- a/tests/schema/fixtures/network.yml +++ b/tests/schema/fixtures/network.yml @@ -627,6 +627,76 @@ max_network_levels: type: const: spec +network_local_unevaluated_reduced_ok: + # The network-local schema uses ``unevaluatedProperties``, whose semantics are only + # meaningful after ``reduce_need()`` strips the fields the schema does not reference. + # SN applies that same reduction inside the network path (``_validate_need_local``) + # as for top-level local validation, so the linked spec — reduced to just + # ``{type: spec}`` — validates cleanly and ``items`` passes with no warning. + conf: | + extensions = ["sphinx_needs"] + needs_from_toml = "ubproject.toml" + needs_schema_definitions_from_json = "schemas.json" + ubproject: | + [needs.fields.asil] + nullable = true + rst: | + .. spec:: title + :id: SPEC_1 + + .. impl:: title + :id: IMPL_1 + :links: SPEC_1 + schemas: + $defs: [] + schemas: + - select: + properties: + type: {const: "impl"} + validate: + network: + links: + items: + local: + properties: + type: {const: spec} + unevaluatedProperties: false + +network_local_unevaluated_reduced_error: + # Same as ``network_local_unevaluated_reduced_ok`` but the linked spec sets an extra + # field (``asil``) that the network-local schema does not reference. ``reduce_need()`` + # keeps actively-set extra fields, so ``unevaluatedProperties: false`` still fails on + # it — confirming reduction matches the top-level path without masking real violations. + conf: | + extensions = ["sphinx_needs"] + needs_from_toml = "ubproject.toml" + needs_schema_definitions_from_json = "schemas.json" + ubproject: | + [needs.fields.asil] + nullable = true + rst: | + .. spec:: title + :id: SPEC_1 + :asil: QM + + .. impl:: title + :id: IMPL_1 + :links: SPEC_1 + schemas: + $defs: [] + schemas: + - select: + properties: + type: {const: "impl"} + validate: + network: + links: + items: + local: + properties: + type: {const: spec} + unevaluatedProperties: false + link_name_contains: conf: | extensions = ["sphinx_needs"]