[release/11.0-preview7]: Map [Obsolete] to deprecated in OpenAPI - #67953
Merged
wtgodbe merged 1 commit intoJul 22, 2026
Merged
Conversation
… documents Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Youssef1313
July 22, 2026 07:19
View session
Youssef1313
approved these changes
Jul 22, 2026
Youssef1313
approved these changes
Jul 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Backports OpenAPI deprecation support to release/11.0-preview7 by mapping [Obsolete] metadata onto deprecated: true across generated OpenAPI operations and schemas, including proper handling of $ref-based schemas via reference annotations.
Changes:
- Set
OpenApiOperation.Deprecatedwhen an endpoint hasObsoleteAttributemetadata. - Emit
deprecated: truefor component schemas and inline property schemas when the corresponding type/property is[Obsolete], and flow deprecated state onto schema references via a newx-ref-deprecatedmetadata annotation. - Add/extend unit + integration snapshot coverage, and introduce a sample “obsolete” document + endpoints used by snapshot tests.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Marks operations as deprecated when ObsoleteAttribute is present in endpoint metadata. |
| src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs | Maps [Obsolete] on types/properties to schema deprecated state (inline + componentized/reference scenarios). |
| src/OpenApi/src/Services/OpenApiConstants.cs | Adds RefDeprecatedAnnotation constant (x-ref-deprecated). |
| src/OpenApi/src/Schemas/OpenApiSchemaKeywords.cs | Adds DeprecatedKeyword constant (deprecated). |
| src/OpenApi/src/Schemas/OpenApiJsonSchema.Helpers.cs | Enables JSON parsing of deprecated and x-ref-deprecated into schema model fields/metadata. |
| src/OpenApi/src/Extensions/OpenApiDocumentExtensions.cs | Promotes x-ref-deprecated metadata onto OpenApiSchemaReference.Deprecated. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentService/OpenApiDocumentServiceTests.Operations.cs | Adds tests validating operation deprecated mapping from attribute/metadata and MVC actions. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.Annotations.cs | Adds tests for deprecated mapping on obsolete types and both inline/reference properties. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/OpenApiDocumentIntegrationTests.cs | Adds “obsolete” document to the integration test matrix. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentLocalizationTests.VerifyOpenApiDocumentIsInvariant.verified.txt | Updates localization snapshot to include new obsolete endpoints/schemas output. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_0/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=obsolete.verified.txt | Adds OpenAPI 3.0 snapshot for “obsolete” document (no sibling deprecated on $ref property). |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_1/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=obsolete.verified.txt | Adds OpenAPI 3.1 snapshot for “obsolete” document. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_2/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=obsolete.verified.txt | Adds OpenAPI 3.2 snapshot for “obsolete” document. |
| src/OpenApi/sample/Program.cs | Registers the new “obsolete” OpenAPI document and maps corresponding endpoints in the sample app. |
| src/OpenApi/sample/Endpoints/MapObsoleteEndpoints.cs | Adds sample endpoints and DTOs annotated with [Obsolete] to drive integration snapshots. |
wtgodbe
approved these changes
Jul 22, 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.
Manual backport of #66355 to
release/11.0-preview7.Maps
[Obsolete]attributes todeprecated: truein generated OpenAPI documents for operations, component schemas, and schema properties.Description
[Obsolete]on handler method or via.WithMetadata(new ObsoleteAttribute())emitdeprecated: true[Obsolete]producedeprecated: trueon the component schema[Obsolete]on a primitive/non-componentized property setsdeprecated: truedirectly on the property schema[Obsolete]on a componentized property setsdeprecated: trueon theOpenApiSchemaReferenceviax-ref-deprecatedannotation (underlying component schema unchanged)$refare not allowed by the spec, so reference properties do not carrydeprecatedin 3.0 outputNew constants:
DeprecatedKeyword,RefDeprecatedAnnotation. No opt-out mechanism; users can suppress via transformer if needed.Customer Impact
Users with
[Obsolete]-annotated types, properties, or endpoints will now seedeprecated: truein generated OpenAPI output automatically, without needing custom transformers. Behavioral change: existing documents will gain newdeprecatedfields after upgrading.Regression?
Risk
Behavioral change to OpenAPI document output — any downstream codegen tools consuming the document may be affected by newly-appearing
deprecatedfields.Verification
1019 unit tests pass; 8 new tests covering all scenarios (operation attribute, operation metadata, MVC action, type schema, inline property, reference property, negative cases).
Packaging changes reviewed?
When servicing release/2.3