Skip to content

Update cgmanifest to align with the JSON schema - #516

Merged
jeffhandley merged 1 commit into
dotnet:dotnet/mainfrom
jeffhandley:jeffhandley/cgmanifest
Nov 1, 2024
Merged

Update cgmanifest to align with the JSON schema#516
jeffhandley merged 1 commit into
dotnet:dotnet/mainfrom
jeffhandley:jeffhandley/cgmanifest

Conversation

@jeffhandley

Copy link
Copy Markdown
Member

With dotnet/machinelearning#7283, we realized that the cgmanifest.json file was not aligned with the JSON schema. It is using Title case property names but it should be using camelCase property names. See this comment for more detail: dotnet/machinelearning#7283 (comment)

I'm following up by updating each CG manifest in the dotnet org where we had the same issue.

Here's the console app I used to confirm the existing manifest isn't valid against its schema, and the updated one in this PR is valid:

using System;
using System.Net.Http;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Json.Schema; // Requires package JsonSchema.Net

HttpClient httpClient = new();

string schemaUrl = "https://json.schemastore.org/component-detection-manifest.json";
HttpResponseMessage schemaResponse = await httpClient.GetAsync(schemaUrl);
schemaResponse.EnsureSuccessStatusCode();
string schemaJson = (await schemaResponse.Content.ReadAsStringAsync()).Replace("/draft-04/", "/draft-06/");
JsonSchema schema = JsonSchema.FromText(schemaJson);

string[] manifestUrls = [
    "https://raw.githubusercontent.com/dotnet/icu/refs/heads/dotnet/main/cgmanifest.json",
    "https://raw.githubusercontent.com/jeffhandley/dotnet-icu/refs/heads/jeffhandley/cgmanifest/cgmanifest.json"
];

foreach (var manifestUrl in manifestUrls)
{
    HttpResponseMessage manifestResponse = await httpClient.GetAsync(manifestUrl);
    manifestResponse.EnsureSuccessStatusCode();
    string manifestJson = await manifestResponse.Content.ReadAsStringAsync();

    JsonNode manifest = JsonNode.Parse(manifestJson);

    var result = schema.Evaluate(manifest);
    Console.WriteLine(manifestUrl);
    Console.WriteLine($"Valid: {result.IsValid}");
    Console.WriteLine();
}

Here's the output:

https://raw.githubusercontent.com/dotnet/icu/refs/heads/dotnet/main/cgmanifest.json
Valid: False

https://raw.githubusercontent.com/jeffhandley/dotnet-icu/refs/heads/jeffhandley/cgmanifest/cgmanifest.json
Valid: True

@jeffhandley
jeffhandley requested a review from tarekgh November 1, 2024 18:28
@jeffhandley
jeffhandley merged commit 18e47a2 into dotnet:dotnet/main Nov 1, 2024
@jeffhandley
jeffhandley deleted the jeffhandley/cgmanifest branch November 1, 2024 19:42
@akoeplinger

Copy link
Copy Markdown
Member

Thank you!

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

Successfully merging this pull request may close these issues.

3 participants