Skip to content

Commit

Permalink
Swagger APIView Bugfix (#9133)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu authored Oct 10, 2024
1 parent 88c86a6 commit 34d0ef6
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,27 @@ public static void AddSchemaToRootDefinition(Schema schema, Dictionary<string, D
}
else
{
Definition def = (Definition)schema;
Definition def = new Definition();
if (schema is Definition)
{
def = (Definition)schema;
}
else
{
// Copy over properties to definition
foreach (PropertyInfo property in schema.GetType().GetProperties())
{
var value = property.GetValue(schema);
if (value != null)
{
PropertyInfo targetProperty = def.GetType().GetProperty(property.Name);
if (targetProperty != null && targetProperty.CanWrite)
{
targetProperty.SetValue(def, value);
}
}
}
}
if (definitions[schemaKey].IsRefObject())
{
definitions[schemaKey] = def;
Expand Down

0 comments on commit 34d0ef6

Please sign in to comment.