Skip to content

Commit 0b6b07d

Browse files
committed
chore: convert to conditional expression
1 parent 489fa4d commit 0b6b07d

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/Microsoft.OpenApi/Extensions/EnumExtensions.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,7 @@ public static string GetDisplayName(this Enum enumValue)
5858
var attribute = e.GetAttributeOfType<DisplayAttribute>();
5959

6060
// Return the DisplayAttribute name if it exists, otherwise return the enum's string representation
61-
if (attribute?.Name is not null)
62-
{
63-
return attribute.Name;
64-
}
65-
else
66-
{
67-
return e.ToString();
68-
}
61+
return attribute?.Name is not null ? attribute.Name : e.ToString();
6962
});
7063
}
7164
}

src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,9 @@ public static JsonNode LoadAny(ParseNode node, OpenApiDocument hostDocument)
137137

138138
private static IOpenApiExtension LoadExtension(string name, ParseNode node)
139139
{
140-
if (node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser))
141-
{
142-
return parser(node.CreateAny(), OpenApiSpecVersion.OpenApi3_1);
143-
}
144-
else
145-
{
146-
return new OpenApiAny(node.CreateAny());
147-
}
140+
return node.Context.ExtensionParsers is not null && node.Context.ExtensionParsers.TryGetValue(name, out var parser)
141+
? parser(node.CreateAny(), OpenApiSpecVersion.OpenApi3_1)
142+
: new OpenApiAny(node.CreateAny());
148143
}
149144

150145
private static string? LoadString(ParseNode node)

0 commit comments

Comments
 (0)