Skip to content

Commit 779060f

Browse files
committed
Override the component's summary and description values with those in the Reference object
1 parent 3e5cd0f commit 779060f

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,31 +504,51 @@ internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool
504504
switch (reference.Type)
505505
{
506506
case ReferenceType.Schema:
507-
return this.Components.Schemas[reference.Id];
507+
var resolvedSchema = this.Components.Schemas[reference.Id];
508+
resolvedSchema.Description = reference.Description != null ? reference.Description : resolvedSchema.Description;
509+
return resolvedSchema;
508510

509511
case ReferenceType.PathItem:
510-
return this.Components.PathItems[reference.Id];
512+
var resolvedPathItem = this.Components.PathItems[reference.Id];
513+
resolvedPathItem.Description = reference.Description != null ? reference.Description : resolvedPathItem.Description;
514+
resolvedPathItem.Summary = reference.Summary != null ? reference.Summary : resolvedPathItem.Summary;
515+
return resolvedPathItem;
511516

512517
case ReferenceType.Response:
513-
return this.Components.Responses[reference.Id];
518+
var resolvedResponse = this.Components.Responses[reference.Id];
519+
resolvedResponse.Description = reference.Description != null ? reference.Description : resolvedResponse.Description;
520+
return resolvedResponse;
514521

515522
case ReferenceType.Parameter:
516-
return this.Components.Parameters[reference.Id];
523+
var resolvedParameter = this.Components.Parameters[reference.Id];
524+
resolvedParameter.Description = reference.Description != null ? reference.Description : resolvedParameter.Description;
525+
return resolvedParameter;
517526

518527
case ReferenceType.Example:
519-
return this.Components.Examples[reference.Id];
528+
var resolvedExample = this.Components.Examples[reference.Id];
529+
resolvedExample.Summary = reference.Summary != null ? reference.Summary : resolvedExample.Summary;
530+
resolvedExample.Description = reference.Description != null ? reference.Description : resolvedExample.Description;
531+
return resolvedExample;
520532

521533
case ReferenceType.RequestBody:
522-
return this.Components.RequestBodies[reference.Id];
523-
534+
var resolvedRequestBody = this.Components.RequestBodies[reference.Id];
535+
resolvedRequestBody.Description = reference.Description != null ? reference.Description : resolvedRequestBody.Description;
536+
return resolvedRequestBody;
537+
524538
case ReferenceType.Header:
525-
return this.Components.Headers[reference.Id];
526-
539+
var resolvedHeader = this.Components.Headers[reference.Id];
540+
resolvedHeader.Description = reference.Description != null ? reference.Description : resolvedHeader.Description;
541+
return resolvedHeader;
542+
527543
case ReferenceType.SecurityScheme:
528-
return this.Components.SecuritySchemes[reference.Id];
529-
544+
var resolvedSecurityScheme = this.Components.SecuritySchemes[reference.Id];
545+
resolvedSecurityScheme.Description = reference.Description != null ? reference.Description : resolvedSecurityScheme.Description;
546+
return resolvedSecurityScheme;
547+
530548
case ReferenceType.Link:
531-
return this.Components.Links[reference.Id];
549+
var resolvedLink = this.Components.Links[reference.Id];
550+
resolvedLink.Description = reference.Description != null ? reference.Description : resolvedLink.Description;
551+
return resolvedLink;
532552

533553
case ReferenceType.Callback:
534554
return this.Components.Callbacks[reference.Id];

0 commit comments

Comments
 (0)