This is a sample project designed to learn how to build and work with RESTful APIs using ASP.NET.
- Clone the repository with the application:
git clone https://github.com/yourlx/RestAPIHardwareShop- Navigate to the
srcfolder:
cd src-
Make sure that you have .NET 8 SDK and runtime installed. Also, ensure that you have a PostgreSQL instance (local or in a Docker container) running on the same port defined in appsettings.json, or change it to your preferred port.
-
Run the application:
dotnet run --project HardwareStore.WebApi- Verify that the application is running.
-
Make sure that you have Docker (and Docker Compose) installed.
-
Build the Docker image and run the containers using Docker Compose:
docker-compose up- Ensure that the containers are running using the
docker pscommand or Docker Desktop.
To interact with the API, you can use tools like curl, Postman, or the built-in Swagger UI. The Swagger documentation
should be available at http://localhost:8080/swagger/index.html.
Example:
- Get all products:
GET /api/v1/products- Create a new product:
POST /api/v1/products
{
"name": "Wooden Chair",
"category": "Furniture",
"price": 15,
"availableStock": 100,
"supplierId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}This repository code is under MIT License. See LICENSE file for more info.