© 2026 Hedgehog Software, LLC

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

nswag openapi add a global return type for a specific response code

Hey, I have an API that has routes which are defined like below; but I return some 401s and others via middleware, is there a way to say that all routes could return a specific response type using openAPI?

    [HttpPost("UpdatePersonalInformation")]
    [ProducesResponseType(typeof(UpdatePersonalInformationResponse), 200)]
    [ProducesResponseType(typeof(AppError), 400)]
    public async Task<IActionResult> UpdatePersonalInformation(
        [FromBody] UpdatePersonalInformationRequest request)
    [HttpPost("UpdatePersonalInformation")]
    [ProducesResponseType(typeof(UpdatePersonalInformationResponse), 200)]
    [ProducesResponseType(typeof(AppError), 400)]
    public async Task<IActionResult> UpdatePersonalInformation(
        [FromBody] UpdatePersonalInformationRequest request)
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) typescript get error type
C#CC# / help
13mo ago
Resolving External Components with Nested Components in NSwag for OpenAPI specs
C#CC# / help
2y ago
❔ OpenAPI add TAG swagger
C#CC# / help
3y ago
Resolving External $ref Paths With Nested Refs in NSwag for OpenAPI Specification in C#
C#CC# / help
2y ago