Skip to content

Test-Json fails to parse schema while other validators succeed #9560

@chriskuech

Description

@chriskuech

Steps to reproduce

good.params.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "0.0.0.1",
  "parameters": {
    "var1": {
      "value": "4"
    },
    "var2": {
      "reference": {
        "keyVault": {
          "id": "<keyvault-resource-id>"
        },
        "secretName": "<secret-name>"
      }
    }
  }
}
$json = Get-Content $PSScriptRoot\good.params.json -Raw
$schemaUri = ($json | ConvertFrom-Json).'$schema' -replace "#.*"
[string]$schema = Invoke-WebRequest $schemaUri
Test-Json -Json $json -Schema $schema

Expected behavior

I have tested the schema and json in two online validators and neither had issues, so I would expect Test-Json to not throw an error.

Actual behavior

Test-Json : Cannot parse the JSON schema.
At /bugrepro.ps1:4 char:1
+ Test-Json -Json $json -Schema $schema
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Test-Json], Exception
+ FullyQualifiedErrorId : InvalidJsonSchema,Microsoft.PowerShell.Commands.TestJsonCommand

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Darwin 18.5.0 Darwin Kernel Version 18.5.…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions