Skip to content

Commit e81a1c6

Browse files
Merge pull request #1022 from microsoft/mk/copy-responses-property
Copy OpenApiResponses object from source OpenApiOperation
2 parents b645cb5 + 194ef81 commit e81a1c6

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Company>Microsoft</Company>
1212
<Title>Microsoft.OpenApi</Title>
1313
<PackageId>Microsoft.OpenApi</PackageId>
14-
<Version>1.4.2</Version>
14+
<Version>1.4.3</Version>
1515
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
1616
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1717
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi/Models/OpenApiResponses.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public OpenApiResponses() { }
1616
/// <summary>
1717
/// Initializes a copy of <see cref="OpenApiResponses"/> object
1818
/// </summary>
19-
public OpenApiResponses(OpenApiResponses openApiResponses) { }
20-
19+
/// <param name="openApiResponses">The <see cref="OpenApiResponses"/></param>
20+
public OpenApiResponses(OpenApiResponses openApiResponses) : base(dictionary: openApiResponses) {}
2121
}
2222
}

test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,5 +787,16 @@ public void SerializeOperationWithNullCollectionAsV2JsonWorks()
787787
expected = expected.MakeLineBreaksEnvironmentNeutral();
788788
actual.Should().Be(expected);
789789
}
790+
791+
[Fact]
792+
public void EnsureOpenApiOperationCopyConstructorCopiesResponsesObject()
793+
{
794+
// Arrange and act
795+
var operation = new OpenApiOperation(_operationWithBody);
796+
797+
// Assert
798+
Assert.NotNull(operation.Responses);
799+
Assert.Equal(2, operation.Responses.Count);
800+
}
790801
}
791802
}

0 commit comments

Comments
 (0)