Skip to content

Add description for OpenAPI schema references - #3860

Merged
martincostello merged 3 commits into
masterfrom
gh-3759
Mar 24, 2026
Merged

martincostello merged 3 commits into
masterfrom
gh-3759

Conversation

@martincostello

Copy link
Copy Markdown
Collaborator

Apply description to properties using OpenAPI schema references when generating OpenAPI 3.1 documents.

Resolves #3759.

Apply description to properties using OpenAPI schema references when generating OpenAPI 3.1 documents.

Resolves #3759.

Co-Authored-By: Santiago Garcia <70714718+santiagog14@users.noreply.github.com>
@martincostello martincostello added this to the v10.1.6 milestone Mar 24, 2026
Copilot AI review requested due to automatic review settings March 24, 2026 17:16
@codecov

codecov Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (b2a9a92) to head (a924a58).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3860      +/-   ##
==========================================
+ Coverage   94.97%   95.01%   +0.03%     
==========================================
  Files         111      111              
  Lines        3903     3910       +7     
  Branches      789      788       -1     
==========================================
+ Hits         3707     3715       +8     
+ Misses        196      195       -1     
Flag Coverage Δ
Linux 95.01% <100.00%> (+0.03%) ⬆️
Windows 95.01% <100.00%> (+0.03%) ⬆️
macOS 95.01% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Swashbuckle’s OpenAPI 3.1 generation to include descriptive metadata alongside $ref schema references, targeting scenarios where OpenAPI 3.1 allows “$ref siblings” (e.g., adding description next to a $ref).

Changes:

  • Populate selected schema metadata (e.g., Description) onto schema references returned from SchemaRepository.AddDefinition.
  • Apply schema filters even when GenerateSchemaForType returns an OpenApiSchemaReference.
  • Update Basic test site fixtures and OpenAPI 3.1 integration snapshots to reflect $ref-sibling description output.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SchemaRepository.cs Adds metadata propagation from definitions to returned $ref schema references.
src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs Applies schema filters to referenced schemas in the type-generation path.
test/WebSites/Basic/Controllers/SwaggerAnnotationsController.cs Adds a SwaggerSchema description annotation intended to validate $ref sibling behavior.
test/WebSites/Basic/Controllers/DataAnnotationsController.cs Adds a SwaggerSchema description annotation on an enum parameter intended to validate $ref sibling behavior.
test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/*/VerifyTests.*swaggerRequestUri=3.1*.verified.txt Updates OpenAPI 3.1 snapshots to include description adjacent to $ref in several schema locations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/WebSites/Basic/Controllers/SwaggerAnnotationsController.cs
Comment thread test/WebSites/Basic/Controllers/DataAnnotationsController.cs Outdated
- Apply filters to OpenAPI schema references in more places.
- Avoid overwriting extant schema descriptions when using `[SwaggerSchema]`.
Fix property descriptions not overwriting schema descriptions.
@martincostello
martincostello enabled auto-merge (squash) March 24, 2026 18:00
@martincostello
martincostello merged commit ac7b877 into master Mar 24, 2026
14 checks passed
@martincostello
martincostello deleted the gh-3759 branch March 24, 2026 18:10
This was referenced Mar 24, 2026
This was referenced Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question]: How to include description through xml comments in refs when using OpenApi 3.1 version?

2 participants