Skip to content

Commit

Permalink
- TODO REBASE AND DROP temporary patch for backward composed type until
Browse files Browse the repository at this point in the history
#3340 is merged
  • Loading branch information
baywet committed Sep 21, 2023
1 parent 69dbec0 commit 206b6d2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,14 +1296,22 @@ codeType.TypeDefinition is CodeClass codeClass &&
}
else if (modelType is CodeComposedTypeBase codeComposedTypeBase)
{
var obsoleteComposedType = codeComposedTypeBase switch
CodeComposedTypeBase obsoleteComposedType;
var deprecationInformation = new DeprecationInformation($"This class is obsolete. Use {modelType.Name} instead.", IsDeprecated: true);
switch (codeComposedTypeBase)
{
CodeUnionType u => (CodeComposedTypeBase)u.Clone(),
CodeIntersectionType i => (CodeComposedTypeBase)i.Clone(),
_ => throw new InvalidOperationException("Could not create an obsolete composed type"),
};
case CodeUnionType u:
obsoleteComposedType = (CodeUnionType)u.Clone();
((CodeUnionType)obsoleteComposedType).Deprecation = deprecationInformation;
break;
case CodeIntersectionType i:
obsoleteComposedType = (CodeIntersectionType)i.Clone();
((CodeIntersectionType)obsoleteComposedType).Deprecation = deprecationInformation;
break;
default:
throw new InvalidOperationException("Could not create an obsolete composed type");
}
obsoleteComposedType.Name = obsoleteTypeName;
obsoleteComposedType.Deprecation = new($"This class is obsolete. Use {modelType.Name} instead.", IsDeprecated: true);
return (modelType, obsoleteComposedType);
}
}
Expand Down

0 comments on commit 206b6d2

Please sign in to comment.