yahehe / Nancy.Swagger

Nancy plugin for generated API documentation in Swagger format.
MIT License
133 stars 60 forks source link

RouteParamAttribute - mulitiple usage behavior. #146

Closed vincentparrett closed 6 years ago

vincentparrett commented 6 years ago

Expected Behavior

Multiple RouteParam attributes specified on a single method parameter would result in multiple parameters being documented.

Actual Behavior

Last attribute wins.

Steps to Reproduce the Problem

[Route("GetAccessControlEntriesPaged")]
[Route(Summary = "Returns a list of access control entries.")]
[Route(HttpMethod.Post, RestRoutes.RestRoutes.AuthRefreshToken_Full)]
[SwaggerResponse(HttpStatusCode.OK, Message = "OK", Model = typeof(AccessControlEntriesListModel))]
[SwaggerResponse(HttpStatusCode.Forbidden, Model = typeof(ForbiddenModel))]
[SwaggerResponse(HttpStatusCode.BadRequest, Model = typeof(ValidationFailureModel))]
[Route(Tags = new[] { "ACL" })]
private AccessControlEntriesListModel GetAccessControlEntriesPaged([RouteParam(ParameterIn.Query, "Skip")] [RouteParam(ParameterIn.Query, "Take")] Paging paging)
{
}

We do some work under the hood to massage Skip and Take query parameters into a Paging object, so all our methods that return lists will take this paging object. Right now I can't document these parameters with Nancy.Swagger.Annotations.

In the above example, only Take appears in the doco, even though the RouteParamAttribute allows multiple usage.

I'm happy to submit a PR for this if you are ameniable to changing the existing behavior.

Specifications

yahehe commented 6 years ago

Implemented by #148