Skip to content
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

DTL Artifact JSON Schema for draft-06 ?? #888

Open
mmcdermo2 opened this issue Mar 28, 2024 · 0 comments
Open

DTL Artifact JSON Schema for draft-06 ?? #888

mmcdermo2 opened this issue Mar 28, 2024 · 0 comments

Comments

@mmcdermo2
Copy link

  • The current schema for Artifacts (https://raw.githubusercontent.com/Azure/azure-devtestlab/master/schemas/2016-11-28/dtlArtifacts.json) is based on JSON schema draft-04.
  • Since PowerShell 7.4, it seems that the Test-Json function cannot validate schemas based on draft-04
  • Within our DTL private repo, we have a set of tests for validating the artifact.json files on each Pull Request. One such test uses Test-Json to validate that the artifact.json file matches the schema to ensure that we don't commit any bad artifact files to the main branch
  • However, now that we are on PowerShell 7.4, this particular test is failing, because PowerShell can't seem to validate draft-04.
  • Is anybody aware if there is a newer dtlArtifacts schema based on draft-06 that we can use instead ? Or if there's any plans to update the current 2016-11-28 schema to draft-06 ?
  • Below is some code to demonstrate the issue
$ArtifactFile = "https://raw.githubusercontent.com/Azure/azure-devtestlab/master/Artifacts/windows-fiddler/Artifactfile.json"
$JsonContent = Invoke-WebRequest -Uri $ArtifactFile -Authentication None -Method Get | Select-Object -ExpandProperty Content
$JsonObject = ConvertFrom-Json -InputObject $JsonContent

$SchemaURL = $JsonObject | Select-Object -ExpandProperty `$schema
$SchemaContent = Invoke-WebRequest -Uri $SchemaURL -Authentication None -Method Get | Select-Object -ExpandProperty Content

# the below produces error "Test-Json: Cannot parse the JSON schema."
Test-Json -Json $JsonContent -Schema $SchemaContent	

# after doing a fine/replace on the schema to switch to draft-06, the validation works fine
$SchemaContent = $SchemaContent.Replace("draft-04", "draft-06")
Test-Json -Json $JsonContent -Schema $SchemaContent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant