You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-59Lines changed: 68 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,30 +29,30 @@ public partial class GreetingWebApiEndpoint
29
29
```
30
30
31
31
## Key Features
32
-
-[x] Structured way of building WebApiEndpoints using [minimal apis](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0)
33
-
-[x][Easy setup](#easy-setup)
34
-
-[x] Full support and built on top of [minimal apis](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0)
35
-
-[x] Full support for OpenApi
36
-
-[x] Full support for Api Versioning
37
-
-[x] Full support for [TypedResults](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.typedresults?view=aspnetcore-7.0)
-[x] individual REST method(s) - as per standard minimal apis
44
-
-[x][Supports uploading file(s) with additional JSON payload](#uploading-files-with-additional-json-payload)
45
-
-[x] Built in [sandbox runner](#sandbox-runner) with full [TypedResults support](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.typedresults?view=aspnetcore-7.0), catching unhandled exceptions and returning a [ProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.problemdetails?view=aspnetcore-7.0) response
46
-
-[x] Autodiscovery of WebApiEndpoint(s), based on Source Generators
47
-
-[x][Roslyn Analysers](#roslyn-analysers) to help build your WebApiEndpoint(s) and ensure best practices
48
-
-[x] Enables Vertical Slice Architecture, giving you the ability to add new features without changing existing code
49
-
-[x] Built on dotnet 8
50
-
-[x] Built in use of [ProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.problemdetails?view=aspnetcore-7.0) support
51
-
-[x] Built in [extendable GlobalExceptionHandler](#extendable-globalexceptionhandler)
52
-
-[x] Developer friendly, with a simple API and with a full suite of samples and tests
-✅ Structured way of building WebApiEndpoints using [minimal apis](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0)
33
+
-✅[Easy setup](#easy-setup)
34
+
-✅ Full support and built on top of [minimal apis](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0)
35
+
-✅ Full support for OpenApi
36
+
-✅ Full support for Api Versioning
37
+
-✅ Full support for [TypedResults](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.typedresults?view=aspnetcore-7.0)
-✅ individual REST method(s) - as per standard minimal apis
44
+
-✅[Supports uploading file(s) with additional JSON payload](#uploading-files-with-additional-json-payload)
45
+
-✅ Built in [sandbox runner](#sandbox-runner) with full [TypedResults support](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.typedresults?view=aspnetcore-7.0), catching unhandled exceptions and returning a [ProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.problemdetails?view=aspnetcore-7.0) response
46
+
-✅ Autodiscovery of WebApiEndpoint(s), based on Source Generators
47
+
-✅[Roslyn Analysers](#roslyn-analysers) to help build your WebApiEndpoint(s) and ensure best practices
48
+
-✅ Enables Vertical Slice Architecture, giving you the ability to add new features without changing existing code
49
+
-✅ Built on dotnet 8
50
+
-✅ Built in use of [ProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.problemdetails?view=aspnetcore-7.0) support
51
+
-✅ Built in [extendable GlobalExceptionHandler](#extendable-globalexceptionhandler)
52
+
-✅ Developer friendly, with a simple API and with a full suite of samples and tests
class entire-api,specific-version-api,endpoint-configure,endpoint-build,minimal-api blackText
272
272
```
273
273
274
-
### Configuring the entire API
274
+
### 1. Configuring the entire API
275
275
The entire API can be configured to set global parameters. This is an ideal place to set configurations such as:
276
276
- Global route prefix: This is a common prefix for all routes in your API.
277
277
- Global authorization: This is where you can set the authorization required for all endpoints in your API. Remember to use the AllowAnonymous attribute on individual WebApiEndpoints that should not be secured, such as a Login endpoint.
@@ -297,7 +297,7 @@ public class GlobalWebApiEndpoint : IGlobalWebApiEndpoint
297
297
```
298
298
**See *[GlobalWebApiEndpoint](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/GlobalWebApiEndpoint.cs)* in sample project**
299
299
300
-
### Configuring a specific API version
300
+
### 2. Configuring a specific API version
301
301
In the context of API development, it's often necessary to configure specific API versions. This configuration can include aspects such as:
302
302
- Authorization specific to the API version: This is where you can set the authorization required for all endpoints in a specific API version. Don't forget to use the AllowAnonymous attribute on individual WebApiEndpoints that should not be secured, such as a Login endpoint.
303
303
@@ -328,6 +328,15 @@ public class WebApiVersionEndpoint3_0a : IWebApiVersionEndpoint
328
328
329
329
**Remember, the configuration of specific API versions is a crucial aspect of maintaining and managing your APIs, especially when dealing with different versions of the same API. It allows you to control the behavior of each version independently, providing flexibility and control over your API's functionality.**
330
330
331
+
### 3. WebApiEndpoint 'Configure' Method
332
+
See [here](#configure)
333
+
334
+
### 4. WebApiEndpoint 'Build' Method
335
+
See [here](#build).
336
+
337
+
### 5. Individual Minimal API
338
+
See [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/overview?view=aspnetcore-8.0).
339
+
331
340
## Sandbox runner
332
341
The Sandbox Runner is a feature that provides a set of comprehensive extension methods to execute your code in a controlled environment or "sandbox".
-[x] A basic blog CRUD implementation - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Blog/BlogWebApiEndpoint.cs)
544
-
-[x] The *ToDo* sample from Damian Edwards [here](https://github.com/DamianEdwards/TrimmedTodo) - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Todo/TodoApiWebApiEndpoint.cs)
-[x] EndpointFilter on a specific WebApiEndpoint - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Features/EndpointFilterWebApiEndpoint.cs)
-[x][Security](#security-example) with a basic JWT example on a specific WebApiEndpoint - [login link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Security/SecurityLoginWebApiEndpoint.cs), [protected link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Security/SecurityProtectedWebApiEndpoint.cs)
-[x] Configuring setting for entire API - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/GlobalWebApiEndpoint.cs)
559
-
-[x] Configuring setting for specific API version - [link v3, v1.20-beta](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/WebApiVersionEndpoint3_0.cs)
552
+
-✅ A basic blog CRUD implementation - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Blog/BlogWebApiEndpoint.cs)
553
+
-✅ The *ToDo* sample from Damian Edwards [here](https://github.com/DamianEdwards/TrimmedTodo) - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Todo/TodoApiWebApiEndpoint.cs)
-✅ EndpointFilter on a specific WebApiEndpoint - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Features/EndpointFilterWebApiEndpoint.cs)
-✅[Security](#security-example) with a basic JWT example on a specific WebApiEndpoint - [login link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Security/SecurityLoginWebApiEndpoint.cs), [protected link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/Security/SecurityProtectedWebApiEndpoint.cs)
-✅ Configuring setting for entire API - [link](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/GlobalWebApiEndpoint.cs)
568
+
-✅ Configuring setting for specific API version - [link v3, v1.20-beta](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/WebApiVersionEndpoint3_0.cs)
2. In the Swagger UI, go to the 'Security' 'Login' endpoint
567
576
3. Set the following
568
-
Username = user1
569
-
Password = password1
570
-
SetPermissions = true
571
-
SetClaim = true
572
-
SetRole = true
577
+
-Username = user1
578
+
-Password = password1
579
+
-SetPermissions = true
580
+
-SetClaim = true
581
+
-SetRole = true
573
582
4. Copy the value returned without double quotes.
574
583
5. Go to the 'Security' 'Protected' endpoint
575
584
6. Click on the padlock
@@ -707,8 +716,8 @@ public partial class OpenApiVersionV1WebApiEndpoint
707
716
**See*[OpenApiVersionV1WebApiEndpoint.cs](https://github.com/futurum-dev/dotnet.futurum.webapiendpoint.micro/blob/main/sample/Futurum.WebApiEndpoint.Micro.Sample/OpenApi/OpenApiVersionV1WebApiEndpoint.cs)* in sample project**
708
717
709
718
## Troubleshooting
710
-
### *No operations defined in spec!*
711
-
IfyouseethiserrorintheSwaggerUI-Nooperationsdefinedinspec!-thenitmeansyouhaven't added any WebApiEndpoint projects. You need to do this for each project, including the project that contains the *program.cs* file. See [this](#addwebapiendpointsfor-per-project-containing-webapiendpoints) section for more details.
719
+
### No operations defined in spec!
720
+
IfyouseethiserrorintheSwaggerUI-*Nooperationsdefinedinspec!*-thenitmeansyouhaven't added any WebApiEndpoint projects. You need to do this for each project, including the project that contains the *program.cs* file. See [this](#addwebapiendpointsfor-per-project-containing-webapiendpoints) section for more details.
712
721
713
722
### If there are Rest Api's that are not being picked up
714
723
IfthereareRestApi's that are not being picked up, then it means you haven'taddedaWebApiEndpointprojects. Youneedtodothisforeachproject, includingtheprojectthatcontainsthe*program.cs*file. See [this](#addwebapiendpointsfor-per-project-containing-webapiendpoints) sectionformoredetails.
0 commit comments