Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal API /3 #22941

Merged
merged 65 commits into from
Oct 25, 2021
Merged

Minimal API /3 #22941

merged 65 commits into from
Oct 25, 2021

Conversation

Rick-Anderson
Copy link
Contributor

@Rick-Anderson Rick-Anderson commented Aug 3, 2021

@Rick-Anderson Rick-Anderson marked this pull request as draft August 3, 2021 22:03
* Select the **Project** checkbox in the right pane and then select **Install**.
* Follow the preceding instructions to add the following packages:
* `Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore`
* `MinimalValidation`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want to show this in the tutorial? Do we @LadyNaggaga @DamianEdwards? Maybe we should show fluent validation instead?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't in the box yet so, let's remove them. @DamianEdwards am I wrong ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @davidfowl says we could decide to show how to use FluentValidation or I could do some work on MinimalValidation and release that as a 1.0 and we could use that. Or we don't talk about validation at all in the tutorial as it's not something we provide in the box today. We know people will ask about it but we also know putting things in the tutorial is in ways an implicit blessing/statement of what we recommend. Likely requires more thought/discussion.

@Rick-Anderson Rick-Anderson changed the title Minimal API /3 Double Draft: Minimal API /3 Aug 4, 2021

Examine the `app.MapPut("/todoitems/{id}", ...` method:

[!code-csharp[](min-web-api/samples/6.x/todo/Program.cs?name=snippet_put)]

This comment was marked as resolved.

This comment was marked as resolved.

@Rick-Anderson
Copy link
Contributor Author

Rick-Anderson commented Oct 18, 2021

EDIT I've decided to keep Swagger and the weather forecast controller, then remove them in the next step

@rafikiassumani-msft @davidfowl @LadyNaggaga @DamianEdwards I suggest for this onboarding tutorial I have then uncheck Enable OpenAPI support. Otherwise the generated code goes from 4 lines to 43 lines. I think we should focus on minimal APIs and refer them to Swagger in a follow up tutorial.

@Rick-Anderson
Copy link
Contributor Author

@rafikiassumani-msft I'm merging this at EOD unless you have changes. cc @LadyNaggaga

- No support for binding from forms. This includes binding <xref:Microsoft.AspNetCore.Http.IFormFile>. We plan to add support for `IFormFile` in the future.
- No built-in support for validation. i.e. <xref:Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IModelValidator>
- No support for [application parts](xref:mvc/advanced/app-parts) or the [application model](xref:mvc/controllers/application-model). There's no way to apply or build your own conventions.
- No built-in view rendering support. We recommend using Razor Pages for rendering views.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the razor pages article

@Rick-Anderson
Copy link
Contributor Author

@serpent5 please review on Monday but not before then.

@Rick-Anderson Rick-Anderson dismissed timheuer’s stale review October 23, 2021 00:23

Made requested changes and asked for new review last week

@Rick-Anderson
Copy link
Contributor Author

@rafikiassumani-msft @LadyNaggaga @captainsafia I'm merging this EOD Monday.

Copy link
Contributor

@serpent5 serpent5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you want me to turn down the verbosity for the next review. 😅

aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
## Differences between minimal APIs and APIs with controllers

- No support for filters: For example, no support for <xref:Microsoft.AspNetCore.Mvc.Filters.IAsyncAuthorizationFilter>, <xref:Microsoft.AspNetCore.Mvc.Filters.IAsyncActionFilter>, <xref:Microsoft.AspNetCore.Mvc.Filters.IAsyncExceptionFilter>, <xref:Microsoft.AspNetCore.Mvc.Filters.IAsyncResultFilter>, and <xref:Microsoft.AspNetCore.Mvc.Filters.IAsyncResourceFilter>
- No support for model binding. i.e. <xref:Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinderProvider>, <xref:Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder>. Support can be added with a custom binding shim.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support can be added with a custom binding shim.

Is there somewhere we can send the reader to learn more about what this means?

aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
-
## Use JsonOptions

The following code uses <xref:Microsoft.AspNetCore.Http.Json.JsonOptions>:
Copy link
Contributor

@serpent5 serpent5 Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of thoughts here:

  • The code that follows doesn't actually mention JsonOptions.
  • The section doesn't have much context. Should we call out that it's showing how to customise the JSON response, for example?

aspnetcore/tutorials/min-web-api.md Outdated Show resolved Hide resolved
Co-authored-by: Kirk Larkin <6025110+serpent5@users.noreply.github.com>
Rick-Anderson and others added 2 commits October 25, 2021 13:22
Co-authored-by: Kirk Larkin <6025110+serpent5@users.noreply.github.com>
@Rick-Anderson Rick-Anderson merged commit 95f4117 into main Oct 25, 2021
@Rick-Anderson Rick-Anderson deleted the minAPI/ra/3 branch October 25, 2021 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create minimal API tutorial
10 participants