Skip to content

Commit 9d4ca4c

Browse files
committed
fix: allow colon in EnumMember-Value
1 parent 479a3fb commit 9d4ca4c

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

src/Atc.CodeGeneration.CSharp/Content/Generators/GenerateContentForEnum.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class GenerateContentForEnum : IContentGenerator
66
{
77
private readonly ICodeDocumentationTagsGenerator codeDocumentationTagsGenerator;
88
private readonly EnumParameters parameters;
9+
private readonly char[] removeSeparatorsForName = { ' ', '-', '_', ':' };
910

1011
public GenerateContentForEnum(
1112
ICodeDocumentationTagsGenerator codeDocumentationTagsGenerator,
@@ -57,8 +58,10 @@ public string Generate()
5758
}
5859
else
5960
{
61+
var name = parametersValue.Name.PascalCase(removeSeparatorsForName, true);
62+
6063
sbLine.AppendLine($"[EnumMember(Value = \"{parametersValue.Name}\")]");
61-
sbLine.Append(4, parametersValue.Name.PascalCase(removeSeparators: true));
64+
sbLine.Append(4, name);
6265
}
6366
}
6467
else

src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/ServerClient/ContentGeneratorServerClientEnumParametersFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static EnumParameters Create(
4343
{
4444
case 1:
4545
result.Add(
46-
key: sa[0].Trim().Replace(":", "-", StringComparison.CurrentCulture),
46+
key: sa[0].Trim(),
4747
value: null);
4848
break;
4949
case 2:

test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Monta/Monta.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15250,6 +15250,22 @@ components:
1525015250
- created
1525115251
- updated
1525215252
- deleted
15253+
- scanned
15254+
- monta:ocpp:OcppRequestResponse
15255+
- monta:ocpp:ChargePointConnected
15256+
- monta:ocpp:ChargePointDisconnected
15257+
- monta:ocpp:OcppProtocolError
15258+
- monta:ocpp:OcppRequestTimeout
15259+
x-enum-varnames:
15260+
- CREATED
15261+
- UPDATED
15262+
- DELETED
15263+
- SCANNED
15264+
- OCPP_REQUEST_RESPONSE
15265+
- CHARGE_POINT_CONNECTED
15266+
- CHARGE_POINT_DISCONNECTED
15267+
- OCPP_PROTOCOL_ERROR
15268+
- OCPP_REQUEST_TIMEOUT
1525315269
KwhPerHour:
1525415270
required:
1525515271
- time

test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Monta/VerifyClient/WCEM/src/Monta.ApiClient.Generated/Contracts/_EnumerationTypes/KafkaEventType.verified.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,22 @@ public enum KafkaEventType
2121

2222
[EnumMember(Value = "deleted")]
2323
Deleted,
24+
25+
[EnumMember(Value = "scanned")]
26+
Scanned,
27+
28+
[EnumMember(Value = "monta:ocpp:OcppRequestResponse")]
29+
MontaOcppOcppRequestResponse,
30+
31+
[EnumMember(Value = "monta:ocpp:ChargePointConnected")]
32+
MontaOcppChargePointConnected,
33+
34+
[EnumMember(Value = "monta:ocpp:ChargePointDisconnected")]
35+
MontaOcppChargePointDisconnected,
36+
37+
[EnumMember(Value = "monta:ocpp:OcppProtocolError")]
38+
MontaOcppOcppProtocolError,
39+
40+
[EnumMember(Value = "monta:ocpp:OcppRequestTimeout")]
41+
MontaOcppOcppRequestTimeout,
2442
}

0 commit comments

Comments
 (0)