Skip to content

Commit

Permalink
Try to fix generation of multiple identical classes #4191
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasKenneth committed Apr 25, 2024
1 parent 7de92ea commit 12373fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,9 +1656,13 @@ private CodeTypeBase CreateModelDeclarations(OpenApiUrlTreeNode currentNode, Ope
true => (GetShortestNamespace(parentElement.GetImmediateParentOfType<CodeNamespace>(), schema), response, string.Empty), // referenced schema
false => (parentElement.GetImmediateParentOfType<CodeNamespace>(), null, suffixForInlineSchema), // Inline schema, i.e. specific to the Operation
};

// If typeNameForInlineSchema is not null and the schema is referenced, we have most likely unwrapped a referenced schema(most likely from an AllOf/OneOf/AnyOf).
// Therefore the current type/schema is not really inlined, so invalidate the typeNameForInlineSchema and just work with the information from the schema reference.
if (schema.AllOf.Count == 1 && schema.Reference == null && !schema.Properties.Any())
{
schema.Reference = schema.AllOf.First().Reference;
}

if (schema.IsReferencedSchema() && !string.IsNullOrEmpty(typeNameForInlineSchema))
{
typeNameForInlineSchema = string.Empty;
Expand Down

0 comments on commit 12373fa

Please sign in to comment.