Skip to content

Praveenkumar-here/API-op-swagger

Repository files navigation

ASP.NET Minimal API Demo with Swagger

This project is a basic ASP.NET Core minimal API demonstrating how to build a simple API with in-memory data and minimal code.

Features

  • Implements two GET endpoints:
    • /games – returns all games as JSON
    • /games/{id} – returns a single game by ID or 404 if not found
  • Uses a simple in-memory list of game objects
  • Includes Swagger/OpenAPI support for interactive API documentation and testing

Getting Started

Prerequisites

  • .NET 8 SDK
  • Recommended: Visual Studio Code or Visual Studio 2022+

Running the API

  1. Clone the repository: git clone https://github.com/YourUsername/YourRepoName.git cd YourRepoName

  2. Restore dependencies: dotnet restore

  3. Run the project: dotnet run

  4. Open your browser and navigate to: http://localhost:PORT/games & http://localhost:PORT/games/id

This opens the Swagger UI where you can explore and test the API endpoints interactively.

API Endpoints

  • GET /games – Retrieves all available games.
  • GET /games/{id} – Retrieves a game by its integer ID.

Example responses:

{ "id": 1, "name": "Chess", "genre": "Strategy" }, { "id": 2, "name": "Pandemic", "genre": "Cooperative" } ]

Project Structure

  • Program.cs – Main entry point defining API routes and Swagger configuration.
  • Game.cs – Model representing game data.
  • games.http - Fetch the data from the host with defined or preferred methods.

Why This Project?

This project helped me practice:

  • Building minimal APIs with ASP.NET Core
  • Implementing RESTful API endpoints
  • Using in-memory collections for quick prototyping
  • Integrating Swagger for live API documentation and testing

Feedback and Contributions

This is a learning project. Feel free to fork, open issues, or suggest improvements!


Learning ❤️ by [PRaveenkumar-here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages