fix: handle deserializing and writing empty security requirements #1426#2323
Merged
MaggieKimani1 merged 4 commits intomicrosoft:mainfrom May 13, 2025
Conversation
…crosoft#1426 make distinction between empty security requirements and no security requirements on an operation. empty security requirements are read as an empty list, no security requirements are read as null for OpenAPI v2/v3/v3.1. This is a breaking change, previously both cases were read as an empty list. also includes a change to OpenApiOperation.SerializeInternal so it can serialize these two cases separately. this required a new method OpenApiWriterExtensions.WriteOptionalOrEmptyCollection. includes unit tests, change to PublicApi.approved.txt to include the new method, and I removed a couple of unused usings and a typo in test name `SerializeDocWithSecuritySchemeWithInlineReferencesWorks`.
Contributor
Author
|
I will contact the right people at my work so I can sign the CLA, this will take some time. |
baywet
requested changes
Apr 14, 2025
Member
baywet
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
A couple of suggestions while we wait for the CLA.
src/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@microsoft-github-policy-service agree company="Mendix" |
paulmendix
commented
Apr 18, 2025
test/Microsoft.OpenApi.Tests/Models/Samples/docWithEmptyOperationSecurity.yaml
Show resolved
Hide resolved
baywet
previously approved these changes
May 12, 2025
Member
baywet
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
@MaggieKimani1 for final review and merge
Member
|
@paulmendix can you please handle the conflict before we review another time? |
…ity-requirements-on-operation
Contributor
Author
|
Thanks. I addressed the conflict. Ready for final review @MaggieKimani1 |
baywet
approved these changes
May 12, 2025
MaggieKimani1
approved these changes
May 13, 2025
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.
fix #1426.
make distinction between empty security requirements and no security requirements on an operation. empty security requirements are read as an empty list, no security requirements are read as null for OpenAPI v2/v3/v3.1. This is a breaking change, previously both cases were read as an empty list.
also includes a change to
OpenApiOperation.SerializeInternalso it can serialize these two cases separately. this required a new methodOpenApiWriterExtensions.WriteOptionalOrEmptyCollection.includes unit tests, change to PublicApi.approved.txt to include the new method, and I removed a couple of unused usings and a typo in test name
SerializeDocWithSecuritySchemeWithInlineReferencesWorks.