Skip to content

Commit

Permalink
(MAINT) Fix schema gen for array values
Browse files Browse the repository at this point in the history
Prior to this change, the schema generation had a bug that incorrectly
munged the values for always-array keywords, like `enum` and `requires`
to scalar values when the definition was a single-item array.

This change ensures that those values are not incorrectly munged, fixing
hidden bugs in the behavior for those values in the generated schemas.
  • Loading branch information
michaeltlombardi committed Sep 27, 2023
1 parent 455e660 commit 9150f03
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 173 deletions.
8 changes: 6 additions & 2 deletions schemas/2023/08/bundled/config/document.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"description": "This property must be the canonical URL of the DSC Configuration Document schema that the document is implemented for.",
"type": "string",
"format": "uri",
"enum": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json"
"enum": [
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json"
]
},
"parameters": {
"title": "DSC Configuration document parameters",
Expand Down Expand Up @@ -51,7 +53,9 @@
"title": "Parameter",
"description": "Defines a runtime option for a DSC Configuration Document.",
"type": "object",
"required": "type",
"required": [
"type"
],
"properties": {
"type": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/parameters/dataTypes.json"
Expand Down
4 changes: 3 additions & 1 deletion schemas/2023/08/bundled/outputs/resource/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"title": "dsc resource get result",
"description": "Describes the return data for a DSC Resource instance from the `dsc resource get` command.",
"type": "object",
"required": "actualState",
"required": [
"actualState"
],
"properties": {
"actualState": {
"title": "Actual state",
Expand Down
144 changes: 88 additions & 56 deletions schemas/2023/08/bundled/outputs/resource/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@
"title": "Standard implementation",
"description": "Indicates that the DSC Resource is implemented as one of the standard implementations built into DSC.",
"type": "string",
"enum": "Command"
"enum": [
"Command"
]
},
{
"title": "Custom implementation",
"description": "Indicates that the DSC Resource uses a custom implementation.",
"type": "object",
"required": "custom",
"required": [
"custom"
],
"properties": {
"custom": {
"title": "Custom implementation name",
Expand Down Expand Up @@ -119,7 +123,9 @@
"title": "Manifest Version",
"description": "The semver of the DSC Resource manifest schema to validate this manifest with.",
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/semver.json",
"enum": "1.0"
"enum": [
"1.0"
]
},
"type": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/resourceType.json"
Expand Down Expand Up @@ -179,13 +185,15 @@
"0": "Success",
"1": "Error"
},
"examples": {
"0": "Success",
"1": "Invalid parameter",
"2": "Invalid input",
"3": "Registry error",
"4": "JSON serialization failed"
}
"examples": [
{
"0": "Success",
"1": "Invalid parameter",
"2": "Invalid input",
"3": "Registry error",
"4": "JSON serialization failed"
}
]
},
"schema": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/resource/manifest.schema.json"
Expand All @@ -198,7 +206,9 @@
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of an instance.",
"type": "object",
"required": "executable",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandExecutable.json"
Expand Down Expand Up @@ -230,7 +240,9 @@
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of every instance.",
"type": "object",
"required": "executable",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandExecutable.json"
Expand Down Expand Up @@ -271,16 +283,18 @@
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/returnKind.json"
}
},
"examples": {
"executable": "registry",
"args": [
"config",
"set"
],
"input": "stdin",
"implementsPretest": true,
"return": "state"
}
"examples": [
{
"executable": "registry",
"args": [
"config",
"set"
],
"input": "stdin",
"implementsPretest": true,
"return": "state"
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/resource/manifest.test.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
Expand Down Expand Up @@ -308,23 +322,27 @@
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/returnKind.json"
}
},
"examples": {
"executable": "registry",
"args": [
"config",
"test"
],
"input": "stdin",
"return": "state"
}
"examples": [
{
"executable": "registry",
"args": [
"config",
"test"
],
"input": "stdin",
"return": "state"
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/resource/manifest.validate.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/resource/manifest.validate.json",
"title": "Validate Method",
"description": "Defines how DSC must call the DSC Resource to validate the state of an instance. This method is mandatory for DSC Group Resources. It's ignored for all other DSC Resources.",
"type": "object",
"required": "executable",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandExecutable.json"
Expand All @@ -333,13 +351,15 @@
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandArgs.json"
}
},
"examples": {
"executable": "dsc",
"args": [
"config",
"validate"
]
}
"examples": [
{
"executable": "dsc",
"args": [
"config",
"validate"
]
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/resource/manifest.provider.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
Expand All @@ -356,7 +376,9 @@
"title": "List Command",
"description": "Defines how DSC must call the DSC Resource Provider to list its supported DSC Resources.",
"type": "object",
"required": "executable",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandExecutable.json"
Expand All @@ -376,19 +398,21 @@
]
}
},
"examples": {
"config": "full",
"list": {
"executable": "pwsh",
"args": [
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"./powershellgroup.resource.ps1 List"
]
"examples": [
{
"config": "full",
"list": {
"executable": "pwsh",
"args": [
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"./powershellgroup.resource.ps1 List"
]
}
}
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/resource/manifest.schema.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
Expand All @@ -398,18 +422,24 @@
"type": "object",
"oneOf": [
{
"required": "command"
"required": [
"command"
]
},
{
"required": "embedded"
"required": [
"embedded"
]
}
],
"properties": {
"command": {
"title": "Instance Schema Command",
"description": "Defines how DSC must call the DSC Resource to get the JSON Schema for validating a JSON blob representing an instance of the DSC Resource.",
"type": "object",
"required": "executable",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2023/08/definitions/commandExecutable.json"
Expand Down Expand Up @@ -514,7 +544,9 @@
{
"command": {
"executable": "registry",
"args": "schema"
"args": [
"schema"
]
}
},
{
Expand Down
Loading

0 comments on commit 9150f03

Please sign in to comment.