Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes OpenAPI response reference duplicating objects #2084

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public OpenApiResponse Target
get
{
_target ??= Reference.HostDocument?.ResolveReferenceTo<OpenApiResponse>(_reference);
OpenApiResponse resolved = new OpenApiResponse(_target);
if (!string.IsNullOrEmpty(_description)) resolved.Description = _description;
return resolved;
return _target;
}
}

Expand Down Expand Up @@ -75,29 +73,32 @@ internal OpenApiResponseReference(string referenceId, OpenApiResponse target)
/// <inheritdoc/>
public override string Description
{
get => string.IsNullOrEmpty(_description) ? Target.Description : _description;
get => string.IsNullOrEmpty(_description) ? Target?.Description : _description;
set => _description = value;
}

private IDictionary<string, OpenApiMediaType> _content;
/// <inheritdoc/>
public override IDictionary<string, OpenApiMediaType> Content { get => Target?.Content; set => Target.Content = value; }
public override IDictionary<string, OpenApiMediaType> Content { get => _content is not null ? _content : Target?.Content; set => _content = value; }

private IDictionary<string, OpenApiHeader> _headers;
/// <inheritdoc/>
public override IDictionary<string, OpenApiHeader> Headers { get => Target.Headers; set => Target.Headers = value; }
public override IDictionary<string, OpenApiHeader> Headers { get => _headers is not null ? _headers : Target?.Headers; set => _headers = value; }

private IDictionary<string, OpenApiLink> _links;
/// <inheritdoc/>
public override IDictionary<string, OpenApiLink> Links { get => Target.Links; set => Target.Links = value; }
public override IDictionary<string, OpenApiLink> Links { get => _links is not null ? _links : Target?.Links; set => _links = value; }

private IDictionary<string, IOpenApiExtension> _extensions;
/// <inheritdoc/>
public override IDictionary<string, IOpenApiExtension> Extensions { get => Target.Extensions; set => Target.Extensions = value; }
public override IDictionary<string, IOpenApiExtension> Extensions { get => _extensions is not null ? _extensions : Target?.Extensions; set => _extensions = value; }

/// <inheritdoc/>
public override void SerializeAsV3(IOpenApiWriter writer)
{
if (!writer.GetSettings().ShouldInlineReference(_reference))
{
_reference.SerializeAsV3(writer);
return;
}
else
{
Expand All @@ -111,7 +112,6 @@ public override void SerializeAsV31(IOpenApiWriter writer)
if (!writer.GetSettings().ShouldInlineReference(_reference))
{
_reference.SerializeAsV31(writer);
return;
}
else
{
Expand All @@ -125,7 +125,6 @@ public override void SerializeAsV2(IOpenApiWriter writer)
if (!writer.GetSettings().ShouldInlineReference(_reference))
{
_reference.SerializeAsV2(writer);
return;
}
else
{
Expand Down
Loading