NSwag
NSwag copied to clipboard
Generator option to use .NET built-in ProblemDetails type
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.