NSwag icon indicating copy to clipboard operation
NSwag copied to clipboard

Generator option to use .NET built-in ProblemDetails type

Open GuyLescalier opened this issue 3 years ago • 10 comments

NSwag C# client generator creates a class for every schema in OpenAPI documentation. This prevents implementing a generic exception handler based on MyException<ProblemDetails> as ProblemDetails is a different class for each client even in the same solution. A work around is to consider it a MyException and deserialize the content of the response property which is not a very elegant solution. The solution would be adding a parameter to the generator so that it uses the built-in type (Microsoft.AspNetCore.Mvc.ProblemDetails) instead of generating a new one. That way you can still use a generated class if the schema isn't compatible with the built-in type.

GuyLescalier avatar Apr 09 '21 10:04 GuyLescalier