All Templates / Starters
.NET8 Web API
A basic ASP.NET Core Web API template (.NET 8)
.NET8 Web API
dangos-dev/DotNet8.ScalarWebApi
Just deployed
This project demonstrates a simple Web API built with ASP.NET Core targeting .NET 8, showcasing interactive API documentation using Scalar.
This template offers a live demonstration of the API's functionality through the integrated Scalar UI. This interactive environment provides a hands-on experience for understanding and testing the API endpoints.
Access the Live API Demonstration: View Interactive Demo
Follow these steps to run the Web API example on your local machine.
git clone https://github.com/dangos-dev/DotNet8.ScalarWebApi.git
cd DotNet8.ScalarWebApi
dotnet run
Scalar UI: Open your browser and navigate to the /scalar
endpoint. For example:
https://localhost:5001/scalar/v1
or http://localhost:5000/scalar/v1
. The specific port will be shown in the console
output when you run the application.
OpenAPI JSON: The raw OpenAPI document in JSON format is available at /openapi/v1.json
. For example:
https://localhost:5001/openapi/v1.json
The HelloWorldController
in this example provides the following endpoints:
GET /HelloWorld
Description: Returns a simple "Hello World! 🍡" greeting message.
Response Example (200 OK):
Hello World! 🍡
GET /HelloWorld/echo
Description: This endpoint echoes back the message provided in the message
query parameter.
Query Parameters:
message
(string, required): The message you want to be echoed.Request Example:
/HelloWorld/echo?message=YourTestMessage
Response Example (200 OK):
Echo: YourTestMessage
Error Response (400 Bad Request):
Condition: If the message
query parameter is missing or empty.
Response Body:
Please provide a message to echo.
Here are the key code files for this template:
Program.cs
: The main application startup file, configuring services and middleware, including Scalar for API
documentation.
Controllers/HelloWorldController.cs
: Defines the HelloWorldController
with the API endpoints.
ApiController]
[Route("[controller]")]
public class HelloWorldController(ILogger logger) : ControllerBase {
[HttpGet] [Route("")]// Matches GET requests to /HelloWorld
public IActionResult GetHelloWorld() {
logger.LogInformation("Hello World endpoint was hit.");
return Ok("Hello World! 🍡");
}
}
Scalar API documentation is configured in Program.cs
using the app.MapScalarApiReference
extension method.
app.MapScalarApiReference(
opt => {
opt.Title = "WebApi with Scalar Example";
opt.Theme = ScalarTheme.BluePlanet;
opt.DefaultHttpClient = new(ScalarTarget.Http, ScalarClient.Http11);
}
);
Title
: Sets the title of the documentation displayed in the Scalar UI (e.g., "WebApi Example").Theme
: Applies the BluePlanet
theme to customize the appearance of the Scalar UI.DefaultHttpClient
: Configures the default HTTP client settings for Scalar.This project relies on the following NuGet packages:
This template is a basic example to help you get started with building ASP.NET Core Web APIs using .NET 8 and documenting them with Scalar. Feel free to use and modify it for your own projects.
Template Content
.NET8 Web API
dangos-dev/DotNet8.ScalarWebApiDetails
Created on Feb 9, 2025
1 total projects
1 active projects
100% success on recent deploys
C#, Dockerfile
Starters
More templates in this category
Django Monolith
A Django app connected to a Postgres database with Celery and Celery Beat.
Prosper Otemuyiwa
26
TanStack + React Starter
A barebones TypeScript React starter with TanStack Router & Query setup
Kyle Gill
23
Scala Play
A simple Play framework app connected to a Postgres database.
Prosper Otemuyiwa