You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I specify the Name and custom Path parameters in the Route() attribute both are used to generate the swagger file
Actual Behavior
When Name is specified the custom Path is ignored.
Steps to Reproduce the Problem
Create a Nancy method, e.g.:
public class TestModule: NancyModule
{
public TestModule()
{
Get("/test/{param:guid}", ctx => AMethod(ctx.param), name: "AMethod");
}
[Route("AMethod")]
[Route(HttpMethod.Get, "/test/{param}")]
[RouteParam(ParameterIn.Path, Name = "param", ParamType = typeof(Guid), Required = true)]
private object AMethod(Guid param) => param.ToString();
}
Generate swagger docs
The route in the doc says '/test/{param:guid}' instead of /test/{param}' and you get a parse error at editor.swagger.io saying that "Declared path parameter "param:guid" needs to be defined as a path parameter at either the path or operation level"
Specifications
I think the problem is in the code in Nancy.Swagger.Annotations / RouteId.Create() method, if the code
[Route(HttpMethod.Get, "/test/{param}")] doesn't work as a Custom path, but actually is an alternative to mapping the attributes to the Nancy route by name. You really only need to specify either one.
As a future thing, we can probably make it so it does override the path if a mapping was found by name (or at least clean up the bad examples that show both at the same time).
However, you do have a valid problem - I created #168 to fix this issue. It will remove the type parameters from the swagger paths.
Expected Behavior
When I specify the Name and custom Path parameters in the Route() attribute both are used to generate the swagger file
Actual Behavior
When Name is specified the custom Path is ignored.
Steps to Reproduce the Problem
Specifications
I think the problem is in the code in Nancy.Swagger.Annotations / RouteId.Create() method, if the code
was modified to do without the
else
keyword intoit would work as expected
The text was updated successfully, but these errors were encountered: