Skip to content

fix: updated documentLoader to load stored JSON#27

Merged
rongquan1 merged 1 commit intomasterfrom
fix/oav3-dep
Apr 23, 2026
Merged

fix: updated documentLoader to load stored JSON#27
rongquan1 merged 1 commit intomasterfrom
fix/oav3-dep

Conversation

@isaackps
Copy link
Copy Markdown

@isaackps isaackps commented Apr 22, 2026

Summary

OA V3 is deprecated and the schemata is being used in V3. This PR is to update the context loader so that it will detect schemata.openattestation.com and load the stored context JSON instead of calling the endpoint.

Changes

  • documentLoader to load stored JSON when Schemata.openattestation.com is detected

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for HTTP document loading and context resolution validation
  • New Features

    • Added bundled local JSON-LD context files: OpenAttestation v3, DrivingLicenceCredential, and CustomContext
  • Refactor

    • Switched from remote context fetching to bundled local contexts for improved performance and reliability
    • Exported context resolution functionality for broader usability

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8fc7e84-10e8-4351-9461-0b860bf636d8

📥 Commits

Reviewing files that changed from the base of the PR and between eed6abb and d053061.

📒 Files selected for processing (6)
  • src/3.0/validate/__tests__/documentLoader-http.test.ts
  • src/3.0/validate/__tests__/validate.test.ts
  • src/3.0/validate/contexts/CustomContext.json
  • src/3.0/validate/contexts/DrivingLicenceCredential.json
  • src/3.0/validate/contexts/OpenAttestation.v3.json
  • src/3.0/validate/validate.ts

📝 Walkthrough

Walkthrough

Introduced bundled JSON-LD context files and modified the document loader to resolve hardcoded contexts locally instead of remote preloading. Added corresponding tests to verify context resolution and HTTP behavior for schemata and non-schemata URLs.

Changes

Cohort / File(s) Summary
JSON-LD Context Definitions
src/3.0/validate/contexts/OpenAttestation.v3.json, src/3.0/validate/contexts/DrivingLicenceCredential.json, src/3.0/validate/contexts/CustomContext.json
Added three bundled JSON-LD context files with vocabulary mappings, datatype definitions, and version/protection settings for OpenAttestation, DrivingLicence, and custom credential types.
Validation Logic Update
src/3.0/validate/validate.ts
Replaced remote context preloading with bundled local contexts. Added resolveHardcodedContext() function to resolve schemata URLs to bundled contexts by filename. Updated documentLoader to intercept context URLs and return pre-bundled payloads, falling back to cached loader behavior for unmatched URLs. Exported both functions.
Document Loader HTTP Tests
src/3.0/validate/__tests__/documentLoader-http.test.ts
Added tests verifying that documentLoader performs real HTTP GET requests for non-schemata URLs and confirms zero HTTP requests for schemata URLs, validating network behavior.
Context Resolution Tests
src/3.0/validate/__tests__/validate.test.ts
Added test suite for resolveHardcodedContext validating bundled context resolution for schemata hosts, confirming correct context selection, undefined returns for unknown hosts, and fixture-level assertions for context count and resolution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Bundled contexts hop into place,
No network calls in this space,
Local JSON guards the way,
Validation swift and safe today!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: updating documentLoader to load stored JSON instead of fetching from external endpoints for schemata URLs.
Description check ✅ Passed The description covers the required template sections with background (OA V3 deprecation), concrete changes (documentLoader behavior), but lacks explicit issue/story references.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oav3-dep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rongquan1 rongquan1 merged commit 26d0cc5 into master Apr 23, 2026
11 checks passed
@rongquan1 rongquan1 deleted the fix/oav3-dep branch April 23, 2026 03:34
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.10.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants