Skip to content

(SCHEMAS) Fix/update for v3.0.0 release #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions schemas/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using namespace System.Collections
<#
.SYNOPSIS
Build the DSC schema files from the source YAML files.

.DESCRIPTION
This build script composes the JSON Schema files from the source YAML files, creating new
files in the specified output directory. It creates a schema registry to analyze the source
Expand All @@ -15,11 +15,11 @@ using namespace System.Collections
param(
[string]
$OutputDirectory = "$PSScriptRoot",

[Parameter(ParameterSetName='ByPath')]
[string[]]
$ConfigFilePath,

[string[]]
[ValidateSet('Json', 'JsonVSCode', 'Yaml', 'YamlVSCode')]
$OutputFormat = @(
Expand All @@ -40,7 +40,7 @@ begin {

[Specialized.OrderedDictionary]
$Map

[Generic.List[Specialized.OrderedDictionary]]
$List

Expand Down Expand Up @@ -102,7 +102,7 @@ begin {
# Need to ensure single-item returns get correctly handled as arays,
# not munged into scalars.
if (
($MungedKeyValue.Count -eq 1) -or
($MungedKeyValue.Count -eq 1) -or
($MungedKeyValue -is [Specialized.OrderedDictionary])
) {
$MungedSchema.Add($_.Key, [object[]]$MungedKeyValue)
Expand Down Expand Up @@ -308,18 +308,18 @@ begin {
[Parameter(ParameterSetName='FromPath', Mandatory)]
[string]
$Path,

[Parameter(ParameterSetName='FromSchema', Mandatory)]
[Specialized.OrderedDictionary]
$Schema,

[Parameter(ParameterSetName='FromPreset', Mandatory)]
[ValidateSet('ConfigDocument', 'ResourceManifest')]
[string]
$Preset,

[LocalJsonSchemaRegistry] $SchemaRegistry,

[switch]$ForVSCode,
[switch]$WithoutComments,
[switch]$WithoutExamples
Expand Down Expand Up @@ -379,9 +379,14 @@ begin {
continue
}

if ($ID -match "$Reference`$") {
Write-Verbose "$ID`n`tSkipping adding self ($Reference) to `$defs"
continue
}

$ReferenceSegments = $Reference.Trim('/') -split '/'
$Working = $MergedSchema.'$defs'

for ($i = 0; $i -lt $ReferenceSegments.Count; $i++) {
$Segment = $ReferenceSegments[$i]

Expand All @@ -390,7 +395,7 @@ begin {
$Working = $Working.$Segment
continue
}

# Add an empty dictionary for non-final segments
if ($i -ne ($ReferenceSegments.Count - 1)) {
$Working.Add($Segment, [Specialized.OrderedDictionary]::new())
Expand Down Expand Up @@ -446,6 +451,11 @@ begin {
continue
}

if ($ID -match "$Reference`$") {
Write-Verbose "$ID`n`tSkipping adding self ($Reference) to `$defs"
continue
}

if ($Reference -notin $Schema.'$defs'.Keys) {
Write-Verbose "$ID`n`tAdding reference to `$defs: '$Reference'"
$MergedSchema.'$defs'.Add($ReferenceSchema.'$id', $ReferenceSchema)
Expand Down Expand Up @@ -524,7 +534,7 @@ begin {

[string]
$OutputDirectory = $PWD,

[string[]]
[ValidateSet('Json', 'JsonVSCode', 'Yaml', 'YamlVSCode')]
$OutputFormat = @(
Expand Down Expand Up @@ -567,7 +577,7 @@ begin {
Path = $ConfigFilePath
SchemaRegistry = $SchemaRegistry
}

if ($MergeForNormal) {
$Bundled = Merge-JsonSchema @SharedMergeParams
| Set-BundledSchemaID -BundledName $Name
Expand Down Expand Up @@ -716,7 +726,7 @@ process {
foreach ($VSCodeKeyword in $VSCodeKeywords) {
$SchemaData = Remove-JsonSchemaKey -Schema $SchemaData -KeyName $VSCodeKeyword
}

$SchemaData
| ConvertTo-Json -Depth 99
| ForEach-Object { $_ -replace '\r\n', "`n" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# For testing outside of the repository, set the schema in the yaml server directive to:
# https://raw.githubusercontent.com/PowerShell/DSC/main/2024/04/resource/manifest.json
# https://raw.githubusercontent.com/PowerShell/DSC/main/v3/resource/manifest.json
#
# Hover on the keys to see the documentation. Try changing values and adding new settings.
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json
# Try adding the variables, metadata, and parameters properties,
# then use IntelliSense to define a few entries.

Expand Down
25 changes: 13 additions & 12 deletions schemas/examples/output/config.get.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# yaml-language-server: $schema=../../2024/04/bundled/outputs/config/get.vscode.json
# yaml-language-server: $schema=../../v3.0/bundled/outputs/config/get.vscode.json
#
# Shows output from `dsc config get --path dsc/examples/osinfo_registry.dsc.yaml
#
metadata:
Microsoft.DSC:
version: 3.0.0-preview.7
operation: Get
executionType: Actual
startDatetime: 2024-04-16T15:29:19.776934500-05:00
endDatetime: 2024-04-16T15:29:20.052168700-05:00
duration: PT0.275234200S
securityContext: Restricted
version: 3.0.0
operation: get
executionType: actual
startDatetime: 2025-05-09T11:57:24.223992200-05:00
endDatetime: 2025-05-09T11:57:25.237202300-05:00
duration: PT1.0132101S
securityContext: restricted
results:
- metadata:
Microsoft.DSC:
duration: PT0.053120900S
duration: PT0.0391229S
name: os
type: Microsoft/OSInfo
result:
actualState:
$id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json
family: Windows
version: 10.0.22631
version: 10.0.26100
edition: Windows 11 Enterprise
bitness: '64'
architecture: x86_64
- metadata:
Microsoft.DSC:
duration: PT0.137957200S
duration: PT0.1583279S
name: windows product name
type: Microsoft.Windows/Registry
result:
Expand All @@ -37,7 +38,7 @@ results:
String: Windows 10 Enterprise
- metadata:
Microsoft.DSC:
duration: PT0.035664200S
duration: PT0.049571S
name: system root
type: Microsoft.Windows/Registry
result:
Expand Down
25 changes: 13 additions & 12 deletions schemas/examples/output/config.test.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
# yaml-language-server: $schema=../../2024/04/bundled/outputs/config/get.vscode.json
# yaml-language-server: $schema=../../v3.0/bundled/outputs/config/test.vscode.json
#
# Shows output from `dsc config get --path dsc/examples/osinfo_registry.dsc.yaml
#
metadata:
Microsoft.DSC:
version: 3.0.0-preview.7
operation: Test
executionType: Actual
startDatetime: 2024-04-16T15:31:15.556395700-05:00
endDatetime: 2024-04-16T15:31:15.820044900-05:00
duration: PT0.263649200S
securityContext: Restricted
version: 3.0.0
operation: test
executionType: actual
startDatetime: 2025-05-09T11:57:46.868555-05:00
endDatetime: 2025-05-09T11:57:47.837039900-05:00
duration: PT0.9684849S
securityContext: restricted
results:
- metadata:
Microsoft.DSC:
duration: PT0.061508200S
duration: PT0.0402149S
name: os
type: Microsoft/OSInfo
result:
desiredState: {}
actualState:
$id: https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json
family: Windows
version: 10.0.22631
version: 10.0.26100
edition: Windows 11 Enterprise
bitness: '64'
architecture: x86_64
inDesiredState: true
differingProperties: []
- metadata:
Microsoft.DSC:
duration: PT0.142056900S
duration: PT0.1675133S
name: windows product name
type: Microsoft.Windows/Registry
result:
Expand All @@ -45,7 +46,7 @@ results:
differingProperties: []
- metadata:
Microsoft.DSC:
duration: PT0.033704600S
duration: PT0.0618466S
name: system root
type: Microsoft.Windows/Registry
result:
Expand Down
2 changes: 1 addition & 1 deletion schemas/examples/resource_manifest/foo.dsc.resource.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "../2024/04/bundled/resource/manifest.vscode.json",
"$schema": "../../v3.0/bundled/resource/manifest.vscode.json",
"type": "Example/Resource",
"description": "An example resource using the schema.",
"version": "0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions schemas/examples/resource_manifest/foo.dsc.resource.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# For testing outside of the repository, set the schema in the yaml server directive to:
# https://raw.githubusercontent.com/PowerShell/DSC/main/2024/04/resource/manifest.json
# https://raw.githubusercontent.com/PowerShell/DSC/main/v3/resource/manifest.json
#
# Hover on the keys to see the documentation. Try changing values and adding new settings.
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.vscode.json
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/resource/manifest.vscode.json
type: Example/Foo
version: 0.1.0
description: An example resource to manage the foo application.
Expand Down
4 changes: 2 additions & 2 deletions schemas/src/config/document.parameter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
$schema: https://json-schema.org/draft/2020-12/schema
$id: <HOST>/<PREFIX>/<VERSION>/config/document.parameter.yaml
title: Parameter
description: Defines a runtime option for a DSC Configuration Document.
description: Defines a runtime option for a DSC configuration document.

markdownDescription: | # VS Code only
***
[_Online Documentation_][01]
***

Defines a runtime option for a DSC Configuration Document.
Defines a runtime option for a DSC configuration document.

[01]: <DOCS_BASE_URL>/reference/schemas/config/parameter?<DOCS_VERSION_PIN>

Expand Down
24 changes: 12 additions & 12 deletions schemas/src/config/document.resource.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# yaml-language-server: $schema=https://json-schema.org/draft/2020-12/schema
$schema: https://json-schema.org/draft/2020-12/schema
$id: <HOST>/<PREFIX>/<VERSION>/config/document.resource.yaml
title: DSC Resource instance
description: Defines an instance of a DSC Resource in a configuration.
title: DSC resource instance
description: Defines an instance of a DSC resource in a configuration.

type: object
required:
Expand All @@ -16,7 +16,7 @@ properties:
dependsOn:
title: Instance depends on
description: >-
Defines a list of DSC Resource instances that DSC must successfully process before processing
Defines a list of DSC resource instances that DSC must successfully process before processing
this instance. Each value for this property must be the `resourceID()` lookup for another
instance in the configuration. Multiple instances can depend on the same instance, but every
dependency for an instance must be unique in that instance's `dependsOn` property.
Expand Down Expand Up @@ -47,7 +47,7 @@ properties:
[_Online Documentation_][01]
***

Defines a list of DSC Resource instances that DSC must successfully process before processing
Defines a list of DSC resource instances that DSC must successfully process before processing
this instance. Each value for this property must be the `resourceID()` lookup for another
instance in the configuration. Multiple instances can depend on the same instance, but every
dependency for an instance must be unique in that instance's `dependsOn` property.
Expand All @@ -67,17 +67,17 @@ properties:
properties:
title: Managed instance properties
description: >-
Defines the properties of the DSC Resource this instance manages. This property's value must
be an object. DSC validates the property's value against the DSC Resource's schema.
Defines the properties of the DSC resource this instance manages. This property's value must
be an object. DSC validates the property's value against the DSC resource's schema.
type: object
# VS Code only
markdownDescription: |
***
[_Online Documentation_][01]
***

Defines the properties of the DSC Resource this instance manages. This property's value must
be an object. DSC validates the property's value against the DSC Resource's schema.
Defines the properties of the DSC resource this instance manages. This property's value must
be an object. DSC validates the property's value against the DSC resource's schema.

[01]: <DOCS_BASE_URL>/reference/schemas/config/resource?<DOCS_VERSION_PIN>#properties-1

Expand All @@ -87,9 +87,9 @@ markdownDescription: |
[_Online Documentation_][01]
***

Defines an instance of a DSC Resource in a configuration.
Defines an instance of a DSC resource in a configuration.

The `resources` property of a DSC Configuration document always includes at least one DSC Resource
The `resources` property of a DSC configuration document always includes at least one DSC resource
instance. Together, the instances in a configuration define the desired state that DSC can get,
test, and set on a machine.

Expand All @@ -98,7 +98,7 @@ markdownDescription: |
defaultSnippets:
- label: ' New resource instance'
markdownDescription: |-
Defines a new instance of a DSC Resource for the configuration.
Defines a new instance of a DSC resource for the configuration.

```yaml
type: owner[.group][.area]/name
Expand All @@ -114,7 +114,7 @@ defaultSnippets:

- label: ' New dependent resource instance'
markdownDescription: |-
Defines a new instance of a DSC Resource for the configuration that depends on another
Defines a new instance of a DSC resource for the configuration that depends on another
instance.

```yaml
Expand Down
Loading
Loading