Title: OpenApiSchema System.Text.Json (De)Serialization · Issue #2299 · microsoft/OpenAPI.NET · GitHub
Open Graph Title: OpenApiSchema System.Text.Json (De)Serialization · Issue #2299 · microsoft/OpenAPI.NET
X Title: OpenApiSchema System.Text.Json (De)Serialization · Issue #2299 · microsoft/OpenAPI.NET
Description: Is your feature request related to a problem? Please describe. Default System.Text.Json Serialization of OpenApiJsonSchema is verbose (complete) and unsatisfying. Describe the solution you'd like A simple way to fix it, probably via a Js...
Open Graph Description: Is your feature request related to a problem? Please describe. Default System.Text.Json Serialization of OpenApiJsonSchema is verbose (complete) and unsatisfying. Describe the solution you'd like A...
X Description: Is your feature request related to a problem? Please describe. Default System.Text.Json Serialization of OpenApiJsonSchema is verbose (complete) and unsatisfying. Describe the solution you'd li...
Opengraph URL: https://github.com/microsoft/OpenAPI.NET/issues/2299
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OpenApiSchema System.Text.Json (De)Serialization","articleBody":"**Is your feature request related to a problem? Please describe.**\nDefault System.Text.Json Serialization of OpenApiJsonSchema is verbose (complete) and unsatisfying.\n\n**Describe the solution you'd like**\nA simple way to fix it, probably via a JsonConverter, either by default or to configure on AddMVC json options.\n\n**Describe alternatives you've considered**\n\nOtherwise, OpenApiSchema could support direct serialization to a JsonWriter:\n\n**Additional context**\nTurns out I did it in my projects, and I also just really wanted to know if this was appropriate, or I missed something available\n```c#\n\ninternal class SchemaConverter : System.Text.Json.Serialization.JsonConverter\u003cOpenApiSchema\u003e\n{\n\tprivate static readonly ConcurrentDictionary\u003cint, JsonSerializerOptions\u003e _jsonSerializerCache = new();\n\tpublic override OpenApiSchema Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n\t{\n\t\tvar correctedOptions = _jsonSerializerCache.GetOrAdd(options.GetHashCode(), _ =\u003e\n\t\t{\n\t\t\tvar optionsCopy = new JsonSerializerOptions(options);\n\t\t\toptionsCopy.Converters.Remove(options.Converters.First(c =\u003e c is SchemaConverter));\n\t\t\treturn optionsCopy;\n\t\t});\n\n\t\treturn JsonSerializer.Deserialize\u003cOpenApiSchema\u003e(ref reader, correctedOptions)!;\n\t}\n\n\tpublic override void Write(Utf8JsonWriter writer, OpenApiSchema value, JsonSerializerOptions options)\n\t{\n\t\tusing var memoryStream = new MemoryStream();\n\t\tusing (var textWriter = new StreamWriter(memoryStream, leaveOpen: true))\n\t\t{\n\t\t\tvalue.SerializeAsV31(new OpenApiJsonWriter(textWriter));\n\t\t\ttextWriter.Flush();\n\t\t}\n\n\t\tmemoryStream.Position = 0;\n\t\twriter.WriteRawValue(memoryStream.ToArray());\n\t}\n}\n\n\n```","author":{"url":"https://github.com/Poltuu","@type":"Person","name":"Poltuu"},"datePublished":"2025-04-02T09:51:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2299/OpenAPI.NET/issues/2299"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:771fefd5-2997-7875-3d13-25fda074a84b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E97C:5A2ED:324C73:4404A8:69825489 |
| html-safe-nonce | 8f6162e10cb5c58a352363a75abfddd30d1732c85e712e3ba88e52344b17c589 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTdDOjVBMkVEOjMyNEM3Mzo0NDA0QTg6Njk4MjU0ODkiLCJ2aXNpdG9yX2lkIjoiMzcxODA3OTMxMjE4NDg5MDUwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ea87431f658a1b0b547541033d90deaca0ae691ed7dd3314e02915a40dafc3a5 |
| hovercard-subject-tag | issue:2965851902 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/OpenAPI.NET/2299/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ec775845cc9a6325bca321ff455c76f001309df34d31ca123498c66991179491/microsoft/OpenAPI.NET/issues/2299 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ec775845cc9a6325bca321ff455c76f001309df34d31ca123498c66991179491/microsoft/OpenAPI.NET/issues/2299 |
| og:image:alt | Is your feature request related to a problem? Please describe. Default System.Text.Json Serialization of OpenApiJsonSchema is verbose (complete) and unsatisfying. Describe the solution you'd like A... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Poltuu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5a7140cc648b2cdbea97926248d63eb74cfc2f06ec2c0582e23ad07913b6c9fe |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/OpenAPI.NET git https://github.com/microsoft/OpenAPI.NET.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 97175798 |
| octolytics-dimension-repository_nwo | microsoft/OpenAPI.NET |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 97175798 |
| octolytics-dimension-repository_network_root_nwo | microsoft/OpenAPI.NET |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | eae0a2862c46988d0b368534d563f8e044fa42ea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width