Skip to content

Add synchronous JsonSchema.FromJson methods#1912

Open
lahma wants to merge 1 commit intoRicoSuter:masterfrom
lahma:feature/sync-fromjson-1727
Open

Add synchronous JsonSchema.FromJson methods#1912
lahma wants to merge 1 commit intoRicoSuter:masterfrom
lahma:feature/sync-fromjson-1727

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 8, 2026

Summary

  • Add synchronous JsonSchema.FromJson() overloads as alternatives to FromJsonAsync() for schemas that don't require external file or URL reference resolution
  • Internal document references (#/definitions/...) are resolved synchronously
  • External file/URL references throw NotSupportedException with a message directing users to use FromJsonAsync instead
  • Adds sync UpdateSchemaReferences in JsonSchemaReferenceUtilities and sync ResolveReference in JsonReferenceResolver

Fixes #1727

New API

JsonSchema.FromJson(string data)
JsonSchema.FromJson(string data, string? documentPath)
JsonSchema.FromJson(string data, string? documentPath, 
    Func<JsonSchema, JsonReferenceResolver> referenceResolverFactory)

Test plan

  • Basic schema parsing works synchronously
  • Internal $ref references (#/definitions/...) resolve correctly
  • Sync FromJson produces identical results to FromJsonAsync for self-contained schemas
  • All existing tests continue to pass

🤖 Generated with Claude Code

Provide synchronous alternatives to FromJsonAsync for schemas that
don't require external file or URL reference resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

JsonSchema.FromJsonAsync as synchronous method

1 participant