You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
have an OpenAPI spec that includes multiple schemas defined under components.schemas with names containing periods and ending with numbers, e.g.:
"Section.TestClassA.1"
"Section.TestClassA.2"
"Section.TestClassB.1"
"Section.TestClassB.2"
use NSwag to generate a C# client
Observed behavior
with NSwag versions up to and including 14.0.0-preview008:
generated class names are _1, _2 for the first set and _12, _22 for the second set
the client code compiles and is usable by application code
with NSwag version 14.0.0-preview009:
generated class names are _1, _2 for both sets
the client code compiles but is not usable by application code due to improper re-use of class names
with NSwag version 14.1.0:
generated class names are _1, _2 for the first set and 1, 2 for the second set
the client code does not compile due to invalid class names (can't be a number)
Expected behavior
the behavior from NSwag 14.0.0-preview008 and earlier, where all generated class names are unique
Sample repo
I have prepared a minimal sample repo here that demonstrates the problem. Build the solution in the repo to automatically generate clients using various NSwag versions.
The correctly working versions of NSwag generate clients with classes named _1, _2, _12 and _22. The NSwagExample.Consumer project references these classes for each project, in their corresponding Consumer.cs file.
Uncommenting the NSwagExample.Consumer\13.20.0.And.NSwag.Net60\Consumer.cs file displays the expected behavior in all versions: _1, _2, _12 and _22 exist and can be referenced without issues. OK.
Uncommenting the NSwagExample.Consumer\14.0.0-preview008.And.NSwag.Net80\Consumer.cs file shows that the behavior has not changed yet: _1, _2, _12 and _22 exist and can be referenced without issues. OK.
Uncommenting the NSwagExample.Consumer\14.0.0-preview009.And.NSwag.Net80\Consumer.cs file shows the first change in behavior: _12 and _22 do not exist anymore, and instead _1 and _2 are reused twice. Not OK.
Steps to reproduce
components.schemas
with names containing periods and ending with numbers, e.g.:"Section.TestClassA.1"
"Section.TestClassA.2"
"Section.TestClassB.1"
"Section.TestClassB.2"
Observed behavior
with NSwag versions up to and including
14.0.0-preview008
:_1
,_2
for the first set and_12
,_22
for the second setwith NSwag version
14.0.0-preview009
:_1
,_2
for both setswith NSwag version
14.1.0
:_1
,_2
for the first set and1
,2
for the second setExpected behavior
14.0.0-preview008
and earlier, where all generated class names are uniqueSample repo
I have prepared a minimal sample repo here that demonstrates the problem. Build the solution in the repo to automatically generate clients using various NSwag versions.
The correctly working versions of NSwag generate clients with classes named
_1
,_2
,_12
and_22
. TheNSwagExample.Consumer
project references these classes for each project, in their correspondingConsumer.cs
file.Observed behavior per project:
NSwagExample.13.20.0.And.NSwag.Net60.OK
Versions
NSwagExe
->Net60
NSwag.MSBuild
->13.20.0
NSwagExample.Consumer\13.20.0.And.NSwag.Net60\Consumer.cs
file displays the expected behavior in all versions:_1
,_2
,_12
and_22
exist and can be referenced without issues. OK.NSwagExample.14.0.0-preview008.And.NSwag.Net80.OK
Versions
NSwagExe
->Net80
NSwag.MSBuild
->14.0.0-preview008
NSwagExample.Consumer\14.0.0-preview008.And.NSwag.Net80\Consumer.cs
file shows that the behavior has not changed yet:_1
,_2
,_12
and_22
exist and can be referenced without issues. OK.NSwagExample.14.0.0-preview009.And.NSwag.Net80.NOK
Versions
NSwagExe
->Net80
NSwag.MSBuild
->14.0.0-preview009
NSwagExample.Consumer\14.0.0-preview009.And.NSwag.Net80\Consumer.cs
file shows the first change in behavior:_12
and_22
do not exist anymore, and instead_1
and_2
are reused twice. Not OK.NSwagExample.14.1.0.And.NSwag.Net80.NOK
Versions
NSwagExe
->Net80
NSwag.MSBuild
->14.1.0
_12
and_22
classes being now named1
and2
, which is not valid C# syntax. Not OK.The text was updated successfully, but these errors were encountered: