Previously, @context and @type were always stripped from domain data before
validation. This caused failures when a schema explicitly declares these as
required properties, resulting in "missing required field" errors. The fix
checks whether each field is declared in the schema's properties before
deciding to strip it.
Replace fixed JSON struct tags for bpp_uri and bap_uri with a map-based parse of
the context object. A new getContextString() helper checks the snake_case key first
and falls back to the camelCase key, so routing works transparently for both the
legacy beckn spec and the new camelCase convention.
Also adds a nil-context guard so a missing context field returns a clear error
instead of a panic.
Test coverage:
- Two new cases in TestRouteSuccess for bppUri and bapUri camelCase payloads
- TestGetContextString: 5 table-driven cases covering snake, camel, precedence,
missing, and empty-snake-fallthrough scenarios
- TestRouteNilContext: confirms clear error on missing context field
Fixes#636
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add transactionId and messageId as camelCase aliases in model.go contextKeys map,
pointing to the same ContextKeyTxnID and ContextKeyMsgID constants. This allows
adapter configs to reference either form without failing startup validation.
- In reqpreprocessor, add firstNonNil() helper for subscriber/caller ID lookups
so bap_id/bapId and bpp_id/bppId are both resolved correctly regardless of
which beckn spec version the payload uses. snake_case takes precedence when both
are present.
- Add snakeToCamel() helper used in the context key loop so a single config entry
(e.g. transaction_id) automatically also checks the camelCase form (transactionId)
without requiring any config file changes.
- Add TestSnakeToCamel, TestCamelCaseSubscriberID, TestCamelCaseContextKeys to
cover all new code paths.
Fixes#637
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Renamed the `PolicyEnforcer` interface and related implementations to `PolicyChecker` for clarity and consistency.
- Updated configuration keys in YAML files to reflect the new `checkPolicy` terminology.
- Adjusted related code, tests, and documentation to support the new naming convention and ensure compatibility.
- Enhanced comments and examples for the `checkPolicy` configuration to improve usability.
- Added detailed comments and examples for the `policyPaths` configuration in both BAP and BPP YAML files to improve clarity on usage.
- Introduced a new benchmark test suite for the Policy Enforcer to evaluate performance under varying rule counts, measuring both evaluation and compilation times.
- Updated the Policy Enforcer to consolidate policy source configuration under a single `policyPaths` key, allowing for auto-detection of URLs, directories, and files.
- Removed deprecated keys such as `policyFile` and `policyUrls` from the configuration structure.
- Adjusted related code and tests to ensure compatibility with the new configuration format.
- Enhanced documentation to clarify the usage of `policyPaths` and provide examples for various configurations.
- Changed configuration key from `policyDir` to `policyPaths` across multiple YAML files and related code to standardize the naming convention.
- Updated documentation to reflect the new key name and its usage for specifying local directories containing `.rego` policy files.
- Adjusted tests to ensure compatibility with the updated configuration structure.
- Updated the Policy Enforcer configuration across multiple YAML files to use a unified `policyDir` instead of individual policy sources.
- Changed the step name from `enforcePolicy` to `policyEnforcer` for consistency.
- Enhanced the documentation to clarify the use of `policyUrls`, `policyDir`, and `policyFile` for policy sources.
- Adjusted related code and tests to accommodate the new configuration structure.
- Added documentation for using YAML folded scalar (>-) to keep long comma-separated policyUrls values readable across multiple lines.
- Added a new Policy Enforcer plugin to evaluate incoming messages against OPA policies.
- Configurable via YAML with options for policy sources, actions, and query.
- Integrated into existing configuration files for BAP and BPP.
- Updated related tests and documentation for the new functionality.
- Enhanced plugin manager to support Policy Enforcer instantiation.