Open pnguyen2021 opened 8 months ago
There is a work-around the issue: remove the "/GenerateExceptionClasses:false" parameter from the 2nd+ OpenApiReference node(s):
<ItemGroup>
<OpenApiReference Include="OpenAPIs\xxx.yaml" Options="/GenerateClientInterfaces:true /AdditionalNamespaceUsages:xxx /DateType:System.DateTime /DateTimeType:System.DateTime /GenerateExceptionClasses:false /GenerateDataAnnotations:false /RequiredPropertiesMustBeDefined:false" CodeGenerator="NSwagCSharp" Namespace="xxx" ClassName="xxx">
<OutputPath>xxx.cs</OutputPath>
<SourceUri>http://xxx.yaml</SourceUri>
</OpenApiReference>
<OpenApiReference Include="OpenAPIs\yyy.yaml" CodeGenerator="NSwagCSharp" Namespace="yyy" ClassName="yyy">
<SourceUri>http://yyy.yaml</SourceUri>
<ClassName>yyy</ClassName>
<OutputPath>yyy.cs</OutputPath>
<Options>/GenerateClientInterfaces:true /AdditionalNamespaceUsages:yyy /DateTimeType:DateTime /GenerateDataAnnotations:false /RequiredPropertiesMustBeDefined:false </Options>
</OpenApiReference>
</ItemGroup>
Can confirm that I had the exact same issue and the workaround fixed it for me too
When there are multiple client classes being generated, the "/GenerateExceptionClasses:false" parameter is somehow added to the command-line even when it is already explicitly specified. v14 is not able to parse the same parameter twice.
GenerateNSwagCSharp: dotnet --roll-forward-on-no-candidate-fx 2 "C:\zzz\nswag.msbuild\14.0.0\buildTransitive../tools/Net60//dotnet-nswag.dll" openapi2csclient /className:yyy /namespace:yyy /GenerateExceptionClasses:false /input:"D:\yyy.yaml" /output:"yyy.cs" /GenerateClientInterfaces:true /AdditionalNamespaceUsages:yyy /DateType:DateTime /DateTimeType:DateTime /GenerateExceptionClasses:false /GenerateDataAnnotations:false /RequiredPropertiesMustBeDefined:false NSwag command line tool for .NET Core Net60, toolchain v14.0.0.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) Visit http://nswag.org/ for more information. NSwag bin directory: C:\zzz\nswag.msbuild\14.0.0\tools\Net60 NConsole.UnusedArgumentException: Unrecognised arguments are present: [] at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /_/src/NSwag.Commands/NSwagCommandProcessor.cs:line 62
Previous version worked fine:
GenerateNSwagCSharp: dotnet --roll-forward-on-no-candidate-fx 2 "C:\zzz\nswag.msbuild\13.18.2\build../tools/Net60//dotnet-nswag.dll" openapi2csclient /className:yyy /namespace:yyy /GenerateExceptionClasses:false /input:"D:\yyy.yaml" /output:"obj\yyy.cs" /GenerateClientInterfaces:true /AdditionalNamespaceUsages:yyy /useDateTimeOffset:false /GenerateExceptionClasses:false /GenerateDataAnnotations:false /RequiredPropertiesMustBeDefined:false NSwag command line tool for .NET Core Net60, toolchain v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0)) Visit http://nswag.org/ for more information. NSwag bin directory: C:\zzz\nswag.msbuild\13.18.2\tools\Net60 Code has been successfully written to file.