You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Copy constructor doesn't create new OpenApiPathItem objects when creating new instance of OpenApiPaths #1193
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.
Having this issue with cloning OpenApiPathItem as well. As a workaround I serialize to json via the built-in functionality and use ReadFragment to deserialize it again.
This is not a bug, it's by design. Dictionary creates shallow copies, removing the derived constructor would be a breaking change at this point. And the rest of the cloning infrastructure is using offering shallow copies as well.
I've amended the doc comments in #2947 to address that.
And if we get an issue/popular request to implement deep copies across the object model, we should do that at a later stage.
Let me know if you have any additional comments or questions.
Activity
darrelmiller commentedon Apr 2, 2023
When cloning OpenApiPaths we are using the standard Dictionary constructor which does not do a clone of the values of the key value pairs.
https://github.com/microsoft/OpenAPI.NET/blob/vnext/src/Microsoft.OpenApi/Models/OpenApiExtensibleDictionary.cs#L31
MaggieKimani1 commentedon Apr 24, 2023
Reopening this issue as its not fixed.
kevinharing commentedon Dec 1, 2023
Having this issue with cloning
OpenApiPathItemas well. As a workaround I serialize to json via the built-in functionality and use ReadFragment to deserialize it again.baywet commentedon Jul 14, 2026
This is not a bug, it's by design. Dictionary creates shallow copies, removing the derived constructor would be a breaking change at this point. And the rest of the cloning infrastructure is using offering shallow copies as well.
I've amended the doc comments in #2947 to address that.
And if we get an issue/popular request to implement deep copies across the object model, we should do that at a later stage.
Let me know if you have any additional comments or questions.