Repository navigation
fix(models): preserve specification extensions in OpenApiPaths and OpenApiResponses copy constructors - #3162
Open
Hardik K (hardikkaurani) wants to merge 8 commits into
Conversation
Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ions Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
… extensions Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…tensions Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…onses extensions Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ths and Responses copy constructors Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
…ponses copy constructors Signed-off-by: Hardik K <hardikkaurani1@gmail.com>
Contributor
Author
|
While working with the model copy constructors, I noticed that Since the This PR updates both copy constructors to pass a shallow copy of Whenever you have a moment, I'd appreciate your review. Thank you! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
This pull request ensures that specification extensions (
Extensions) are preserved when copyingOpenApiPathsandOpenApiResponsesinstances via their copy constructors.Previously,
OpenApiPaths(OpenApiPaths paths)andOpenApiResponses(OpenApiResponses openApiResponses)calledbase(dictionary: ...)without forwarding the existing instance'sExtensions. Because theextensionsparameter defaults tonull,OpenApiExtensibleDictionaryinitializedExtensions = [], dropping any specification extensions configured onPathsorResponses.This also caused
OpenApiDocument(OpenApiDocument document)andOpenApiOperation(OpenApiOperation operation)to lose anyPaths.ExtensionsandResponses.Extensionsduring document or operation cloning.Type of Change
Related Issue(s)
None.
Changes Made
OpenApiPaths(OpenApiPaths paths)to passextensions: paths?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(paths.Extensions) : nullto the base constructor.OpenApiResponses(OpenApiResponses openApiResponses)to passextensions: openApiResponses?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(openApiResponses.Extensions) : nullto the base constructor.OpenApiPathsTestsandOpenApiResponsesTestscovering extensions preservation, dictionary mutation isolation, null parameter handling, and empty extensions handling.OpenApiDocumentTestsandOpenApiOperationTestsverifying that cloning anOpenApiDocumentpreservesPaths.Extensionsand cloning anOpenApiOperationpreservesResponses.Extensions.Testing
Local verification:
dotnet test test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj-> 1322 passed, 0 failed.dotnet test test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj-> 637 passed, 0 failed.Checklist
Versions applicability
See the contributing guidelines for more information about how patches are applied across multiple versions.
Additional Notes
Preserves full backwards compatibility and public API analyzer surface without any breaking changes.