Repository navigation
Add description for OpenAPI schema references - #3860
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 fromSchemaRepository.AddDefinition. - Apply schema filters even when
GenerateSchemaForTypereturns anOpenApiSchemaReference. - Update Basic test site fixtures and OpenAPI 3.1 integration snapshots to reflect
$ref-siblingdescriptionoutput.
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.
- Apply filters to OpenAPI schema references in more places. - Avoid overwriting extant schema descriptions when using `[SwaggerSchema]`.
Fix property descriptions not overwriting schema descriptions.
Apply description to properties using OpenAPI schema references when generating OpenAPI 3.1 documents.
Resolves #3759.