-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add json schema #952
Conversation
📝 WalkthroughWalkthroughA new test file Changes
Sequence DiagramsequenceDiagram
participant Test as Schema Test
participant Ajv as JSON Schema Validator
participant YAML as YAML Parser
participant Schema as Metatype Schema
Test->>YAML: Read configuration files
YAML-->>Test: Parse YAML to JavaScript objects
Test->>Ajv: Create validator instance
Test->>Schema: Load JSON schema
Ajv->>Schema: Compile validation function
Test->>Ajv: Validate each configuration
Ajv-->>Test: Validation result
alt Validation Fails
Test->>Test: Throw assertion error
else Validation Passes
Test->>Test: Test complete
end
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #952 +/- ##
=======================================
Coverage 77.72% 77.72%
=======================================
Files 154 154
Lines 19154 19154
Branches 1930 1930
=======================================
Hits 14888 14888
Misses 4243 4243
Partials 23 23 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
tests/tools/schema_test.ts (1)
25-29
: Add custom loading or preprocessing if necessary.While
addFormats
is sufficient for standard formats, you might need additional keywords or custom validations in the future. Keep an eye on the library's release notes for changes that affect specialized data types (URIs, UUIDs, etc.).tools/schema/metatype.json (4)
21-35
: Suggest adding descriptive examples.It's often helpful to provide small example values for keys like
include
orexclude
to guide users."typegraphLoaderConfig": { "type": "object", "additionalProperties": false, "properties": { + "includeExample": { + "description": "Example patterns for include", + "example": ["**/*.tg", "typegraphs/**/*.yaml"] + }, "include": { "$ref": "#/definitions/path", "description": "A pattern or array of patterns to include." }, ...
36-56
: Expand or unify generator base properties.All generator config bases share some common aspects, but some are more specialized (e.g., Rust). Review if there's a possibility to unify them further or keep them separate by design.
190-234
: Include flexible property fallback or official doc references.You restrict additional properties for typegates. That helps keep the config strict, but if new features appear frequently, consider a fallback approach or a reference to official docs for new properties.
272-288
: Solid definitions for metagen, but consider versioning.Metagen configurations evolve quickly. If older config structures need to be supported, you may want to specify versioning or backward compatibility approach.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
deno.lock
is excluded by!**/*.lock
📒 Files selected for processing (2)
tests/tools/schema_test.ts
(1 hunks)tools/schema/metatype.json
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: lint-compat (macos-14, aarch64-apple-darwin, false)
- GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
- GitHub Check: test-full
- GitHub Check: pre-commit
🔇 Additional comments (5)
tests/tools/schema_test.ts (3)
1-2
: Include a reference to the license information in the PR description.You have established licensing details at the top. It's good practice to cross-reference them in the PR description to remind external contributors and maintainers about the licensing.
5-6
: Validate version alignment and potential vulnerabilities.You're using Ajv v8.12.0 and ajv-formats v3.0.1. Make sure the rest of your dependencies and environment are compatible with these versions.
✅ Verification successful
Version alignment verified - no issues found
The versions of Ajv (v8.12.0) and ajv-formats (v3.0.1) are compatible and properly pinned. The minor version differences in some imports (v8.17.1) maintain backward compatibility within the v8.x series. The version pinning and isolation of test environments demonstrate good dependency management practices.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # This script checks the package.json or import references for potential version mismatches. rg 'ajv' -A 5 rg 'ajv-formats' -A 5Length of output: 21138
14-22
: Consider a stable reference for the example YAML files.It might be beneficial to verify that these example YAML files exist and remain up-to-date. Ensure that the paths you reference (especially those in examples/templates) are accurate and under version control.
✅ Verification successful
All referenced YAML files exist and paths are correct
The relative paths in the code are accurate when resolved from
tests/tools/schema_test.ts
. All the referenced metatype YAML files exist in the repository and are under version control. No changes are needed.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # This script checks for the existence of each file reference for file in "../metatype.yml" "../../examples/metatype.yaml" "../../examples/templates/deno/metatype.yaml" "../../examples/templates/node/metatype.yaml" "../../examples/templates/python/metatype.yaml" "../metagen/typegraphs/sample/metatype.yml" "../metagen/typegraphs/identities/metatype.yml"; do if [[ ! -f "$file" ]]; then echo "Missing file: $file" fi doneLength of output: 3215
Script:
#!/bin/bash # Search for all metatype yaml/yml files in the repository echo "Searching for metatype.y(a)ml files:" fd -t f "metatype\.(yaml|yml)$"Length of output: 482
tools/schema/metatype.json (2)
1-5
: Congratulations on adding a descriptive schema.The
$schema
and$id
references, along withtitle
, are well-defined. This is a great start for discoverability on the SchemaStore.
156-187
: Confirm that all generator configs match real usage.Make sure the schema covers all possible future expansions of your generator configurations so that you don’t need frequent schema updates.
✅ Verification successful
All generator configurations in the schema match actual usage patterns
Found evidence of all generator types being actively used across the codebase:
- Client generators (client_ts, client_py, client_rs) in test typegraphs
- FDK generators (fdk_typescript, fdk_python, fdk_rust) in example configurations
- Sub-generator configuration used with stubbed runtimes
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Searching for references to config generator usage rg -A 10 'generatorConfig'Length of output: 1699
Script:
#!/bin/bash # Find config files that might contain generator configurations fd -e json -e yaml -e yml | xargs rg -l 'generator|typegraph' # Look for actual generator implementations rg -l "class.*Generator"Length of output: 851
Script:
#!/bin/bash # Check content of main metatype config files echo "=== whiz.yaml ===" cat whiz.yaml echo -e "\n=== src/metagen/metatype.yaml ===" cat src/metagen/metatype.yaml echo -e "\n=== examples/metatype.yaml ===" cat examples/metatype.yamlLength of output: 9693
Script:
#!/bin/bash # Check test files for generator configurations echo "=== tests/metatype.yml ===" cat tests/metatype.yml echo -e "\n=== tests/metagen/typegraphs/sample/metatype.yml ===" cat tests/metagen/typegraphs/sample/metatype.ymlLength of output: 2288
<!-- Pull requests are squashed and merged using: - their title as the commit message - their description as the commit body Having a good title and description is important for the users to get readable changelog. --> <!-- 1. Explain WHAT the change is about --> - Add a self-hosted json schema that will be referenced to [schemastore](https://www.schemastore.org/json/), part of [MET-798](https://linear.app/metatypedev/issue/MET-798/metatype-schema-for-ide-support). <!-- 3. Explain HOW users should update their code --> --- - [x] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> - **New Features** - Added comprehensive configuration schema validation for Metatype system configuration files. - Implemented JSON schema testing to ensure configuration integrity across multiple YAML files. - **Tests** - Introduced new test suite for validating configuration schema using Ajv JSON schema validator. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- Pull requests are squashed and merged using: - their title as the commit message - their description as the commit body Having a good title and description is important for the users to get readable changelog. --> <!-- 1. Explain WHAT the change is about --> - Add a self-hosted json schema that will be referenced to [schemastore](https://www.schemastore.org/json/), part of [MET-798](https://linear.app/metatypedev/issue/MET-798/metatype-schema-for-ide-support). <!-- 3. Explain HOW users should update their code --> --- - [x] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> - **New Features** - Added comprehensive configuration schema validation for Metatype system configuration files. - Implemented JSON schema testing to ensure configuration integrity across multiple YAML files. - **Tests** - Introduced new test suite for validating configuration schema using Ajv JSON schema validator. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Migration notes
Summary by CodeRabbit
New Features
Tests