A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/scalar/scalar/issues/3898 below:

Scalar not replacing the "version" parameter when using Minimal API Versioning and Net 9 OpenApi · Issue #3898 · scalar/scalar · GitHub

What happens?

Using Net 9 I have the following Minimal API endpoint:

builder.MapGet("v{version:version}/countries", async ([FromServices] IMediator mediator, CancellationToken cancellationToken) => {

  CountryGetMessage.Request request = new();

  Outcome<List<CountryGetMessage.Response>> outcome = await mediator.Send(request, cancellationToken);

  if (outcome.Status == Status.Success)
    return Results.Ok(outcome.Payload);

  return Results.BadRequest();

}).WithName("Country.Get")
  .WithApiVersionSet(versions)
  .MapToApiVersion(1.0);

I am using Net 9 OpenApi, Scalar and AspNet Api Versioning.

In Program file I have:

  WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

  builder.Services.AddApiVersioning(x => {
    x.DefaultApiVersion = new ApiVersion(1, 0);
    x.ReportApiVersions = true;
    x.RouteConstraintName = "version";
    x.UnsupportedApiVersionStatusCode = 400;
  });

  builder.Services.AddEndpoints(typeof(Program)); // Helper to add the Minimal API Endpoints

  builder.Services.AddOpenApi();

  ApiVersionSet versions = application.NewApiVersionSet().HasApiVersion(1.0).Build();

  application.MapEndpoints(versions); // Helper to map the Minimal API Endpoints

  application.MapOpenApi();
  application.MapScalarApiReference();

When I access "https://localhost:5001/v1.0/countries" I get a 200 OK response with the following:

:status: 200
api-supported-versions: 1.0
Content-Type: application/json; charset=utf-8

But when I check the endpoint in Scalar the version is not replaced by 1.0:

What did you expect to happen?

I would expect that Scalar would automatically replace the version value by 1.0:

As is the one in the endpoint definition:

}).WithName("Country.Get")
  .WithApiVersionSet(versions)
  .MapToApiVersion(1.0);
OpenAPI Document

https://sandbox.scalar.com/e/4dHv0


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4