• Stars
    star
    296
  • Rank 140,464 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A set of extensions and helpers for working with ASP.NET Core Minimal APIs.

MinimalApis.Extensions

A set of extensions and helpers that extend the functionality of ASP.NET Core Minimal APIs.

Installation

Nuget

NuGet Releases

This package is currently available from nuget.org:

> dotnet add package MinimalApis.Extensions

CI Builds

If you wish to use builds from this repo's main branch you can install them from this repo's package feed.

  1. Create a personal access token for your GitHub account with the read:packages scope with your desired expiration length:

    image

  2. At the command line, navigate to your user profile directory and run the following command to add the package feed to your NuGet configuration, replacing the <GITHUB_USER_NAME> and <PERSONAL_ACCESS_TOKEN> placeholders with the relevant values:

    ~> dotnet nuget add source -n GitHub -u <GITHUB_USER_NAME> -p <PERSONAL_ACCESS_TOKEN> https://nuget.pkg.github.com/DamianEdwards/index.json
  3. You should now be able to add a reference to the package specifying a version from the repository packages feed

  4. See these instructions for further details about working with GitHub package feeds

Getting Started

  1. Install the NuGet package into your ASP.NET Core project:
    > dotnet add package MinimalApis.Extensions
  2. .NET 6.0 projects only In your project's Program.cs, call the AddEndpointsMetadataProviderApiExplorer() method on builder.Services to enable enhanced endpoint metadata in ApiExplorer:
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddEndpointsMetadataProviderApiExplorer(); // <-- Add this line in .NET 6.0 projects
    builder.Services.AddSwaggerGen();
    ...
  3. Update your Minimal APIs to use the filters, binding, and result types from this library, e.g.:
    app.MapPut("/todos/{id}", async Task<Results<NotFound, NoContent>> (int id, Todo todo, TodoDb db) =>
    {
        var existingTodo = await db.Todos.FindAsync(id);
    
        if (existingTodo is null)
            return TypedResults.NotFound();
    
        existingTodo.Title = todo.Title;
        existingTodo.IsCompleted = todo.IsCompleted;
    
        await db.SaveChangesAsync();
    
        return TypedResults.NoContent();
    })
    .WithParameterValidation();

What's Included?

This library provides types that help extend the core functionality of ASP.NET Core Minimal APIs in the following ways:

  • Enhanced parameter binding via IParameterBinder and Bind<TValue>, Body<TValue>, JsonFormFile, and others
  • Extra result types available via Results.Extensions including PlainText, Html, and UnsupportedMediaType
  • For .NET 7.0 apps, an endpoint filter that validates route handler parameters and auto-responds with validation problem if validation fails
  • Poly-filling of .NET 7.0 features for use in .NET 6.0 projects including:
    • Typed IResult objects for easier unit testing (available via TypedResults) including the IStatusCodeHttpResult, IContentTypeHttpResult, and IValueHttpResult interfaces
    • Automatic population of detailed endpoint descriptions in Swagger/OpenAPI via the ability for input and result types to populate endpoint metadata via IEndpointParameterMetadataProvider and IEndpointMetadataProvider
    • Union IResult return types via Results<TResult1, TResultN> that enable route handler delegates to declare all the possible IResult types they can return, enabling compile-time type checking and automatic population of all possible responses in Swagger/OpenAPI from type information

Sample Projects

TodoApis.Dapper

An example Todos application using ASP.NET Core Minimal APIs and the Dapper library for data storage in SQLite.

MinimalApis.Examples

Contains small examples for other types in this library.

MinimalApiPlayground

Shows many examples of using the types in this library along with other things related to ASP.NET Core Minimal APIs.

More Repositories

1

MinimalApiPlayground

A place I'm trying out the new ASP.NET Core minimal APIs features.
C#
654
star
2

MiniValidation

A minimalist validation library for .NET built atop the existing features in `System.ComponentModel.DataAnnotations` namespace
C#
339
star
3

TagHelperPack

A set of useful, and possibly opinionated, Tag Helpers for ASP.NET Core
C#
338
star
4

RazorSlices

Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor.
HTML
315
star
5

BlazorIdentity

An exploration of recreating the ASP.NET Core Identity UI functionality in Blazor components.
C#
135
star
6

aspnet5-workshop

ASP.NET 5 workshop
106
star
7

TagHelperStarterWeb

ASP.NET 5 Starter Web project template converted to use Tag Helpers
JavaScript
80
star
8

RazorPagesSample

Examples of various ways to build simple CRUD pages using ASP.NET Core Razor Pages (coming in ASP.NET Core 2.0).
C#
77
star
9

aspnetcore-workshop

ASP.NET Core
C#
71
star
10

PiDnx

A sample DNX app for running on Windows 10 IoT Core on Raspberry Pi 2
C#
61
star
11

NDCLondon2013

Demos from my talks at NDC London 2013
JavaScript
55
star
12

AspNetCoreDevJwts

Experimenting with development environment scenarios for JWT authentication.
C#
42
star
13

Nanorm

A tiny data-access helper library for ADO.NET. Linker and native AOT friendly.
C#
41
star
14

AspNetCorePathAuthorization

A middleware to enable path-based authorization in an ASP.NET Core application.
C#
38
star
15

TrimmedTodo

An app to try out trimming stuff in .NET 7
C#
34
star
16

grunt-tsng

A TypeScript pre-processor for AngularJS
JavaScript
29
star
17

MinimalRazorComponents

An exploration of allowing returning rendered Razor Components (aka Blazor Components) from ASP.NET Core Minimal API endpoints.
C#
27
star
18

SignalR-MoveShapeDemo

A simple demo app I use when giving talks on SignalR
JavaScript
21
star
19

KeyTips-jQuery-Plugin

The KeyTips plugin for jQuery (formerly the Access Key Highlighter plugin) provides various options for highlighting access keys on web forms when the user presses their browser's access key shortcut key, e.g. Alt in Internet Explorer and Safari, Shift+Alt in Firefox.
JavaScript
21
star
20

Unobtrusive-jQuery-UI

Unobtrusive wire-up of jQuery UI features using data-ui-* attributes on target elements.
JavaScript
19
star
21

AspNetCoreClientLibManagement

Examples of different techniques for management of client libraries (i.e. JS/CSS libraries/frameworks) to ASP.NET Core projects.
HTML
18
star
22

i18nStarterWeb

ASP.NET 5 Starter Web project template converted to use proposed i18n/l10n system
JavaScript
16
star
23

vNextBowerGrunt

A demonstration of an approach for integration of Bower and Grunt into an ASP.NET vNext project.
JavaScript
16
star
24

dotnetConf2014

Demos from my dotnetConf 2014 SignalR talk http://channel9.msdn.com/Events/dotnetConf/2014/SignalR
JavaScript
15
star
25

SystemWebSdk

Exploration of using new .NET SDK-style projects with ASP.NET (System.Web) projects
JavaScript
15
star
26

SignalR-2.x-demo

Demos for SignalR 2.0 and upcoming 2.x releases
JavaScript
14
star
27

BlazingPageHead

Example of Blazor components for managing page head content.
HTML
13
star
28

Ignite2022

Demos for talk at MS Ignite 2022 with David Fowler
C#
12
star
29

YouTubePlaylistCopier

A one-page ASP.NET Core site that allows for copying items from one YouTube playlist to another.
C#
11
star
30

ndcoslo2016

Demos for NDC Oslo 2016
C#
11
star
31

TrackDirty-jQuery-Plugin

The TrackDirty plugin for jQuery tracks changes to form fields. When changes are detected, the field's class name is updated so as to allow styling. A callback function can be passed which will be called when a field is marked dirty. You can also query dirty fields using the added ":dirty" pseudo class.
JavaScript
11
star
32

aspConf2012

Demo code from talks at aspConf2012
JavaScript
10
star
33

AspNetCoreVbHybrid

Example of ASP.NET Core application with logic written in Visual Basic
C#
8
star
34

WebFormsModelBindingExtensions

Sample extensions for ASP.NET Web Forms Model Binding
C#
8
star
35

RazorPagesLocalization

Sample of fixed Razor Pages localization in ASP.NET Core 2.0.0 application
C#
7
star
36

RealTimeEntityFramework

Some ideas for real-time extensions to Entity Framework
C#
7
star
37

MusicStore

JavaScript
6
star
38

SimpleMvcHack

Some hacky ideas for simplifying MVC for page-focused scenarios.
C#
6
star
39

CookieConsentUI

Example cookie consent UI for ASP.NET Core project templates, coming in ASP.NET Core 2.1
C#
6
star
40

dotnet-new2

A .NET Core CLI command to create new .NET Core projects using templates installed via NuGet packages.
C#
5
star
41

jQueryVsDocBuilder

Utility for creating jQuery vsdoc files for Visual Studio IntelliSense
JavaScript
4
star
42

GittR

Simple issue management board for GitHub projects with real-time updating using ASP.NET SignalR.
JavaScript
4
star
43

UrlRewriteToPublic

Use URL Rewrite in IIS to only serve documents from /public folder
C#
3
star
44

MoveShapeCore

Move Shape for ASP.NET Core SignalR
JavaScript
3
star
45

Northwind

Northwind packages for Entity Framework Code First and VS11 Database projects
3
star
46

UnauthorizedApis

Exploration of potential change to ASP.NET Core behavior for what happens when accessing unauthorized API endpoints.
C#
3
star
47

CustomCultureExample

Demonstrates the issue of trying to localize for custom cultures in .NET Core/.NET 5+ projects.
HTML
3
star
48

AspireStarterDb

C#
3
star
49

MusicStoreSpa

2
star
50

BlazorFormFun

Reproducing patterns, etc. with new Blazor form handling in ASP.NET Core 8
CSS
2
star
51

HeritageTemplates

It's the .NET templates the way you remember them.
C#
2
star
52

AngleBracketsSpring2013

Deoms from my presentations at AngleBrackets/DevIntersections Spring 2013
JavaScript
2
star
53

RazorPages

C#
1
star
54

RazorFlushing

Examples of preemptive flushing from ASP.NET Core Razor
C#
1
star