Skip to content

Conversation

@melotic
Copy link
Member

@melotic melotic commented Jun 22, 2023

Adds a JSON Schema for the Manifest format. Generated with JSON.NET Schema

using Microsoft.ComponentDetection.Contracts.BcdeModels;
using Newtonsoft.Json.Schema.Generation;

var generator = new JSchemaGenerator();
var schema = generator.Generate(typeof(ScanResult));

// Add meta schema
schema.ExtensionData.Add("$schema", "http://json-schema.org/draft-07/schema#");

Console.WriteLine(schema.ToString());

Part of #570

@melotic melotic requested a review from a team as a code owner June 22, 2023 16:30
@melotic melotic requested a review from RushabhBhansali June 22, 2023 16:30
@JamieMagee
Copy link
Member

Do you intend this to be manually or automatically maintained? Cause that will affect how I review this.

@melotic
Copy link
Member Author

melotic commented Jun 22, 2023

Do you intend this to be manually or automatically maintained? Cause that will affect how I review this.

I think as part of CI we should run that small C# program and diff the output. If the JSON schema changed, fail the build? Sort of like how ADO fails if the generated SQL stuff isn't part of the commit.

@melotic
Copy link
Member Author

melotic commented Jun 22, 2023

Should I include the script and CI to check that the schema is properly updated? I'll follow up with a PR to update our validation tests to also ensure the schema is followed.

@JamieMagee
Copy link
Member

Should I include the script and CI to check that the schema is properly updated? I'll follow up with a PR to update our validation tests to also ensure the schema is followed.

I'll approve this now, and feel free to followup in another PR, or open an issue in our backlog.

@melotic melotic merged commit 61a0d35 into main Jul 5, 2023
@melotic melotic deleted the justinperez/manifest-json-schema branch July 5, 2023 17:50
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