4

This link has amazing documentation on how to add documentation into swagger UI.

The problem with that link is that it does not show how to do so using minimal APIs. There are a lot of places on the internet that show how to add documentation to swagger UI such as this other question from stack overflow but I have not been able to do so using minimal apis.

  1. This video shows how to create a simple project using minimal apis:

  2. This video shows how to make it unit testable

  3. This last video shows how to add validation, authorization and authentication

Has anyone managed to add custom documentation into swagger UI using minimal APIs?

1

1 Answer 1

4

According to Microsoft documentation there is support for minimal api.

app.MapGet("/api/todoitems/{id}", async (int id, TodoDb db) =>
         await db.Todos.FindAsync(id) 
         is Todo todo
         ? Results.Ok(todo) 
         : Results.NotFound())
   .Produces<Todo>(StatusCodes.Status200OK)
   .Produces(StatusCodes.Status404NotFound);

More info you can find here:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0#openapi

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.