I configure FastEndpoints and Scalar as follows
using FastEndpoints;
using Scalar.AspNetCore;
builder.Services.AddOpenApi();
builder.Services.AddFastEndpoints();
var app = builder.Build();
app.MapOpenApi();
app.MapScalarApiReference(options =>
{
options.WithSidebar(false);
options.ShowSidebar = true;
});
app.UseFastEndpoints();
app.Run();
After which I create and configure the endpoint as follows
namespace Test.Endpoints
{
public class TestRequest
{
public int ParentId { get; set; }
public int ChildId { get; set; }
}
public class TestResponse
{
public string Text { get; set; }
}
public class TestEndpoint : Endpoint<TestRequest, TestResponse>
{
public override void Configure()
{
Get("/RestAPI/{ParentId}/Child{ChildId}");
AllowAnonymous();
}
public override Task HandleAsync(TestRequest request, CancellationToken ct)
{
var response = new TestResponse { Text = $"Hello from FastEndpoints {request.ChildId}." };
return SendAsync(response, cancellation: ct);
}
}
}
Scalar generates the following documentation
- I don't understand why Scalar describes the parameters in the request body if it is a Get request.
Then if I use the form to test the query
Scalar does not pass Query parameter
2 How should Fast Endpoints be configured so that correct documentation is generated and Scalar can send requests correctly?
UPD.
Okay, I'll try to sort out this authorization error.
But still, I have one question left.
- How should the endpoint be configured so that query parameters in the documentation are correctly displayed not in the Variables section, but in the Query section and are passed with a question mark?
With this configuration
Get("/RestAPI/{ParentId}/Parameters{ChildId}");
I get this documentation GET request with Body !
and such testing form