© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
20 replies
Tiger

nswag (OpenApi) typescript get error type

Hey, I'm generating an api client using nswag, here is an example route:

[HttpPost("BeginLogin")]
    [ProducesResponseType(typeof(AppError), 400)]
    [ProducesResponseType(typeof(BeginLoginResponse), 200)]
    public async Task<ActionResult> BeginLogin([FromBody] BeginLoginRequest request)
[HttpPost("BeginLogin")]
    [ProducesResponseType(typeof(AppError), 400)]
    [ProducesResponseType(typeof(BeginLoginResponse), 200)]
    public async Task<ActionResult> BeginLogin([FromBody] BeginLoginRequest request)


However, in the client itself the response is not a union type, but simply the 200 default type... How am I supposed to get the error in the frontend (typescript)?

beginLogin(authorization: any | undefined, request: BeginLoginRequest): Promise<BeginLoginResponse>{}
beginLogin(authorization: any | undefined, request: BeginLoginRequest): Promise<BeginLoginResponse>{}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

nswag openapi add a global return type for a specific response code
C#CC# / help
13mo ago
Resolving External Components with Nested Components in NSwag for OpenAPI specs
C#CC# / help
2y ago
❔ NSwag Client generation
C#CC# / help
3y ago
How flexible is NSwag?
C#CC# / help
2y ago