Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inagoesit/products-api
A products API using ASP.NET Web APIs. For testing I used xUnit and Fluent Assertions.
https://github.com/inagoesit/products-api
api asp-net-core-web-api backend-api csharp dotnet fluentassertions openapi-specification xunit
Last synced: 2 days ago
JSON representation
A products API using ASP.NET Web APIs. For testing I used xUnit and Fluent Assertions.
- Host: GitHub
- URL: https://github.com/inagoesit/products-api
- Owner: InagoesIT
- Created: 2023-12-18T08:52:09.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-01-23T10:59:14.000Z (8 months ago)
- Last Synced: 2024-09-25T10:40:26.395Z (2 days ago)
- Topics: api, asp-net-core-web-api, backend-api, csharp, dotnet, fluentassertions, openapi-specification, xunit
- Language: C#
- Homepage:
- Size: 51.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Products API
## Overview
This project is a simple RESTful API for managing products, implemented using ASP.NET Web APIs. The task was provided by ChatGPT, and the requirements are outlined below.
## Task Requirements
1. **CRUD Operations using Repositories:**
- `READ` all products.
- `CREATE` a single product.
- `READ` a product by id.
- `UPDATE` an existing product by id.
- `DELETE` a product by id.2. **Implement Endpoints:**
- `GET /api/products`: Retrieve a list of products (using a hardcoded list for simplicity).
- `POST /api/products`: Add a new product to the list.
- `GET /api/products/{id}`: Retrieve a product by id.
- `PUT /api/products/{id}`: Update a product by id.
- `DELETE /api/products/{id}`: Delete a product by id.3. **Data Validation:**
- Ensure that the product model has required fields (e.g., name, price).
- Validate input data to handle common errors gracefully.4. **Error Handling:**
- Handle exceptions appropriately.
- Return meaningful error messages in the API responses.5. **Authentication: (will be added latter)**
- Allow only authenticated users to perform POST, PUT, and DELETE operations.
- Use a simple username/password approach for authentication.6. **Dependency Injection:**
- Organize your code using dependency injection for services and controllers.## Getting Started...
Follow these steps to set up and run the project locally.
### Prerequisites
- [.NET SDK](https://dotnet.microsoft.com/download) installed.
### Installation
1. Clone the repository:
```bash
git clone https://github.com/InaGoesIT/Products-API.git
```### Usage
- **To view the documentation that I wrote during and before coding**
1. Open [Swagger Online Editor](https://editor.swagger.io/)
2. Copy the swagger.yaml file contents from the main directory or from the github repository
3. Paste the file contents into the editor