Skip to content

Commit f6a1b04

Browse files
docs(schema): Fix the JSON schema for the repository configuration
By reusing the analyzer configuration schema, the properties incorrectly used camel case notation, change it to snake case. While at it, remove the `Sw360Configuration` from the schema, which is not part of the analyzer configuration model. Resolves #7680 Signed-off-by: Marcel Bochtler <[email protected]>
1 parent 9fde78b commit f6a1b04

5 files changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://oss-review-toolkit.org/repository-configurations/analyzer-configuration.yml",
4+
"title": "ORT analyzer configurations",
5+
"description": "Configurations for the analyzer of the The OSS-Review-Toolkit (ORT). A full list of all available options can be found at https://github.com/oss-review-toolkit/ort/blob/main/model/src/main/kotlin/config/AnalyzerConfiguration.kt.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"properties": {
9+
"allow_dynamic_versions": {
10+
"type": "boolean"
11+
},
12+
"enabled_package_managers": {
13+
"type": "array",
14+
"items": {
15+
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
16+
}
17+
},
18+
"disabled_package_managers": {
19+
"type": "array",
20+
"items": {
21+
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
22+
}
23+
},
24+
"package_managers": {
25+
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/repository-configurations/package-manager-configuration-schema.json"
26+
},
27+
"skip_excluded": {
28+
"type": "boolean"
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://oss-review-toolkit.org/repository-configurations/package-manager-configuration.yml",
4+
"title": "ORT configuration",
5+
"description": "Configurations for package managers for the OSS-Review-Toolkit (ORT). A full list of all available options can be found at https://github.com/oss-review-toolkit/ort/blob/main/model/src/main/kotlin/config/PackageManagerConfiguration.kt.",
6+
"type": "object",
7+
"propertyNames": {
8+
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
9+
},
10+
"additionalProperties": {
11+
"type": "object",
12+
"$ref": "#/definitions/PackageManagerConfigs"
13+
},
14+
"definitions": {
15+
"PackageManagerConfigs": {
16+
"type": "object",
17+
"additionalProperties": false,
18+
"properties": {
19+
"must_run_after": {
20+
"type": "array",
21+
"items": {
22+
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
23+
}
24+
},
25+
"options": {
26+
"additionalProperties": {
27+
"type": [
28+
"boolean",
29+
"number",
30+
"string"
31+
]
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
analyzer:
2+
allow_dynamic_versions: false
3+
enabled_package_managers:
4+
- Gradle
5+
- Maven
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
analyzer:
2+
package_managers:
3+
Gradle:
4+
must_run_after:
5+
- Maven
6+
options:
7+
foo: bar

model/src/test/kotlin/JsonSchemaTest.kt

+26
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ class JsonSchemaTest : StringSpec({
6060
}
6161
}
6262

63+
"Analyzer configuration within a repository configuration validates successfully" {
64+
val repositoryConfiguration = File("src/test/assets/analyzer-repository-configuration.ort.yml").toJsonNode()
65+
val analyzerConfiguration = repositoryConfiguration.get("analyzer")
66+
67+
val errors = schemaV7.getSchema(repositoryConfigurationAnalyzerConfiguration).validate(analyzerConfiguration)
68+
69+
errors should beEmpty()
70+
}
71+
72+
"Package manager configuration within a repository configuration validates successfully" {
73+
val repositoryConfiguration =
74+
File("src/test/assets/package-manager-repository-configuration.ort.yml").toJsonNode()
75+
val packageManagerConfiguration = repositoryConfiguration.get("analyzer").get("package_managers")
76+
77+
val errors =
78+
schemaV7.getSchema(repositoryConfigurationPackageManagerConfiguration).validate(packageManagerConfiguration)
79+
80+
errors should beEmpty()
81+
}
82+
6383
"The example package curations file validates successfully" {
6484
val curationsSchema = File("../integrations/schemas/curations-schema.json").toURI()
6585
val curationsExample = File("../examples/$ORT_PACKAGE_CURATIONS_FILENAME").toJsonNode()
@@ -116,4 +136,10 @@ private val schemaV7 = JsonSchemaFactory
116136
private val repositoryConfigurationSchema =
117137
File("../integrations/schemas/repository-configuration-schema.json").toURI()
118138

139+
private val repositoryConfigurationAnalyzerConfiguration =
140+
File("../integrations/schemas/repository-configurations/analyzer-configuration-schema.json").toURI()
141+
142+
private val repositoryConfigurationPackageManagerConfiguration =
143+
File("../integrations/schemas/repository-configurations/package-manager-configuration-schema.json").toURI()
144+
119145
private fun File.toJsonNode() = yamlMapper.readTree(inputStream())

0 commit comments

Comments
 (0)