Questions tagged [minimal-apis]

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Minimal APIs were introduced in ASP.NET Core 6 and are architected to create HTTP APIs with minimal dependencies. They are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core.

Answers for many question can be found in the documentation.

236 questions
1
vote
0 answers

Minimal API swagger doesn't generate/discover anything when async

Building a test app with .NET 7 minimal api swagger for learning purposes. Mostly a default project at this point. What has me confused is if I convert what you see below to not be async then Swagger properly generates/discovers the facilities…
FrankTheDank
  • 197
  • 1
  • 2
  • 9
1
vote
0 answers

Minimal API: the api doesnt load because its too big?

I want integrate Flutter with an ASP.NET API. the problem is when I create minimal API, the JSON I retrieved from MapGet taken too long to load, is the limit for how big can minimal api load? this is my scheme [ { "id":…
user21497668
1
vote
2 answers

How do I get the incoming request body and the outgoing response body in ASP.NET Core middleware?

I'm writing some middleware for an ASP.NET Core 7 minimal API project. At this stage, I would just like to be able to read the request body being sent in, and then the response body that is being sent out, and dump them to the console. Reading the…
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1
vote
2 answers

.NET Core 6 minimal API with OpenApi - validate request against OpenApi schema

I'm working on a minimal API in .NET Core 6 with OpenApi support. I have a Resolution model defined like this: using System.ComponentModel.DataAnnotations; public struct Resolution { [Required, Range(1, 800)] public int W { get; set; } …
Fuczak
  • 330
  • 5
  • 10
1
vote
1 answer

Convert the model's fields as Dictionary in another model's field

I have this model: namespace SomeApp.Models { public class FirstModel { public int uid { get; set; } public string? id { get; set; } public string? firstname { get; set; } public string? lastname { get; set;…
Prosy Arceno
  • 2,616
  • 1
  • 8
  • 32
1
vote
1 answer

ASP.NET Core 7 Minimal API - Swagger doesn't start

We have a minimal API application, and whenever we start the app, we get a "Localhost not found" error instead of getting the Swagger interface. If we add the /swagger to the end of the URL, Swagger comes up fine. Are we missing something when…
John Swaringen
  • 731
  • 4
  • 11
  • 29
1
vote
0 answers

File size limit on .NET 7 Minimal Web API

So I have a little problem here, I wanted to port a .NET Core 2.1 web API to an ASP.NET Core web API with .NET 7. I need to be able to upload files larger than 50MB (up to 300MB, since it will include videos), but I cannot find any information for…
OverWorker
  • 11
  • 1
1
vote
2 answers

Minimal Web Api Not Returning Desired Result

I have created a minimal ASP.NET Core Web API project in Visual Studio. And then deploying this to Azure Web App Service to be able to 'GET' results remotely. Locally, the /weatherforecast sample data runs fine as well as the Azure SQL data,…
1
vote
2 answers

Error still occurs even after registering the required dependency, what is wrong?

The following code simulates the problem. I do register the dependency but errors still occur. using Microsoft.AspNetCore.Mvc; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSingleton(); var app =…
1
vote
1 answer

How to send a file to a client using a Minimal API?

I wish to send a file to an API client's GET request, but I'm getting an error: Body was inferred but the method does not allow inferred body parameters Here's what I've got: Dim sPath As String =…
InteXX
  • 6,135
  • 6
  • 43
  • 80
1
vote
1 answer

Minimal API add complex parameters into swagger UI

After defining the endpoint app.MapGet($"{baseRoute}/GetProducts", GetProductsAsync) .WithName("GetProducts") .Produces() .WithTags(Tag); With this async method to call implementation. private static async Task
1
vote
2 answers

Why does Results.Json special-case null (and can I get it to stop doing that)?

Consider the following minimal repro example using the default ASP.NET Core template: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); // Content-Type application/json, Body: true app.MapGet("/True", () =>…
Heinzi
  • 167,459
  • 57
  • 363
  • 519
1
vote
2 answers

Why `ardalis/CleanArchitecture` reference FastEndpoints but not it's own `ardalis/ApiEndpoints`

Just need a clarification. I was keen on referencing ApiEndpoints in one of my projects. But when I am browsing the ardalis/CleanArchitecture repo I noted it has been using FastEndpoints ref. The question is why they have deviated from their own…
1
vote
2 answers

How to get rid of code duplication for Minimal API's

I am trying to learn to effectively use Minimal API's. How can I reduce duplicate codes, how to create base Endpoint class and do the most job there? Especially, how to use Mediatr from a static reference and not put in every methods parameter? My…
Baran
  • 362
  • 2
  • 10
1
vote
1 answer

Error Deploying Asp.Net Minimal API (Top level statements) to lambda using CDK

I have a CDK solution with a stack etc and in the same solution i have created a ASP.NET minimal API Lambda project. When I deploy using the CDK I'm getting the ERROR: Internal Server Error When I check the logs I can see the Error: Error:…