Produce deprecated property in JsonSchema for obsolete types#130665
Open
Youssef1313 wants to merge 4 commits into
Open
Produce deprecated property in JsonSchema for obsolete types#130665Youssef1313 wants to merge 4 commits into
Youssef1313 wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the System.Text.Json JSON Schema exporter to emit the JSON Schema deprecated keyword when exporting schemas for [Obsolete] .NET types, and adds a regression test covering the new behavior.
Changes:
- Detect
[Obsolete]on exported types and setdeprecated: truein the generated schema. - Add
Deprecatedsupport to the internalJsonSchemamodel and include it in JSON output. - Add a unit test validating
deprecatedis emitted for an obsolete type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/libraries/System.Text.Json/tests/Common/JsonSchemaExporterTests.cs | Adds a test case validating deprecated is produced for an [Obsolete] type. |
| src/libraries/System.Text.Json/src/System/Text/Json/Schema/JsonSchemaExporter.cs | Marks exported schemas as deprecated when the associated .NET type has [Obsolete]. |
| src/libraries/System.Text.Json/src/System/Text/Json/Schema/JsonSchema.cs | Adds a Deprecated keyword to the schema model, counts it, and emits it during JSON serialization. |
2e895bf to
a5d6c2d
Compare
a5d6c2d to
0460d8b
Compare
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-json |
0460d8b to
76a2de7
Compare
This was referenced Jul 14, 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.
Spec: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-9.3