Skip to content

Commit

Permalink
docs(schema): Fix the JSON schema for the repository configuration
Browse files Browse the repository at this point in the history
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 <git@bochtler.io>
  • Loading branch information
MarcelBochtler committed Jan 28, 2025
1 parent 71d4614 commit 889577b
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://oss-review-toolkit.org/repository-configurations/analyzer-configuration.yml",
"title": "ORT repository analyzer configurations",
"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.",
"type": "object",
"additionalProperties": false,
"properties": {
"allow_dynamic_versions": {
"type": "boolean"
},
"enabled_package_managers": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"disabled_package_managers": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"package_managers": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/repository-configurations/package-manager-configuration-schema.json"
},
"skip_excluded": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://oss-review-toolkit.org/repository-configurations/package-manager-configuration.yml",
"title": "ORT repository package manager configuration",
"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.",
"type": "object",
"propertyNames": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
},
"additionalProperties": {
"type": "object",
"$ref": "#/definitions/PackageManagerConfigs"
},
"definitions": {
"PackageManagerConfigs": {
"type": "object",
"additionalProperties": false,
"properties": {
"must_run_after": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"options": {
"additionalProperties": {
"type": [
"boolean",
"number",
"string"
]
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
analyzer:
allow_dynamic_versions: false
enabled_package_managers:
- Gradle
- Maven
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
analyzer:
package_managers:
Gradle:
must_run_after:
- Maven
options:
foo: bar
26 changes: 26 additions & 0 deletions model/src/test/kotlin/JsonSchemaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ class JsonSchemaTest : StringSpec({
}
}

"Analyzer configuration within a repository configuration validates successfully" {
val repositoryConfiguration = File("src/test/assets/analyzer-repository-configuration.ort.yml").toJsonNode()
val analyzerConfiguration = repositoryConfiguration.get("analyzer")

val errors = schemaV7.getSchema(repositoryConfigurationAnalyzerConfiguration).validate(analyzerConfiguration)

errors should beEmpty()
}

"Package manager configuration within a repository configuration validates successfully" {
val repositoryConfiguration =
File("src/test/assets/package-manager-repository-configuration.ort.yml").toJsonNode()
val packageManagerConfiguration = repositoryConfiguration.get("analyzer").get("package_managers")

val errors =
schemaV7.getSchema(repositoryConfigurationPackageManagerConfiguration).validate(packageManagerConfiguration)

errors should beEmpty()
}

"The example package curations file validates successfully" {
val curationsSchema = File("../integrations/schemas/curations-schema.json").toURI()
val curationsExample = File("../examples/$ORT_PACKAGE_CURATIONS_FILENAME").toJsonNode()
Expand Down Expand Up @@ -116,4 +136,10 @@ private val schemaV7 = JsonSchemaFactory
private val repositoryConfigurationSchema =
File("../integrations/schemas/repository-configuration-schema.json").toURI()

private val repositoryConfigurationAnalyzerConfiguration =
File("../integrations/schemas/repository-configurations/analyzer-configuration-schema.json").toURI()

private val repositoryConfigurationPackageManagerConfiguration =
File("../integrations/schemas/repository-configurations/package-manager-configuration-schema.json").toURI()

private fun File.toJsonNode() = yamlMapper.readTree(inputStream())

0 comments on commit 889577b

Please sign in to comment.