Skip to content

Fix outdated JSON schema output example in README#1887

Merged
lahma merged 2 commits intomasterfrom
copilot/update-jsonschema-documentation
Mar 1, 2026
Merged

Fix outdated JSON schema output example in README#1887
lahma merged 2 commits intomasterfrom
copilot/update-jsonschema-documentation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

The README's example JSON schema output for JsonSchema.FromType<Person>() no longer matched what the library actually generates, making the documentation misleading.

Changes

  • FirstName/LastName: Added "minLength": 1 — now emitted due to [Required] attribute
  • Gender: Removed redundant oneOf wrapper; now emits $ref directly for non-nullable value type references
  • Company/Manufacturer: Fixed oneOf array ordering from [$ref, null][null, $ref]

Both JsonSchema.FromType<Person>() (System.Text.Json) and NewtonsoftJsonSchemaGenerator.FromType<Person>() now produce identical output for this class, matching the updated example.

Original prompt

This section details on the original issue you should resolve

<issue_title>Is this documentation still valid?</issue_title>
<issue_description>The JsonSchema class can be used as follows:

var schema = JsonSchema.FromType<Person>();
var schemaData = schema.ToJson();
var errors = schema.Validate("{...}");

foreach (var error in errors)
    Console.WriteLine(error.Path + ": " + error.Kind);

schema = await JsonSchema.FromJsonAsync(schemaData);
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: lahma <171892+lahma@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for JsonSchema usage Fix outdated JSON schema output example in README Mar 1, 2026
Copilot finished work on behalf of lahma March 1, 2026 20:04
@lahma lahma marked this pull request as ready for review March 1, 2026 20:14
@lahma lahma merged commit 29ff773 into master Mar 1, 2026
@lahma lahma deleted the copilot/update-jsonschema-documentation branch March 1, 2026 20:16
This was referenced Apr 8, 2026
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.

Is this documentation still valid?

2 participants