-
Notifications
You must be signed in to change notification settings - Fork 3k
Add JSON schema based validation to mbed config script #5022
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fd208e6
Add JSON schema based validation to mbed config script
d208421
Add JSON Schema library to requirements.txt
3ff7de9
Remove config_path setting and amend regex in mbed config JSON schema
151f2fa
Refactor common JSON schema definitions into a seperate file
7010010
Remove placeholder $id from JSON schema and fix description
b1ea388
Fix test errors produced by JSON schema after rebase
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ mbed-greentea>=0.2.24 | |
beautifulsoup4>=4 | ||
fuzzywuzzy>=0.11 | ||
pyelftools>=0.24 | ||
jsonschema>=2.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"name_definition": { | ||
"description": "Name of the library", | ||
"type": "string", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"macro_definition": { | ||
"description": "A list of extra macros that will be defined when compiling a project that includes this library.", | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"pattern": "(^[\\w]+$|^[\\w]+=.+$)" | ||
} | ||
}, | ||
"config_definition": { | ||
"description": "List of configuration parameters", | ||
"type": "object", | ||
"patternProperties": { | ||
"^[^ ]+$": { | ||
"$ref": "#/config_parameter_base" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"target_overrides_definition": { | ||
"description": "List of overrides for specific targets", | ||
"type": "object", | ||
"patternProperties": { | ||
"\\*": { | ||
"type": "object", | ||
"patternProperties": { | ||
".*\\..*": {} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"^\\S+$": { | ||
"$ref": "#/target_override_entry" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"config_parameter_long": { | ||
"type": "object", | ||
"properties": { | ||
"help": { | ||
"description": "An optional help message that describes the purpose of the parameter", | ||
"type": "string" | ||
}, | ||
"value": { | ||
"description": "An optional field that defines the value of the parameter", | ||
"type": [ | ||
"integer", | ||
"string", | ||
"boolean", | ||
"null" | ||
] | ||
}, | ||
"required": { | ||
"description": "An optional field that specifies whether the parameter must be given a value before compiling the code. (False by default)", | ||
"type": "boolean" | ||
}, | ||
"macro_name": { | ||
"description": "An optional field for the macro defined at compile time for this configuration parameter. The system will automatically figure out the macro name from the configuration parameter, but this field will override it", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"config_parameter_short": { | ||
"type": [ | ||
"string", | ||
"integer", | ||
"boolean", | ||
"null" | ||
] | ||
}, | ||
"config_parameter_base": { | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/config_parameter_long" | ||
}, | ||
{ | ||
"$ref": "#/config_parameter_short" | ||
} | ||
] | ||
}, | ||
"target_override_entry": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^\\S+$": {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should contain |
||
}, | ||
"additionalProperties": false | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"title": "Mbed Library Schema", | ||
"description": "Configuration file for an mbed application", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"$ref": "definitions.json#/name_definition" | ||
}, | ||
"config": { | ||
"$ref": "definitions.json#/config_definition" | ||
}, | ||
"target_overrides": { | ||
"$ref": "definitions.json#/target_overrides_definition" | ||
}, | ||
"macros": { | ||
"$ref": "definitions.json#/macro_definition" | ||
}, | ||
"artifact_name": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"title": "Mbed Library Schema", | ||
"description": "Configuration file for an mbed library", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"$ref": "definitions.json#/name_definition" | ||
}, | ||
"config": { | ||
"$ref": "definitions.json#/config_definition" | ||
}, | ||
"target_overrides": { | ||
"$ref": "definitions.json#/target_overrides_definition" | ||
}, | ||
"macros": { | ||
"$ref": "definitions.json#/macro_definition" | ||
} | ||
}, | ||
"required": [ | ||
"name" | ||
], | ||
"additionalProperties": false | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"K64F": { | ||
"exception_msg": "Unknown key(s)" | ||
"exception_msg": "Additional properties are not allowed ('unknown_key' was unexpected)" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"K64F": { | ||
"exception_msg": "Unknown key(s)" | ||
"exception_msg": "Additional properties are not allowed ('unknown_key' was unexpected)" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be the same as the pattern property below,
"$ref": "#/target_override_entry"