Skip to content

Commit e7de93d

Browse files
Made a change to avoid calling _httpResponse.Content.ReadAsStringAsync() and deserialize from the content stream. (#731)
* Avoid calling _httpResponse.Content.ReadAsStringAsync() and deserialize from the content stream Made a change to avoid calling _httpResponse.Content.ReadAsStringAsync() and deserialize from the content stream, which significantly reduced memory utilization. Created Kubernetes.cs file and moved constructors and couple methods from the Kubernetes.cs.template to the Kubernetes.cs Generated Kubernetes.cs will be in a separate commit. * Separate commit for generated Kubernetes.cs
1 parent 43f8922 commit e7de93d

File tree

6 files changed

+5935
-20727
lines changed

6 files changed

+5935
-20727
lines changed

gen/KubernetesGenerator/ParamHelper.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ public ParamHelper(GeneralNameHelper generalNameHelper, TypeHelper typeHelper)
1919

2020
public void RegisterHelper()
2121
{
22-
Helpers.Register(nameof(IfParamCotains), IfParamCotains);
22+
Helpers.Register(nameof(IfParamContains), IfParamContains);
23+
Helpers.Register(nameof(IfParamDoesNotContain), IfParamDoesNotContain);
2324
Helpers.Register(nameof(GetModelCtorParam), GetModelCtorParam);
2425
}
2526

26-
public static void IfParamCotains(RenderContext context, IList<object> arguments,
27+
public static void IfParamContains(RenderContext context, IList<object> arguments,
2728
IDictionary<string, object> options,
2829
RenderBlock fn, RenderBlock inverse)
2930
{
@@ -54,6 +55,36 @@ public static void IfParamCotains(RenderContext context, IList<object> arguments
5455
}
5556
}
5657

58+
public static void IfParamDoesNotContain(RenderContext context, IList<object> arguments,
59+
IDictionary<string, object> options,
60+
RenderBlock fn, RenderBlock inverse)
61+
{
62+
var operation = arguments?.FirstOrDefault() as SwaggerOperation;
63+
if (operation != null)
64+
{
65+
string name = null;
66+
if (arguments.Count > 1)
67+
{
68+
name = arguments[1] as string;
69+
}
70+
71+
var found = false;
72+
73+
foreach (var param in operation.Parameters)
74+
{
75+
if (param.Name == name)
76+
{
77+
found = true;
78+
break;
79+
}
80+
}
81+
82+
if (!found)
83+
{
84+
fn(null);
85+
}
86+
}
87+
}
5788

5889
public void GetModelCtorParam(RenderContext context, IList<object> arguments,
5990
IDictionary<string, object> options,

gen/KubernetesGenerator/TypeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void IfReturnType(RenderContext context, IList<object> arguments,
306306
{
307307
fn(null);
308308
}
309-
else if (type.ToLower() == rt.ToLower())
309+
else if (string.Equals(type, rt.ToLower(), StringComparison.OrdinalIgnoreCase))
310310
{
311311
fn(null);
312312
}

0 commit comments

Comments
 (0)