feat: add JsonConverter for OpenApiSchema System.Text.Json serialization#2915
Merged
baywet merged 8 commits intoJul 2, 2026
Merged
Conversation
baywet
reviewed
Jun 29, 2026
baywet
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution!
Let's a couple of comments to help get this merged
baywet
reviewed
Jun 30, 2026
There was a problem hiding this comment.
Pull request overview
This PR introduces first-class System.Text.Json (de)serialization support for OpenApiSchema by adding a dedicated JsonConverter<OpenApiSchema> that emits/consumes OpenAPI wire-format JSON instead of default reflection-based output, addressing the need described in #2299.
Changes:
- Added
OpenApiSchemaJsonConverterwith version-targeted serialization (defaulting to OpenAPI 3.2) and deserialization support. - Added unit tests validating basic serialize/deserialize and version-specific behavior.
- Updated public API baselines to include the new converter; also includes an encoding-only change to
global.json.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Microsoft.OpenApi/Converters/OpenApiSchemaJsonConverter.cs |
New converter implementation for OpenApiSchema using OpenAPI wire-format I/O. |
test/Microsoft.OpenApi.Tests/Converters/OpenApiSchemaJsonConverterTests.cs |
New unit tests covering basic serialization/deserialization scenarios. |
src/Microsoft.OpenApi/PublicAPI.Unshipped.txt |
Declares the newly added public converter API surface. |
global.json |
Introduces a UTF-8 BOM at file start (encoding-only change). |
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
baywet
approved these changes
Jul 2, 2026
baywet
left a comment
Member
There was a problem hiding this comment.
Thank you for making the changes!
peombwa
approved these changes
Jul 2, 2026
Merged
This was referenced Jul 6, 2026
Open
This was referenced Jul 13, 2026
MelfusX
added a commit
to MelfusX/IncidentCompass
that referenced
this pull request
Jul 13, 2026
Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET) from 2.9.0 to 2.10.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.OpenApi's releases](https://github.com/Microsoft/OpenAPI.NET/releases)._ ## 2.10.0 ## [2.10.0](microsoft/OpenAPI.NET@v2.9.0...v2.10.0) (2026-07-03) ### Features * add JsonConverter for OpenApiSchema System.Text.Json serialization ([#2915](microsoft/OpenAPI.NET#2915)) ([465521b](microsoft/OpenAPI.NET@465521b)) * **library:** support schema keywords on references ([2749463](microsoft/OpenAPI.NET@2749463)), closes [#2903](microsoft/OpenAPI.NET#2903) ### Bug Fixes * Don't silently skip null assignment to OpenApiDocument.Tags ([#2917](microsoft/OpenAPI.NET#2917)) ([6a45a82](microsoft/OpenAPI.NET@6a45a82)) * handling of nullable enums for 3.0 ([#2920](microsoft/OpenAPI.NET#2920)) ([f4778e0](microsoft/OpenAPI.NET@f4778e0)) * **library:** keep v3 schema references ref-only ([8d811c3](microsoft/OpenAPI.NET@8d811c3)) * preserve JSON Schema 2020-12 keyword siblings on $ref schemas for OAS 3.1+ ([#2896](microsoft/OpenAPI.NET#2896)) ([fb20d46](microsoft/OpenAPI.NET@fb20d46)) * preserve JSON Schema 2020-12 keyword siblings on $ref schemas for OAS 3.1+ ([#2896](microsoft/OpenAPI.NET#2896)) ([c79a83e](microsoft/OpenAPI.NET@c79a83e)) * use async method for crypto flush ([677b519](microsoft/OpenAPI.NET@677b519)) Commits viewable in [compare view](microsoft/OpenAPI.NET@v2.9.0...v2.10.0). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Igor Lagutin <61908024+MelfusX@users.noreply.github.com>
This was referenced Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
OpenApiSchemaJsonConverter, aSystem.Text.Json.JsonConverter<OpenApiSchema>that produces clean OpenAPI wire format output instead of the default verbose reflection-based serialization.Type of Change
Related Issue(s)
Closes #2299
Changes Made
OpenApiSchemaJsonConverterinsrc/Microsoft.OpenApi/Converters/Read(deserialization) support in addition toWrite(serialization)PublicAPI.Unshipped.txtwith new public API surfaceTesting
Checklist
Versions applicability
Additional Notes
Usage example: