Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebApiOpenApiDocumentGenerator: Support multiple Route-attributes on Controller level #4129

Conversation

andreasbalzer
Copy link
Contributor

@andreasbalzer andreasbalzer commented Sep 1, 2022

This PR adds support for multiple Route-attributes on controller-level. For example, an API could respond both as api/beverages and api/fluids.

        [System.Web.Http.Route("api/{regionId:int}/beverages")]
        [System.Web.Http.Route("api/{regionId:int}/fluids")]
        public class BeveragesController : RegionalItemController
        {
            [System.Web.Http.HttpGet]
            public string[] Get(int regionId)
            {
                throw new NotImplementedException();
            }
        }

Observed behavior: WebApiOpenApiDocumentGenerator threw an exception, as it only allowed one Route-attribute on controller level

Expected behavior: Two paths get created.

Issue addressed partly: 1354 NSwag.MSBuild does not support API versioning or multiple routes

@andreasbalzer andreasbalzer marked this pull request as draft September 1, 2022 17:42
@andreasbalzer andreasbalzer marked this pull request as ready for review September 1, 2022 23:18
@andreasbalzer
Copy link
Contributor Author

@RicoSuter please let me know if you like to see changes or if there is any way I can help.

@RicoSuter
Copy link
Owner

As I do not actively support WebAPI anymore I'll just assume this is fine.
Thanks for the PR.

@RicoSuter RicoSuter merged commit b543334 into RicoSuter:master Sep 16, 2022
lahma pushed a commit to lahma/NSwag that referenced this pull request Dec 25, 2022
…Controller level (RicoSuter#4129)

* WebApiOpenApiDocumentGenerator: Support multiple route attributes on controllers

* Improve test design

* Add check for empty routes
lahma pushed a commit to lahma/NSwag that referenced this pull request Jan 20, 2024
…Controller level (RicoSuter#4129)

* WebApiOpenApiDocumentGenerator: Support multiple route attributes on controllers

* Improve test design

* Add check for empty routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants