Skip to content

Commit 2d2c932

Browse files
committed
fix: spacing
1 parent 0981819 commit 2d2c932

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

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

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,49 +39,42 @@ namespace {{ spec.title | caseUcfirst }}.Models
3939
}
4040

4141
public static {{ definition.name | caseUcfirst | overrideIdentifier }} From(Dictionary<string, object> map) => new {{ definition.name | caseUcfirst | overrideIdentifier }}(
42-
{%- for property in definition.properties %}
43-
{{ property.name | caseCamel | escapeKeyword | removeDollarSign }}:
44-
{%- if property.sub_schema %}
45-
{%- if property.type == 'array' %}
42+
{%~ for property in definition.properties %}
43+
{{ property.name | caseCamel | escapeKeyword | removeDollarSign }}:
44+
{%- if property.sub_schema %}
45+
{%~ if property.type == 'array' %}
4646
((JArray)map["{{ property.name }}"])
47-
.ToObject<List<Dictionary<string, object>>>()
48-
.Select(it => {{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(map: it))
49-
.ToList()
47+
.ToObject<List<Dictionary<string, object>>>()
48+
.Select(it => {{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(map: it))
49+
.ToList()
5050
{%- else %}
5151
{{ property.sub_schema | caseUcfirst | overrideIdentifier }}.From(
5252
map: ((JObject)map["{{ property.name }}"])
53-
.ToObject<Dictionary<string, object>>()!
53+
.ToObject<Dictionary<string, object>>()!
5454
)
5555
{%- endif %}
56-
{%- else %}
57-
{%- if property.type == 'array' %}
56+
{%~ else %}
57+
{%~ if property.type == 'array' %}
5858
((JArray)map["{{ property.name }}"]).ToObject<{{ property | typeName }}>()
59-
{%- else %}
60-
{%- if property.type == "integer" or property.type == "number" %}
61-
{%- if not property.required %}
62-
map["{{ property.name }}"] == null ? null :
63-
{%- endif %}
64-
Convert.To{% if property.type == "integer" %}Int64{% else %}Double{% endif %}(map["{{ property.name }}"])
65-
{%- else %}
66-
{%- if property.type == "boolean" %}
59+
{%~ else %}
60+
{%~ if property.type == "integer" or property.type == "number" %}
61+
{%~ if not property.required %}map["{{ property.name }}"] == null ? null : {% endif %} Convert.To{% if property.type == "integer" %}Int64{% else %}Double{% endif %}(map["{{ property.name }}"])
62+
{%~ else %}
63+
{%~ if property.type == "boolean" %}
6764
({{ property | typeName }}{% if not property.required %}?{% endif %})map["{{ property.name }}"]
68-
{%- else %}
69-
map
70-
{%- if not property.required -%}
71-
.TryGetValue("{{ property.name }}", out var {{ property.name | caseCamel | escapeKeyword | removeDollarSign }}) ?
72-
{{ property.name | caseCamel | escapeKeyword | removeDollarSign }}?.ToString() : null
73-
{%- else -%}
74-
["{{ property.name }}"]{% if not property.required %}?{% endif %}.ToString()
75-
{%- endif %}
65+
{%~ else %}
66+
{%~ if not property.required %}map.TryGetValue("{{ property.name }}", out var {{ property.name | caseCamel | escapeKeyword | removeDollarSign }}) ? {{ property.name | caseCamel | escapeKeyword | removeDollarSign }}?.ToString() : null
67+
{%~ else %} map["{{ property.name }}"].ToString(){% endif %}
7668
{%- endif %}
77-
{%- endif %}
78-
{%- endif %}
79-
{%- endif %}
80-
{%- if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %}
81-
{%- endfor %}
69+
{%~ endif %}
70+
{%~ endif %}
71+
{%~ endif %}
72+
{%- if not loop.last or (loop.last and definition.additionalProperties) %},
73+
{%~ endif %}
74+
{%~ endfor %}
8275
{%- if definition.additionalProperties %}
83-
data: map
84-
{%- endif %}
76+
, data: map
77+
{%- endif ~%}
8578
);
8679

8780
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()

0 commit comments

Comments
 (0)