Skip to content

Commit d8a5f36

Browse files
author
Gunpal Jain
committed
Simplify description retrieval in SchemaSubsetHelper.
Replaced direct dictionary access with TryGetValue to prevent potential KeyNotFound exceptions. This ensures safer and more robust handling of missing keys when fetching "mainFunction_Desc".
1 parent 234c61e commit d8a5f36

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libs/CSharpToJsonSchema/SchemaSubsetHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ public static OpenApiSchema ConvertToSchema(JsonTypeInfo type, string descriptio
141141
{
142142
required.Add(re.Key);
143143
}
144-
145-
146-
var mainDescription = x.Description ?? dics["mainFunction_Desc"];
144+
145+
var mainDescription = x.Description ?? (dics.TryGetValue("mainFunction_Desc", out var desc) ? desc : "");
147146
return new OpenApiSchema()
148147
{
149148
Description = mainDescription,

0 commit comments

Comments
 (0)