Skip to content

Commit 8071875

Browse files
author
Gunpal Jain
committed
removed uncessary variable
1 parent d245705 commit 8071875

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

src/libs/CSharpToJsonSchema/SchemaSubsetHelper.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,40 @@ public static OpenApiSchema ConvertToSchema<T>(JsonSerializerOptions? jsonOption
110110
public static OpenApiSchema ConvertToSchema(JsonTypeInfo type, string descriptionString)
111111
{
112112
var typeInfo = type;
113-
114-
var dics = JsonSerializer.Deserialize(descriptionString,OpenApiSchemaJsonContext.Default.IDictionaryStringString);
113+
114+
var dics = JsonSerializer.Deserialize(descriptionString,
115+
OpenApiSchemaJsonContext.Default.IDictionaryStringString);
115116
List<string> required = new List<string>();
116-
var x = ConvertToCompatibleSchemaSubset(typeInfo.GetJsonSchemaAsNode(exporterOptions:new JsonSchemaExporterOptions()
117-
{
118-
TransformSchemaNode = (a, b) =>
117+
var x = ConvertToCompatibleSchemaSubset(typeInfo.GetJsonSchemaAsNode(
118+
exporterOptions: new JsonSchemaExporterOptions()
119119
{
120-
if (a.TypeInfo.Type.IsEnum)
120+
TransformSchemaNode = (a, b) =>
121121
{
122-
b["type"] = "string";
123-
}
124-
if (a.PropertyInfo == null)
122+
if (a.TypeInfo.Type.IsEnum)
123+
{
124+
b["type"] = "string";
125+
}
126+
127+
if (a.PropertyInfo == null)
128+
return b;
129+
var propName = ToCamelCase(a.PropertyInfo.Name);
130+
if (dics.ContainsKey(propName))
131+
{
132+
b["description"] = dics[propName];
133+
}
134+
125135
return b;
126-
var propName = ToCamelCase(a.PropertyInfo.Name);
127-
if (dics.ContainsKey(propName))
128-
{
129-
b["description"] = dics[propName];
130-
}
131-
132-
return b;
133-
},
134-
}));
136+
},
137+
}));
138+
135139

136-
137140
foreach (var re in x.Properties)
138141
{
139142
required.Add(re.Key);
140143
}
141144

142-
143-
var mainDescription =x.Description ?? dics["mainFunction_Desc"];
145+
146+
var mainDescription = x.Description ?? dics["mainFunction_Desc"];
144147
return new OpenApiSchema()
145148
{
146149
Description = mainDescription,
@@ -149,7 +152,7 @@ public static OpenApiSchema ConvertToSchema(JsonTypeInfo type, string descriptio
149152
Type = "object"
150153
};
151154
}
152-
155+
153156
public static string ToCamelCase(string str)
154157
{
155158
if (!string.IsNullOrEmpty(str) && str.Length > 1)
@@ -164,9 +167,7 @@ public static string ConvertToSchema(Type type, JsonSerializerOptions? jsonOptio
164167
{
165168
var node = jsonOptions.GetJsonSchemaAsNode(type);
166169
var x = ConvertToCompatibleSchemaSubset(node);
167-
168-
var x2= JsonSerializer.Serialize(x.Properties, OpenApiSchemaJsonContext.Default.IDictionaryStringOpenApiSchema);
169170

170-
return x2;
171+
return JsonSerializer.Serialize(x.Properties, OpenApiSchemaJsonContext.Default.IDictionaryStringOpenApiSchema);
171172
}
172173
}

0 commit comments

Comments
 (0)