最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Unable to configure Get request using FastEndpoints to describe query parameters into OpenApi (Scalar) documentation - Stac

programmeradmin3浏览0评论

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

  1. 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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论