bitbake-setup JSON Schema: Fix linting errors
v3 cover bitbake-setup JSON Schema: Fix linting errors
UPDATES v3:
* bitbake-setup.schema.json
* Updated example to bitbake+openembedded-core with qemux86-64+nodistro
* layers.schema.json
* Fixed typo in description
* Fixed up the title and description
* Put the version element at the end
* Used the short form
UPDATES v2:
The following updates were made to v2 of this series:
* Include an additional patch fixing an existing typo
* Update the examples property to wrap it in an array and add a required configuration element
This series fixes some linting errors in the JSON Schema. Problems were found using the https://github.com/sourcemeta/jsonschema tool.
Here are the steps used to install and use the tool to lint the schemas:
``` python3 -m venv venv source venv/bin/activate pip install sourcemeta-jsonschema ```
``` jsonschema lint setup-schema/bitbake-setup.schema.json jsonschema lint setup-schema/layers.schema.json ```
NOTE: The examples are annotations and are meant for humans reading the schema. They do not typically get checked automatically by the JSON Schema validation tools. Use jq to extract the JSON object into its own file to check it separately.
``` cd setup-schema jq .examples[] bitbake-setup.schema.json > bitbake-setup.schema-examples.json jsonschema validate bitbake-setup.schema.json bitbake-setup.schema-examples.json jq .examples[] layers.schema.json > layers.schema-examples.conf.json jsonschema validate layers.schema.json layers.schema-examples.conf.json cd .. bitbake/bin/bitbake-setup init bitbake/setup-schema/bitbake-setup.schema-examples.conf.json ```
``` jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/oe-nodistro-master.conf.json jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/oe-nodistro-whinlatter.conf.json jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/poky-master.conf.json jsonschema validate setup-schema/bitbake-setup.schema.json default-registry/configurations/poky-whinlatter.conf.json ```
There are 2 outstanding types of linting errors related to the use of hyphen in the property names and the enum currently having only one value:
Set properties to identifier names that can be easily mapped to programming languages (matching [A-Za-z_][A-Za-z0-9_]*) (simple_properties_identifiers).
An enum of a single value can be expressed as const (enum_to_const)
The former would require a larger discussion and potentially increasing the version number. Updating the enum to include a new version would also resolve the latter error.
I do not believe that the changes in this series merit increasing the version of the schema.
Resolving these outstanding errors is not necessary for validating the Bitbake Configuration files.
UPDATE v2: Additional testing was performed with oe-selftest. This uses
python3-jsonschema which is a different implementation and caught additional linting errors.
UPDATE v3: Tested with bitbake-selftest, oe-selftest, and bitbake quilt-native
```
git clone https://git.openembedded.org/bitbake
./bitbake/bin/bitbake-setup init --non-interactive poky-master poky machine/qemux86-64 distro/poky
. /ala-lpggp31/rwoolley/oe-selftest-testing/bitbake-builds/poky-master/build/init-build-env
echo 'SANITY_TESTED_DISTROS = ""' >> conf/local.conf
oe-selftest -r bblayers.BitbakeLayers
```---
Rob Woolley (10):
bitbake-setup.schema.json: Add title for schema bitbake-setup.schema.json: Add examples property bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas bitbake-setup.schema.json: Remove trailing period layers.schema.json: Add missing schema layers.schema.json: Add title for subschema layers.schema.json: Add examples property layers.schema.json: Remove trailing period layers.schema.json: Fix typo in property name bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas
setup-schema/bitbake-setup.schema.json | 40 +++++++++++++++++++++++++++++++--- setup-schema/layers.schema.json | 29 ++++++++++++++++++++---- 2 files changed, 62 insertions(+), 7 deletions(-)
---
base-commit: 020a5ba24c7df53eacf834deb87216053ccd38db
change-id: 20260615-fix-bitbake-schema-0ae8bd18a24c
Best regards,
Signature · 1 line
Rob Woolley <[email protected]>
PATCH v3 1/10 bitbake-setup.schema.json: Add title for schema
Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)
--- setup-schema/bitbake-setup.schema.json | 1 + 1 file changed, 1 insertion(+)
setup-schema/bitbake-setup.schema.json +1 -0
@@ -1,6 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "Schema for bitbake-setup configuration files", + "title": "bitbake-setup configuration file", "type": "object", "required": [ "description",
Signature · 1 line
2.49.0
PATCH v3 2/10 bitbake-setup.schema.json: Add examples property
In reply to Rob WoolleyThis resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)
This example intentionally only references bitbake as a minimal example that focuses on the tool itself.
--- setup-schema/bitbake-setup.schema.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
setup-schema/bitbake-setup.schema.json +33 -0
@@ -1,6 +1,39 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "Schema for bitbake-setup configuration files", + "examples" : [ + { + "description": "Example bitbake-setup configuration file", + "sources": { + "bitbake": { + "git-remote": { + "uri": "https://git.openembedded.org/bitbake", + "rev": "master" + }, + "path": "bitbake" + }, + "openembedded-core": { + "git-remote": { + "uri": "https://git.openembedded.org/openembedded-core", + "rev": "master" + }, + "path": "openembedded-core" + } + }, + "bitbake-setup": { + "configurations": [ + { + "name" : "qemux86-64-nodistro", + "description": "OpenEmbedded 'nodistro' build for qemux86-64", + "setup-dir-name": "oe-nodistro-master", + "bb-layers": ["openembedded-core/meta"], + "oe-fragments": ["machine/qemux86-64"] + } + ] + }, + "version": "1.0" + } + ], "title": "bitbake-setup configuration file", "type": "object", "required": [
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH v3 02/10] bitbake-setup.schema.json: Add examples property
Quoted 6 lines · Rob Woolley via lists.openembedded.org
This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)This example intentionally only references bitbake as a minimal example that focuses on the tool itself.
Nitpick: The commit message does not match the content anymore.
Quoted 2 lines
Signed-off-by Rob Woolley <[email protected]>
Quoted 48 lines
--- setup-schema/bitbake-setup.schema.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)setup-schema/bitbake-setup.schema.json +33
-0@@ -1,6 +1,39 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "Schema for bitbake-setup configuration files", + "examples" : [ + { + "description": "Example bitbake-setup configuration file", + "sources": { + "bitbake": { + "git-remote": { + "uri": "https://git.openembedded.org/bitbake", + "rev": "master" + }, + "path": "bitbake" + }, + "openembedded-core": { + "git-remote": { + "uri": "https://git.openembedded.org/openembedded-core", + "rev": "master" + }, + "path": "openembedded-core" + } + }, + "bitbake-setup": { + "configurations": [ + { + "name" : "qemux86-64-nodistro", + "description": "OpenEmbedded 'nodistro' build for qemux86-64", + "setup-dir-name": "oe-nodistro-master", + "bb-layers": ["openembedded-core/meta"], + "oe-fragments": ["machine/qemux86-64"] + } + ] + }, + "version": "1.0" + } + ], "title": "bitbake-setup configuration file", "type": "object", "required": [
Signature · 2 lines
Yoann Congal Smile ECS
PATCH v3 3/10 bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas
In reply to Rob WoolleyThe oneOf keyword is for matching exactly one subschema.
However, the 2 possible BitBake configuration fragments are not disjoint. Since a simple example with type and description would match both. For this reason, we should use anyOf instead.
This resolves the following jsonschema linting error:
A oneOf where all branches have disjoint types can be safely converted to anyOf (oneof_to_anyof_disjoint_types)
--- setup-schema/bitbake-setup.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
@@ -112,7 +112,7 @@ "type": "array", "description": "List of BitBake configuration fragments to enable", "items": { - "oneOf": [ + "anyOf": [ { "type": "string", "description": "Configuration fragment name"
Signature · 1 line
2.49.0
PATCH v3 4/10 bitbake-setup.schema.json: Remove trailing period
In reply to Rob WoolleyThis resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)
--- setup-schema/bitbake-setup.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
@@ -170,7 +170,7 @@ }, "setup-dir-name": { "type": "string", - "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections." + "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections" } }, "additionalProperties": false
Signature · 1 line
2.49.0
PATCH v3 5/10 layers.schema.json: Add missing schema
In reply to Rob WoolleyThis resolves the jsonschema error:
error: The JSON document is not a valid JSON Schema
--- setup-schema/layers.schema.json | 1 + 1 file changed, 1 insertion(+)
setup-schema/layers.schema.json +1 -0
@@ -1,4 +1,5 @@ { + "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "OpenEmbedder Layer Setup Manifest", "type": "object", "additionalProperties": false,
Signature · 1 line
2.49.0
PATCH v3 6/10 layers.schema.json: Add title for subschema
In reply to Rob WoolleyResolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)
--- setup-schema/layers.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
setup-schema/layers.schema.json +2 -1
@@ -1,6 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "OpenEmbedder Layer Setup Manifest", + "description": "A schema for a manifest of layers to setup", + "title": "OpenEmbedded Layer Setup Schema", "type": "object", "additionalProperties": false, "required": [
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH v3 06/10] layers.schema.json: Add title for subschema
Quoted 6 lines · Rob Woolley via lists.openembedded.org
Resolves the jsonschema linting error:
Set a concise non-empty title at the top level of the schema to explain what the definition is about (top_level_title)Signed-off-by Rob Woolley <[email protected]>---
Quoted 16 lines
setup-schema/layers.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)setup-schema/layers.schema.json +2
-1@@ -1,6 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "OpenEmbedder Layer Setup Manifest", + "description": "A schema for a manifest of layers to setup", + "title": "OpenEmbedded Layer Setup Schema", "type": "object", "additionalProperties": false, "required": [
Signature · 2 lines
Yoann Congal Smile ECS
PATCH v3 7/10 layers.schema.json: Add examples property
In reply to Rob WoolleyThis resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)
This example intentionally only references bitbake as a minimal example that focuses on the tool itself.
--- setup-schema/layers.schema.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
setup-schema/layers.schema.json +19 -0
@@ -2,6 +2,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A schema for a manifest of layers to setup", "title": "OpenEmbedded Layer Setup Schema", + "examples" : [ + { + "version": "1.0", + "sources": { + "bitbake": { + "git-remote": { + "remotes": { + "origin": { + "uri": "https://git.openembedded.org/bitbake" + } + }, + "branch": "master", + "rev": "master" + }, + "path": "bitbake" + } + } + } + ], "type": "object", "additionalProperties": false, "required": [
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH v3 07/10] layers.schema.json: Add examples property
Quoted 9 lines · Rob Woolley via lists.openembedded.org
This resolves the jsonschema linting error:
Set a non-empty examples array at the top level of the schema to illustrate the expected data (top_level_examples)This example intentionally only references bitbake as a minimal example that focuses on the tool itself.
Signed-off-by Rob Woolley <[email protected]>---
This is the same as v2 I reviewed here:
https://lore.kernel.org/bitbake-devel/[email protected]/
My remarks still apply.
Quoted 33 lines
setup-schema/layers.schema.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)setup-schema/layers.schema.json +19
-0@@ -2,6 +2,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "description": "A schema for a manifest of layers to setup", "title": "OpenEmbedded Layer Setup Schema", + "examples" : [ + { + "version": "1.0", + "sources": { + "bitbake": { + "git-remote": { + "remotes": { + "origin": { + "uri": "https://git.openembedded.org/bitbake" + } + }, + "branch": "master", + "rev": "master" + }, + "path": "bitbake" + } + } + } + ], "type": "object", "additionalProperties": false, "required": [
Signature · 2 lines
Yoann Congal Smile ECS
PATCH v3 8/10 layers.schema.json: Remove trailing period
In reply to Rob WoolleyThis resolves the jsonschema linting error:
Descriptions should not end with a period to give user interfaces flexibility in presenting the text (description_trailing_period)
--- setup-schema/layers.schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
setup-schema/layers.schema.json +2 -2
@@ -44,7 +44,7 @@ "type": "string" }, "contains_this_file": { - "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then.", + "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then", "type": "boolean" }, "git-remote": {
@@ -64,7 +64,7 @@ "type": "string" }, "describe": { - "description": "The output of 'git describe' (human readable description of the revision using tags in revision history).", + "description": "The output of 'git describe' (human readable description of the revision using tags in revision history)", "type": "string" }, "uri": {
Signature · 1 line
2.49.0
PATCH v3 9/10 layers.schema.json: Fix typo in property name
In reply to Rob Woolley--- setup-schema/layers.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/layers.schema.json +1 -1
@@ -77,7 +77,7 @@ "patternProperties": { ".*" : { "description": "A git remote", "type": "object", - "addtionalProperties": false, + "additionalProperties": false, "required": [ "uri" ],
Signature · 1 line
2.49.0
PATCH v3 10/10 bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas
In reply to Rob WoolleyThe oneOf keyword is for matching exactly one subschema. However, the branches have disjoint types so it can be safely converted to anyOf.
This resolves the following jsonschema linting error:
A oneOf where all branches have disjoint types can be safely converted to anyOf (oneof_to_anyof_disjoint_types)
--- setup-schema/bitbake-setup.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
setup-schema/bitbake-setup.schema.json +1 -1
@@ -76,7 +76,7 @@ "description": "Human-readable description of the configuration" }, "notes": { - "oneOf": [ + "anyOf": [ { "type": "string" },
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH v3 10/10] bitbake-setup.schema.json: Use anyOf for non-disjoint subschemas
Quoted 9 lines · Rob Woolley via lists.openembedded.org
The oneOf keyword is for matching exactly one subschema. However, the branches have disjoint types so it can be safely converted to anyOf.
This resolves the following jsonschema linting error:
AoneOfwhere all branches have disjoint types can be safely converted toanyOf(oneof_to_anyof_disjoint_types)Signed-off-by Rob Woolley <[email protected]>
This look confusingly similar to 3/10.
Either make the title more precise or merge the 2 in 3/10 (I'd do the latter).
Thanks!
Quoted 17 lines
--- setup-schema/bitbake-setup.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)setup-schema/bitbake-setup.schema.json +1
-1@@ -76,7 +76,7 @@ "description": "Human-readable description of the configuration" }, "notes": { - "oneOf": [ + "anyOf": [ { "type": "string" },
Signature · 2 lines
Yoann Congal Smile ECS