Skip to content

Commit

Permalink
Merge pull request #1022 from microsoft/mk/copy-responses-property
Browse files Browse the repository at this point in the history
Copy OpenApiResponses object from source OpenApiOperation
  • Loading branch information
MaggieKimani1 authored Sep 26, 2022
2 parents b645cb5 + 194ef81 commit e81a1c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi</Title>
<PackageId>Microsoft.OpenApi</PackageId>
<Version>1.4.2</Version>
<Version>1.4.3</Version>
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiResponses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public OpenApiResponses() { }
/// <summary>
/// Initializes a copy of <see cref="OpenApiResponses"/> object
/// </summary>
public OpenApiResponses(OpenApiResponses openApiResponses) { }

/// <param name="openApiResponses">The <see cref="OpenApiResponses"/></param>
public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses) {}
}
}
11 changes: 11 additions & 0 deletions test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,5 +787,16 @@ public void SerializeOperationWithNullCollectionAsV2JsonWorks()
expected = expected.MakeLineBreaksEnvironmentNeutral();
actual.Should().Be(expected);
}

[Fact]
public void EnsureOpenApiOperationCopyConstructorCopiesResponsesObject()
{
// Arrange and act
var operation = new OpenApiOperation(_operationWithBody);

// Assert
Assert.NotNull(operation.Responses);
Assert.Equal(2, operation.Responses.Count);
}
}
}

0 comments on commit e81a1c6

Please sign in to comment.