Skip to content

Commit faad585

Browse files
committed
Import Enums namespace conditionally in model template
Adds conditional import of the Enums namespace in the Model.cs.twig template only when the model definition contains enum properties. This prevents unnecessary imports and improves template clarity.
1 parent ff2545a commit faad585

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ using System.Linq;
44
using System.Collections.Generic;
55
using System.Text.Json;
66
using System.Text.Json.Serialization;
7+
{% if definition.properties | filter(p => p.enum) | length > 0 %}
78
using {{ spec.title | caseUcfirst }}.Enums;
9+
{% endif %}
810

911
namespace {{ spec.title | caseUcfirst }}.Models
1012
{

0 commit comments

Comments
 (0)