Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/distantcam/endpointgenerator
Source Generator to help create minimal api endpoint mappings.
https://github.com/distantcam/endpointgenerator
csharp csharp-sourcegenerator dotnet roslyn source-generator
Last synced: 10 days ago
JSON representation
Source Generator to help create minimal api endpoint mappings.
- Host: GitHub
- URL: https://github.com/distantcam/endpointgenerator
- Owner: distantcam
- License: mit
- Created: 2023-12-24T05:51:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-03T08:07:50.000Z (7 months ago)
- Last Synced: 2024-07-08T09:22:45.167Z (7 months ago)
- Topics: csharp, csharp-sourcegenerator, dotnet, roslyn, source-generator
- Language: C#
- Homepage:
- Size: 130 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license
Awesome Lists containing this project
README
# EndpointGenerator
[![Build Status](https://img.shields.io/github/actions/workflow/status/distantcam/EndpointGenerator/build.yml)](https://github.com/distantcam/EndpointGenerator/actions/workflows/build.yml)
[![NuGet Status](https://img.shields.io/nuget/v/EndpointGenerator.svg)](https://www.nuget.org/packages/EndpointGenerator/)
[![Nuget Downloads](https://img.shields.io/nuget/dt/EndpointGenerator.svg)](https://www.nuget.org/packages/EndpointGenerator/)EndpointGenerator is a Roslyn Source Generator to add methods to call marked minimal api methods.
## Contents
* [NuGet packages](#nuget-packages)
* [Your code](#your-code)
* [What gets generated](#what-gets-generated)
* [How to use](#how-to-use)## NuGet packages
https://nuget.org/packages/EndpointGenerator/
### Your code
```cs
public static class Basic
{
[EndpointGenerator.EndpointBuilder]
public static void Simple(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder builder) =>
builder.MapGet("/simple", () => TypedResults.Ok("Hello World"));[EndpointGenerator.EndpointBuilder]
public static void Grouped(Microsoft.AspNetCore.Routing.RouteGroupBuilder builder) =>
builder.MapGet("/grouped", () => TypedResults.Ok("Hello World"));[EndpointGenerator.EndpointGroupBuilder("prefix")]
public static void GroupedWithPrefix(Microsoft.AspNetCore.Routing.RouteGroupBuilder builder) =>
builder.MapGet("/grouped", () => TypedResults.Ok("Hello World"));
}
```
snippet source | anchor### What gets generated
```cs
// The name will be "Map[AssemblyName]Endpoints"
public static IEndpointRouteBuilder MapEndpointGeneratorExampleEndpoints(this IEndpointRouteBuilder builder)
{
Basic.Simple(builder);
var group = builder.MapGroup("").WithName("Basic");
Basic.Grouped(group);
group = builder.MapGroup("prefix").WithName("Basic");
Basic.GroupedWithPrefix(group);
return builder;
}
```
snippet source | anchor### How to use
```cs
var builder = WebApplication.CreateBuilder();
var app = builder.Build();app.MapEndpointGeneratorExampleEndpoints();
app.Run();
```
snippet source | anchor