Skip to content

Commit

Permalink
Added schema for .tree.yml file validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AsriFox committed Feb 4, 2024
1 parent 928351a commit ae2477a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]
### Added
- Added schema for `.block.yml` and `.grc` file validation
- Added schema for `.block.yml`, `.tree.yml` and `.grc` file validation
- Added integration with `redhat.vscode-yaml` extension (enables schemas automatically)

### Removed
Expand Down
31 changes: 31 additions & 0 deletions language/schemas/gnuradio-block-tree.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"title": "GRC block category tree",
"description": "",
"$ref": "#/definitions/Tree",
"definitions": {
"Tree": {
"title": "Block category",
"type": "object",
"minProperties": 1,
"maxProperties": 1,
"patternProperties": {
"": {
"type": "array",
"items": {
"oneOf": [
{
"description": "Block type ID",
"type": "string",
"pattern": "[a-zA-Z][a-zA-Z0-9_]+"
},
{
"$ref": "#/definitions/Tree"
}
]
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/yamlSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function checkSchemaEnabled(extensionUri: Uri) {
const schemaPath = (filename: string) => Uri.joinPath(extensionUri, 'language', 'schemas', filename).toString();
const requiredSchemas: [string, string][] = [
[schemaPath('gnuradio-block.schema.json'), '*.block.yml'],
[schemaPath('gnuradio-block-tree.schema.json'), '*.tree.yml'],
[schemaPath('grc-flowgraph.schema.json'), '*.grc']
];
if (requiredSchemas.every(v => schemas[v[0]] === v[1])) {
Expand Down

0 comments on commit ae2477a

Please sign in to comment.