-
Notifications
You must be signed in to change notification settings - Fork 305
Open
Description
Summary
Currently extends field is defined as oneof of single string vs array of strings. This makes validation and usage really complicated where just an array of strings where there is a validation for a single item in some cases would be much simpler
source/schemas/capability.json
Motivation
Having structures with non-defined types for fields make implementations harder where there needs to be validations for types. In this case it seems unnecesary as replacing a single string for an array of strings, and adding the restriction of a single item would be much simpler
Goals
- Simplify implementation
- define clearer types for fields
Detailed Design
-
Data Structures: D
-
Replace
extendsfield in capability for array only
{
"type": "object",
"properties": {
"extends": {
"oneOf": [
{
"type": "string",
"pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
},
{
"type": "array",
"items": {
"type": "string",
"pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
},
"minItems": 1
}
],
"description": "Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions."
}
}
}
by
{
"type": "object",
"properties": {
"extends": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
},
"minItems": 1
}
"description": "Parent capability(s) this extends. Present for extensions, absent for root capabilities."
}
}
}
Risks and Mitigations
- Backward Compatibility:
This is a breaking change as defined, unless we keep the oneof versino but discourage the use of single string.
Reactions are currently unavailable