Description
In OpenApiOperation.cs
, the documentation for Security states that "To remove a top-level security declaration, an empty array can be used.". Great - this is exactly what I want. To declare top-level security and then remove it for a few operations that allow anonymous access.
The problem is, I can't actually see any way to get OpenAPI.NET to write out an empty array. Both the SerializeAsV2 and SerializeAsV3 methods write out the security section using writer.WriteOptionalCollection(...)
, which only writes out if (elements != null && elements.Any())
. That means that whether you set Security to null or an empty list, the security section will be skipped altogether instead of serialized to an empty JSON array.
I need to serialize it to an empty JSON array, so what should I do? Does there need to be an update to OpenAPI.NET to allow this? Seems to me that there does.