Skip to content

Commit 34d0ef6

Browse files
Swagger APIView Bugfix (#9133)
1 parent 88c86a6 commit 34d0ef6

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • tools/apiview/parsers/swagger-api-parser/SwaggerApiParser

tools/apiview/parsers/swagger-api-parser/SwaggerApiParser/Utils.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,27 @@ public static void AddSchemaToRootDefinition(Schema schema, Dictionary<string, D
273273
}
274274
else
275275
{
276-
Definition def = (Definition)schema;
276+
Definition def = new Definition();
277+
if (schema is Definition)
278+
{
279+
def = (Definition)schema;
280+
}
281+
else
282+
{
283+
// Copy over properties to definition
284+
foreach (PropertyInfo property in schema.GetType().GetProperties())
285+
{
286+
var value = property.GetValue(schema);
287+
if (value != null)
288+
{
289+
PropertyInfo targetProperty = def.GetType().GetProperty(property.Name);
290+
if (targetProperty != null && targetProperty.CanWrite)
291+
{
292+
targetProperty.SetValue(def, value);
293+
}
294+
}
295+
}
296+
}
277297
if (definitions[schemaKey].IsRefObject())
278298
{
279299
definitions[schemaKey] = def;

0 commit comments

Comments
 (0)