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
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. OpenApiTags in OpenApiOperations are deserialized from the root document as UnresolvedReferences
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.
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
CopyReferenceswalker does not copy over instances ofOpenApiTagReferenceTaking a look at referenceable items here
OpenAPI.NET/src/Microsoft.OpenApi/Services/CopyReferences.cs
Line 19 in 54b3202
Instances of
OpenApiTagReferenceare 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.
OpenAPI.NET/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
Line 62 in 54b3202
2.
OpenApiTags inOpenApiOperations are deserialized from the root document asUnresolvedReferencesTaking a look at the deserializer here
OpenAPI.NET/src/Microsoft.OpenApi/Reader/V3/OpenApiOperationDeserializer.cs
Line 24 in 54b3202
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.
OpenAPI.NET/src/Microsoft.OpenApi/Models/References/OpenApiTagReference.cs
Line 20 in a457935
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