Nancy.Swagger icon indicating copy to clipboard operation
Nancy.Swagger copied to clipboard

Parameter types are not removed from route path strings

Open provegard opened this issue 4 years ago • 0 comments

Expected Behavior

A typed parameter in a Nancy route is included without type in a route path in swagger.json.

Actual Behavior

The parameter type remains in the route path in swagger.json.

Steps to Reproduce the Problem

  1. Use a Nancy route with typed parameter like /something/{id:guid}
  2. Generate swagger.json
  3. Inspect the route path, it is /something/{id:guid}

Analysis

SwaggerRouteData contains a properly sanitized Path property, but it appears that the actual route path being used is the key of the dictionary returned by ISwaggerMetadataProvider.RetrieveSwaggerPaths, and that is the raw route path.

My workaround in a custom metadata provider:

    protected override IDictionary<string, SwaggerRouteData> RetrieveSwaggerPaths(NancyContext context)
    {
        var result = base.RetrieveSwaggerPaths(context);
        return result.Values.ToDictionary(rd => rd.Path);
    }

Specifications

  • Version: 2.2.59-alpha
  • Project: ?
  • Platform: .NET Core 3.0
  • Subsystem: ?

provegard avatar Jun 12 '20 08:06 provegard