Skip to content

fix: handle deserializing and writing empty security requirements #1426 - #2323

Merged
Maggie Kimani (MaggieKimani1) merged 4 commits into
microsoft:mainfrom
paulmendix:fix-no-difference-between-empty-and-no-security-requirements-on-operation
May 13, 2025
Merged

fix: handle deserializing and writing empty security requirements #1426#2323
Maggie Kimani (MaggieKimani1) merged 4 commits into
microsoft:mainfrom
paulmendix:fix-no-difference-between-empty-and-no-security-requirements-on-operation

Conversation

@paulmendix

@paulmendixPaul Rijneveld @ Mendix (paulmendix) commented Apr 13, 2025

Copy link
Copy Markdown
Contributor

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.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.

…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`.
@paulmendix

Copy link
Copy Markdown
ContributorAuthor

I will contact the right people at my work so I can sign the CLA, this will take some time.

@baywetVincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
A couple of suggestions while we wait for the CLA.

Comment threadsrc/Microsoft.OpenApi/Reader/V31/OpenApiOperationDeserializer.cs Outdated
Comment threadsrc/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs Outdated
Comment threadtest/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
Comment threadtest/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
@paulmendix

Copy link
Copy Markdown
ContributorAuthor

@microsoft-github-policy-service agree company="Mendix"

@baywetVincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Maggie Kimani (@MaggieKimani1) for final review and merge

@baywet

Copy link
Copy Markdown
Member

Paul Rijneveld @ Mendix (@paulmendix) can you please handle the conflict before we review another time?
Maggie Kimani (@MaggieKimani1) when you merge, please ensure you squash, and that nowhere in the commit message we have !:, otherwise release please will try to major bump...

@paulmendix

Copy link
Copy Markdown
ContributorAuthor

Thanks. I addressed the conflict. Ready for final review Maggie Kimani (@MaggieKimani1)

@baywetVincent Biret (baywet) changed the title fix!: handle deserializing and writing empty security requirements #1426fix: handle deserializing and writing empty security requirements #1426May 12, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No difference between no security requirement and empty security requirement on Operations

3 participants

@paulmendix@baywet@MaggieKimani1