Skip to content

Copy constructor doesn't create new OpenApiPathItem objects when creating new instance of OpenApiPaths #1193

Open
@irvinesunday

Description

@irvinesunday

Describe the bug
Copy constructors doesn't create a new instance of OpenApiPathItem and its constituent properties on new OpenApiDocument(document).

To Reproduce
I have created a breaking test to demonstrate this:

[Fact]
public void CopyConstructorForAdvancedDocumentWorks()
{
// Arrange & Act
var doc = new OpenApiDocument(AdvancedDocument);
// Change value of operation id for a given url
var docOpId = doc.Paths["/pets"].Operations[OperationType.Get].OperationId = "findAllMyPets";
var advancedDocOpId = AdvancedDocument.Paths["/pets"].Operations[OperationType.Get].OperationId;
// Assert
Assert.NotNull(doc.Info);
Assert.NotNull(doc.Servers);
Assert.NotNull(doc.Paths);
Assert.Equal(2, doc.Paths.Count);
Assert.NotNull(doc.Components);
Assert.NotEqual(docOpId, advancedDocOpId);
}

This is in the branch: is/copy-ctrs

Expected behavior
In the test, I change the operationId of the cloned OpenAPI document. I don't expect the operationId of the original OpenAPI document to also be updated.

Metadata

Metadata

Assignees

Labels

type:bugA broken experience

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions