Skip to content

[Bug]: Parameter description breaking change in v6.8.0 #3084

@michael-wolfenden

Description

@michael-wolfenden

Given the following

using Microsoft.OpenApi.Models;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();
app.UseSwagger();

app.MapGet("/test", (string filter) => "ok")
   .WithOpenApi(o => o
        .WithParameterDescription("filter", "Description for filter querystring parameter")
    );

app.Run();

public static class Extensions
{
    public static OpenApiOperation WithParameterDescription(this OpenApiOperation openApiOperation, string parameterName, string description)
    {
        var openApiParameter = openApiOperation.Parameters.Single(p => p.Name.Equals(parameterName, StringComparison.OrdinalIgnoreCase));
        openApiParameter.Description = description;

        return openApiOperation;
    }
}

Swashbuckle.AspNetCore v6.7.3 generates the parameter with a description

{
    "parameters": [
        {
            "name": "filter",
            "in": "query",
            "description": "Description for filter querystring parameter",
            "required": true,
            "schema": {
                "type": "string"
            }
        }
    ]
}

Swashbuckle.AspNetCore v6.8.0 omits the description

{
    "parameters": [
        {
            "name": "filter",
            "in": "query",
-           "description": "Description for filter querystring parameter",
            "required": true,
            "schema": {
                "type": "string"
            }
        }
    ]
}

@jgarciadelanoceda I suspect this is due to changes introduced in #3059

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions