Open kimbell opened 3 years ago
I've been running into the same issue the past couple of days.
I've tried setting /GenerateExceptionClasses:true as an option in the csproj file on the second OpenApiReference in csproj, but it is ignored and the build output shows the option as being explicitly set to false on everything but the first OpenApiReference.
I would say this is related to #2839, but I don't think that one specifically calls out the fact that the option /GenerateExceptionClasses:true is being ignored when put in a csproj file.
GenerateExceptionClasses:true is mainly used to turn this completely off ... it doesnt enforce it... so probably the check whether the exceptions are needed is flawed ATM.
Hmm, maybe there is no such check:
Maybe you turned off contracts gen?
just came across this issue myself and have had a look
@RicoSuter /GenerateExceptionClasses
is explicity set to false
for service references after the first one
although the intention with this is that you should be able to explicitly turn this back on again with user provided options, the command line processor (NConsole) takes the first matching argument that it finds and not the last
and so a command like this from the user explicitly setting /GenerateExceptionClasses:true
would not work
openapi2csclient /className:{controller}Client /namespace:App /input:"C:\app\OpenAPI\service.json" /output:"obj\serviceClient.cs" /GenerateExceptionClasses:false /UseBaseUrl:false /GenerateExceptionClasses:true
May be this post can help you out: https://github.com/RicoSuter/NSwag/issues/2839#issuecomment-1198017008
This is the same solution: https://github.com/dotnet/aspnetcore/issues/18204#issuecomment-971911921
I have multiple OpenApi contracts that I'm referencing with OpenApiReference in the csproj file. When I generate the code, I place each client in a different namespace. I have some types with same names that would clash in the same namespace.
In the generated code, I get ApiException code for one of the contracts, but not for the other. Since they are in different namespaces, this doesn't compile. I have tried setting the generateExceptionClasses and exceptionClass.