diff --git a/src/SDK/Language/DotNet.php b/src/SDK/Language/DotNet.php index c85ea10c0..085a503a3 100644 --- a/src/SDK/Language/DotNet.php +++ b/src/SDK/Language/DotNet.php @@ -478,13 +478,13 @@ public function getFunctions(): array if (isset($property['sub_schema']) && !empty($property['sub_schema'])) { if ($property['type'] === 'array') { - $result = 'List<' . \ucfirst($property['sub_schema']) . '>'; + $result = 'List<' . $this->toPascalCase($property['sub_schema']) . '>'; } else { - $result = \ucfirst($property['sub_schema']); + $result = $this->toPascalCase($property['sub_schema']); } } elseif (isset($property['enum']) && !empty($property['enum'])) { $enumName = $property['enumName'] ?? $property['name']; - $result = \ucfirst($enumName); + $result = $this->toPascalCase($enumName); } else { $result = $this->getTypeName($property); } @@ -497,9 +497,9 @@ public function getFunctions(): array }), new TwigFunction('property_name', function (array $definition, array $property) { $name = $property['name']; - $name = \ucfirst($name); $name = \str_replace('$', '', $name); - if (\in_array(\strtolower($name), $this->getKeywords())) { + $name = $this->toPascalCase($name); + if (\in_array($name, $this->getKeywords())) { $name = '@' . $name; } return $name; diff --git a/templates/dotnet/Package/Models/Model.cs.twig b/templates/dotnet/Package/Models/Model.cs.twig index bc024073d..b4f8aebeb 100644 --- a/templates/dotnet/Package/Models/Model.cs.twig +++ b/templates/dotnet/Package/Models/Model.cs.twig @@ -1,3 +1,4 @@ + using System; using System.Linq; using System.Collections.Generic; @@ -11,7 +12,7 @@ namespace {{ spec.title | caseUcfirst }}.Models { {%~ for property in definition.properties %} [JsonPropertyName("{{ property.name }}")] - public {{ sub_schema(property) }} {{ property_name(definition, property) | overrideProperty(definition.name) }} { get; private set; } + public {{ sub_schema(property) | raw }} {{ property_name(definition, property) | overrideProperty(definition.name) }} { get; private set; } {%~ endfor %} {%~ if definition.additionalProperties %} @@ -20,7 +21,7 @@ namespace {{ spec.title | caseUcfirst }}.Models {%~ endif %} public {{ definition.name | caseUcfirst | overrideIdentifier }}( {%~ for property in definition.properties %} - {{ sub_schema(property) }} {{ property.name | caseCamel | escapeKeyword }}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %} + {{ sub_schema(property) | raw }} {{ property.name | caseCamel | escapeKeyword }}{% if not loop.last or (loop.last and definition.additionalProperties) %},{% endif %} {%~ endfor %} {%~ if definition.additionalProperties %}