-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Description
Imagine the following scenario:
- I defined an extension with a key
- A description contains an extension with the same key, but with a different structure
- My extension code returns null, in the hope that generic parsing (OpenAPIAny) will kick in instead.
- I get a null exception
This is caused by this block (and others similar to it)
private static IOpenApiExtension LoadExtension(string name, ParseNode node) |
Which should instead be
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser) && parser(
OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny()),
OpenApiSpecVersion.OpenApi2_0) is {} result)
{
return result;
}
else
{
return OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny());
}
Which ultimately triggers
element.Extensions[name] = Utils.CheckArgumentNull(any); |
Once those implementations are updated, all the Microsoft defined extensions should also be updated to return null instead of throwing.
if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source)); |
andrueastman
Metadata
Metadata
Assignees
Labels
type:bugA broken experienceA broken experience