Skip to content

Commit 951a27a

Browse files
committed
fix: issue 4
1 parent 1ee0540 commit 951a27a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

templates/dotnet/Package/Extensions/Extensions.cs.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace {{ spec.title | caseUcfirst }}.Extensions
1313
return JsonSerializer.Serialize(dict, Client.SerializerOptions);
1414
}
1515

16-
public static List<T> ConvertToList<T>(object value)
16+
public static List<T> ConvertToList<T>(this object value)
1717
{
1818
return value switch
1919
{

templates/dotnet/Package/Models/Model.cs.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace {{ spec.title | caseUcfirst }}.Models
4242
{{ property.name | caseCamel | escapeKeyword | removeDollarSign }}:{{' '}}
4343
{%- if property.sub_schema %}
4444
{%- if property.type == 'array' -%}
45-
Extensions.ConvertToList<Dictionary<string, object>>(map["{{ property.name }}"]).Select(it => {{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(map: it)).ToList()
45+
map["{{ property.name }}"].ConvertToList<Dictionary<string, object>>().Select(it => {{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(map: it)).ToList()
4646
{%- else -%}
4747
{{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(map: map["{{ property.name }}"] is JsonElement jsonObj{{ loop.index }} ? jsonObj{{ loop.index }}.Deserialize<Dictionary<string, object>>()! : (Dictionary<string, object>)map["{{ property.name }}"])
4848
{%- endif %}
@@ -59,7 +59,7 @@ namespace {{ spec.title | caseUcfirst }}.Models
5959
{%- endif %}
6060
{%- else %}
6161
{%- if property.type == 'array' -%}
62-
Extensions.ConvertToList<{{ property | typeName | replace({'List<': '', '>': ''}) }}>(map["{{ property.name }}"])
62+
map["{{ property.name }}"].ConvertToList<{{ property | typeName | replace({'List<': '', '>': ''}) }}>()
6363
{%- else %}
6464
{%- if property.type == "integer" or property.type == "number" %}
6565
{%- if not property.required -%}map["{{ property.name }}"] == null ? null :{% endif %}Convert.To{% if property.type == "integer" %}Int64{% else %}Double{% endif %}(map["{{ property.name }}"])

0 commit comments

Comments
 (0)