- 
                Notifications
    You must be signed in to change notification settings 
- Fork 54
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
In PR #311 support for definitions of resources in YAML was added. However, this does not appear to be working as expected for the schema portion of the definition.
Using a working json schema for a resource (see below), I run y2j to convert it to yaml (also seen below), but the resource is not discovered when dsc resource list is executed. If I remove the schema:  section at the end of the yaml file (as this example suggests is not necessary) the resource is discovered but does not execute as the schema is missing from the resource. As I am using the yaml language server validation, any modification to the schema section to support a YAML tag does not appear valid.
working Json resource definition
{
  "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.json",
  "type": "joshcorr/test",
  "version": "0.1.0",
  "description": "Synopsis for the resource's purpose",
  "get": {
    "executable": "powershell",
    "args": [
      "-NoLogo",
      "-NonInteractive",
      "-NoProfile",
      "-Command",
      "$value = ($Input | ConvertFrom-Json).text;",
      "@{\"text\"=\"$value\"} | Convertto-json -Compress"
    ],
    "input": "stdin"
  },
  "set": {
    "executable": "powershell",
    "args": [
      "-NoLogo",
      "-NonInteractive",
      "-NoProfile",
      "-Command",
      "$value = ($Input | ConvertFrom-Json).text;",
      "@{\"text\"=\"$value set\"} | Convertto-json -Compress"
    ],
    "input": "stdin",
    "implementsPretest": false,
    "return": "state"
  },
  "schema": {
    "embedded": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "name": {
          "title": "text",
          "description": "Defines the text you want to output",
          "type": "string"
        }
      }
    }
  }
}non discoverable yaml resource definition
# yaml-language-server: $schema=https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.vscode.json
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.json
type: joshcorr/test
version: 0.1.0
description: Synopsis for the resource's purpose
get:
  executable: powershell
  args:
  - -NoLogo
  - -NonInteractive
  - -NoProfile
  - -Command
  - $value = ($Input | ConvertFrom-Json).text;
  - '@{"text"="$value"} | Convertto-json -Compress'
  input: stdin
set:
  executable: powershell
  args:
  - -NoLogo
  - -NonInteractive
  - -NoProfile
  - -Command
  - $value = ($Input | ConvertFrom-Json).text;
  - '@{"text"="$value set"} | Convertto-json -Compress'
  input: stdin
  implementsPretest: false
  return: state
schema:
  embedded:
    $schema: http://json-schema.org/draft-07/schema#
    type: object
    properties:
      name:
        title: text
        description: Defines the text you want to output
        type: string
discoverable but non-working yaml resource definition
# yaml-language-server: $schema=https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.vscode.json
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.json
type: joshcorr/test
version: 0.1.0
description: Synopsis for the resource's purpose
get:
  executable: powershell
  args:
  - -NoLogo
  - -NonInteractive
  - -NoProfile
  - -Command
  - $value = ($Input | ConvertFrom-Json).text;
  - '@{"text"="$value"} | Convertto-json -Compress'
  input: stdin
set:
  executable: powershell
  args:
  - -NoLogo
  - -NonInteractive
  - -NoProfile
  - -Command
  - $value = ($Input | ConvertFrom-Json).text;
  - '@{"text"="$value set"} | Convertto-json -Compress'
  input: stdin
  implementsPretest: false
  return: stateExpected behavior
dsc resource list joshcorr/test
Type           Version  Methods   Requires  Description
-------------------------------------------------------------------------------
joshcorr/test  0.1.0    get, set            Synopsis for the resource's purposewhen executing the resource (that may be discovered)
(@{"text" = "something2" }  | ConvertTo-Json) | dsc resource set -r joshcorr/test
beforeState:
  text: something2
afterState:
  text: something2 set
changedProperties:
- textActual behavior
dsc resource list joshcorr/test
2024-03-17T21:56:25.513921Z  WARN dsc_lib::discovery::command_discovery: 64: Manifest: C:\Users\User\.dsc\resources\test.dsc.resource.yaml
YAML: schema: invalid type: map, expected a YAML tag starting with '!' at line 28 column 3
Type  Version  Methods  Requires  Description
---------------------------------------------when executing the resource (that may be discovered)
(@{"text" = "something2" }  | ConvertTo-Json) | dsc resource set -r joshcorr/test
2024-03-17T22:08:17.123920Z ERROR dsc::resource_command: 139: Error: Validation: Schema not availableError details
No response
Environment data
Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0Version
dsc 3.0.0-alpha.5
Visuals
No response