Skip to content

Parameter types are not removed from route path strings #180

@provegard

Description

@provegard

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: ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions