-
Notifications
You must be signed in to change notification settings - Fork 270
Description
There are a couple of issues with handling tags in V2 preview causing issues with plugin generation on Kiota when producing a trimmed openApi document.
1. The CopyReferences
walker does not copy over instances of OpenApiTagReference
Taking a look at referenceable items here
switch (referenceHolder) |
Instances of OpenApiTagReference
are not copied over to the new document.
Therefore, using this method with an openApiDocument leaves out the tags that may have been referenced in an openApi document.
public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func<string, OperationType?, OpenApiOperation, bool> predicate) |
2. OpenApiTag
s in OpenApiOperation
s are deserialized from the root document as UnresolvedReference
s
Taking a look at the deserializer here
if (n.CreateSimpleList((valueNode, doc) => LoadTagByReference(valueNode.GetScalarValue(), doc), doc) is {Count: > 0} tags) |
The openApi tag is loaded up as a reference by calling the constructor but not adding the tag to the root of the document. This therefore causes the Target of the reference to be null according to the definition below.
public override OpenApiTag Target |
Therefore, when we have a document trimmed with the OpenApiFilterService
, any tags that existed in the document at the operation level will be references with invalid/unresolved targets. Trying to write the document will result to a null reference due to the null target as defined here.
OpenAPI.NET/src/Microsoft.OpenApi/Models/References/BaseOpenApiReferenceHolder.cs
Line 112 in a457935
action(writer, Target); |