What im trying to do is send a PATCH call to an endpoint which has route params but also required headers and no body.
public class TestRequest
{
[FromHeader("x-correlation-id")]
public Guid CorrelationId { get; set; }
[BindFrom("EntityId")]
public Guid EntityId { get; set; }
}
public sealed class TestEndpoint : Endpoint<TestRequest>
{
public override void Configure()
{
Patch("{EntityId}/fulfill");
}
public override async Task HandleAsync(TestRequest req, CancellationToken cancellationToken)
{
await SendOkAsync(cancellationToken);
}
}
The above displays the 2 properties in Swagger UI but when i call it i get 415 Unsupported Media Type which as i understand is returned because the FastEndpoints Endpoint<T>
sends a body even though its empty. I can verify this if i manually send the properties as the route param and header accordingly and set the Content-type: application/json
header which in turn returns a JsonSerializer error because the body is null and not in a json format.
I have also tried with EndpointWithoutRequest
but this does not take any model as a request therefore the CorrelationId
prop cannot be set and i cannot find any way to set it in the endpoint.
What i would like to find is a way to display all the header properties and the route params in SwaggerUi and be able to send a simple curl with
curl -X 'PATCH' \
'.../72423509-c29b-4735-862a-9ebdd0489c05/fulfill' \
-H 'x-correlation-id: 72423509-c29b-4735-862a-9ebdd0489c05'
The answer was given by the creator of FE https://github.com/FastEndpoints/FastEndpoints/issues/492#issuecomment-1740210893
You'd have to clear the default accepts
metadata
public override void Configure()
{
Description(x => x.Accepts<ToggleSettingRequest>());
}