AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Update Web API Tutorials to Minimal APIs

Open mikekistler opened this issue 5 months ago • 7 comments

In the Tutorials section of the ASP.NET Core docs, there are currently 6 tutorials, 5 of which create a controllers-based app and only one creates a Minimal API app.

Image

These tutorials should be updated so that all or nearly all of them demonstrate the target feature in a Minimal API app.

Specifically, the "Create a controller-based web API with ASP.NET Core" can remain but the other four Tutorials in the "Controller-based APIs" section should be converted to use Minimal APIs.

In addition, the "Controller-based APIs" and "Minimal APIs" sections should be dropped so that all tutorials just appear under "APIs", and the single controller-based tutorial should appear last in the list.

[The following was added by wadepickett] Related to: #35742

mikekistler avatar Jul 10 '25 22:07 mikekistler

@mikekistler, good point, these are needed. Just to verify before paving over:

I can create new topics for those 4 subjects in the Minimal API directory that are for Minimal API. At the same time we could keep the 4 that are in the Controller-based API directory.

Is that better, or do you want to get rid of those four controller-based tutorials anyway?

wadepickett avatar Jul 17 '25 01:07 wadepickett

I would like to remove the 4 controller-based tutorials. We could do this just for .NET 10 and later ... leave the tutorials for older versions. I think that would be okay.

mikekistler avatar Jul 17 '25 03:07 mikekistler

@wadepickett Could someone sort then in one doing the TOC a little bit? the Tutorial for minimal api is listed twice just with different naming in the toc

Image

DevTKSS avatar Jul 18 '25 10:07 DevTKSS

My German is a little rusty (I'm guessing that's German) ;-), but I think I can make it out.

I'd like the Tutorials section to look like this:

v Tutorials
    > Web apps
    v APIs
        Create a minimal web API
        Web API with Mongo DB
        Web API with JavaScript
        Backend for mobile
        Publish to Azure API Management
        Create a controller-based web API
    > Real-time web apps

With all the articles except the last one using Minimal APIs.

And I'd like the top-level APIs section to look like this:

v APIs
    Overview
  v Tutorials
        Create a minimal web API
        Web API with Mongo DB
    Minimal APls quick reference
    WebApplication and WebApplicationBuilder
    Route Handlers
    Parameter binding
    Handle JSON Patch requests
    Create responses
    Filters
    Unit and integration tests
    Middleware
    Handle errors
    Authentication and authorization
  v OpenAPI
        Overview
        Generate OpenAPI documents
        Include OpenAPI metadata
        Customize OpenAPI documents
        Use OpenAPl documents
  v Test with HttpRepl
        Overview
        Telemetry
  v Controller-based APIs 
        Overview
        Create a web API with controllers
        Action return types
        Format response data
        Custom formatters
        Analyzers
        Conventions
  > Real-time apps

Note:

  • All the articles currently under Minimal APIs move up to be under APIs
  • Content from the Handle Errors article currently under Controllers should be merged with Handle Errors currently under Minimal APIs to produce the new Handle Errors under APIs
  • Handle JSON Patch requests is move from under Controllers to under APIs -- that will need to be updated to cover both Minimal APIs and controllers
  • Test with HttpRepl is moved from under Controllers to under APIs
  • I've only listed two of the five tutorials about Minimal APIs in its Tutorials section. That's following the pattern of the current docs where only two of the five tutorials for controllers we listed, but we could include all five if desired.

Hope this is clear now.

mikekistler avatar Jul 18 '25 14:07 mikekistler

@mikekistler would suggest some things as I for example are developing not with Blazor or Maui, then on the Uno Platform Codebase, which allowes us to not just use mobile and webAssembly then also Deskop and Windows etc.

  • The Tutorials can have Razor and so on, but should show also, how to use a (for example) WebAssembly App which might be running on the server, to provide the Pages we are showing to our users. like in a minimal api with Identity needcase (nowerdays an essential task) that would be a login screen. I only found html or cshtml (Razor?) but even while absolutly respecting, that microsoft might see them as competitor, I would hope to someone could just show a basical way to connect a WebAssembly to a asp net core server to use that as trusted UI + connect that properly for secure reasons like CORS and Antiforgery etc.
  • The Identity Topic in the asp net core docs is extremly centralized to MS Identity (makes of course sense for promo ;) ) but just like there are tutorials about jwt, openid and a bit of cookies, I am absolutly missing any guidiance for using the oAuth Extension, which I would like to integrate into my minimal API! that area is all I found to identity, without entra so please tell me, I just missed it or ist just not properly linked in the TOC... this here is the whole minimal api doc about authentication which is (sorry to be so direct): absolutly not helpful if you want to get to a working point when your targeted external api you may need data from, requires you to use oauth2...
  • Found not one chapter about defining extensions for builder.Services.AddMyServices() only for Middleware, but thats the step after you builded that step. May someone add a link if there is a doc about this?
  • on the topic with the ports, it would be great if someone would add a link to this here for the basic config of ports with asp net core
  • Coming back to the integrating Wasm, I would refer also to this doc page about Parameter Biding where I am at least (beeing a bloody beginner with asp net ;) ) completly lost on how to do connect that properly in my asp net server maybe. for dotnet runtime, we are required to use cors and antiforgery and so on, the issue to that should be known for a while, so I would be very interested in more details of how to set this up properly using minimal api!

Hope you may take this idea and suggestion collection into consideration 👍 Let me know, if you see parts, where I can help you enhancing those things, maybe I can learn something on the way :)

DevTKSS avatar Jul 18 '25 16:07 DevTKSS

@guardrex is this getting started and minimal api not what you are on right now?

DevTKSS avatar Jul 22 '25 09:07 DevTKSS

That's right, @DevTKSS, I'm only working on the basic getting started experience, and we won't have Minimal APIs in that article.

guardrex avatar Jul 22 '25 10:07 guardrex