OpenAPIReference objects are not created correctly
When creating OpenAPI model objects that are just references to another model object they need to be marked as unresolved so that reference resolution can replace them with the resolved object.
When an object is created and assigned an OpenApiReference like this,
OpenApiSchema derivedTypeSchema = new()
{
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = derivedType.FullName()
}
};
there needs to be an assignment to the UnresolvedReference property.
OpenApiSchema derivedTypeSchema = new()
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = derivedType.FullName()
}
};
Without this flag set, client code will assume that the object is just an empty model object. The presence of an OpenApiReference object is not sufficient to identify a reference as model objects that are targeted by the reference will also have the OpenApiReference set.
This still seems to be an issue and is blocking this https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/1144
@millicentachieng See this issue https://github.com/microsoft/OpenAPI.NET/issues/1025
@millicentachieng OpenAPI.NET 1.4.4-preview1 is now out. Could you try the code that runs the OpenApiReferenceResolver after creating the OpenAPIDocument so that it is valid when returned? This will allow DevX API to stop cloning the document.
Resolving references is not the solution we are looking for. The OpenApiReferenceResolver replaces a reference with its populated object equivalent.
More details here.