Skip to content

[V2] Handing of Tags on reading and trimming openApi documents #2233

@andrueastman

Description

@andrueastman

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions