Simple CRUD API from Jeffrey Fritz. It supports DbContext and an API based on JSON file. The JSON file is a good alternative to JSON Server as it will not pull down 100s of node modules that I actually dont understand.
The value of this Instant APIs is I can bring up my BFF in minutes and focus my time on building my front end application. The contract often changes as we build out the front end so if the BFF is flexible its a huge win.
See Jeffrey Fritz - Build Web APIs Instantly for your Web Application with ASP.NET Core 6
Another alternative package is Fast Endpoints (package) which would be well worth checking out.
Setup
- Create the project and install Fritz.InstantAPIs
1 | dotnet new web -o DemoApi -f net6.0 |
- Create the json file, example
db.json. At the time of writing this guids are not supported as the primary key #sad
1 | { |
- Update
Program.csas follows
1 | using Mock; |
- Run the app
1 | dotnet run |
Postman requests
Postman is the most popular API platform tool but you can use anything you like such as SoapUI.
You can then run postman requests
GET
1 | GET https://localhost:7203/products |
response 200
1 | [ |
POST
1 | POST https://localhost:7203/products |
response 200
1 | { |
GET {id}
1 | GET https://localhost:7203/products/5 |
response 200
1 | { |
DELETE {id}
1 | DELETE https://localhost:7239/customers/1 |
response 200
1 | OK |
Swagger
You can then also add swagger support, this would probably be more useful if you are using the Dbcontext and plan to use the API for more than just local development of your front end application.
1 | using Mock; |