{"id":1325,"date":"2025-11-19T16:28:33","date_gmt":"2025-11-19T16:28:33","guid":{"rendered":"https:\/\/oussamasaidi.com\/?p=1325"},"modified":"2025-12-20T11:14:43","modified_gmt":"2025-12-20T11:14:43","slug":"building-professional-modern-api-documentation-in-net-core-with-scalar","status":"publish","type":"post","link":"https:\/\/oussamasaidi.com\/en\/building-professional-modern-api-documentation-in-net-core-with-scalar\/","title":{"rendered":"Building Professional, Modern API Documentation in .NET Core with Scalar"},"content":{"rendered":"<div class=\"align wp-block-table-of-content-block-table-of-content\" id='tbcnbBlock-1' data-attributes='{&quot;headings&quot;:[{&quot;contents&quot;:&quot;Introduction&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-0&quot;},{&quot;contents&quot;:&quot;What Is Scalar?&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-1&quot;},{&quot;contents&quot;:&quot;Why Developers Prefer Scalar&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-2&quot;},{&quot;contents&quot;:&quot;Why Use Scalar Instead of Swagger UI?&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-3&quot;},{&quot;contents&quot;:&quot;Installing Scalar in a .NET Core Web API Project&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-4&quot;},{&quot;contents&quot;:&quot;Step 1: Create a New .NET Web API&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-5&quot;},{&quot;contents&quot;:&quot;Step 2: Add Scalar Package&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-6&quot;},{&quot;contents&quot;:&quot;Step 3: Enable XML Comments (Required for Documentation)&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-7&quot;},{&quot;contents&quot;:&quot;Step 4: Configure Scalar in &quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-8&quot;},{&quot;contents&quot;:&quot;&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-9&quot;},{&quot;contents&quot;:&quot;Result: Clean, Professional API Documentation&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-10&quot;},{&quot;contents&quot;:&quot;Customizing Scalar UI&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-11&quot;},{&quot;contents&quot;:&quot;How to Improve Your API Documentation&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-12&quot;},{&quot;contents&quot;:&quot;Use XML documentation on controllers&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-13&quot;},{&quot;contents&quot;:&quot;2. Add example responses&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-14&quot;},{&quot;contents&quot;:&quot;Use request\\\/response DTOs&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-15&quot;},{&quot;contents&quot;:&quot;Provide clear error messages&quot;,&quot;tag&quot;:&quot;H3&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-16&quot;},{&quot;contents&quot;:&quot;Conclusion&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-17&quot;},{&quot;contents&quot;:&quot;Last blogs&quot;,&quot;tag&quot;:&quot;H2&quot;,&quot;id&quot;:&quot;bppb-heading-anchor-18&quot;}],&quot;tagName&quot;:[&quot;h3&quot;,&quot;h2&quot;],&quot;title&quot;:{&quot;text&quot;:&quot;Table of Contents&quot;,&quot;tag&quot;:&quot;h5&quot;},&quot;minimize&quot;:{&quot;toggle&quot;:false,&quot;expandIcon&quot;:&quot;fa-solid fa-chevron-down&quot;,&quot;collapseIcon&quot;:&quot;fa-solid fa-chevron-up&quot;},&quot;align&quot;:&quot;&quot;,&quot;rendered&quot;:true,&quot;header&quot;:{&quot;bgColor&quot;:&quot;&quot;,&quot;textColor&quot;:&quot;#444&quot;,&quot;iconColor&quot;:&quot;#000&quot;,&quot;separatorWidth&quot;:1,&quot;separatorColor&quot;:&quot;#ccc&quot;},&quot;boxList&quot;:{&quot;txtStyle&quot;:&quot;normal&quot;,&quot;nTxtColor&quot;:&quot;#2e2e2e&quot;,&quot;nBarColor&quot;:&quot;#b0aeb1&quot;,&quot;hTxtColor&quot;:&quot;#ec1e75&quot;,&quot;hBarColor&quot;:&quot;#ec1e75&quot;,&quot;nTxtDecoration&quot;:false,&quot;hTxtDecoration&quot;:false,&quot;dotSize&quot;:15,&quot;panelHeight&quot;:0,&quot;treeColor&quot;:&quot;blueviolet&quot;,&quot;dotShadow&quot;:[{&quot;hOffset&quot;:&quot;1px&quot;,&quot;vOffset&quot;:&quot;1px&quot;,&quot;blur&quot;:&quot;5px&quot;,&quot;spreed&quot;:&quot;1px&quot;,&quot;color&quot;:&quot;#b3b3b3&quot;,&quot;isInset&quot;:false}],&quot;maxHeight&quot;:{&quot;desktop&quot;:0,&quot;tablet&quot;:0,&quot;mobile&quot;:0},&quot;padding&quot;:{&quot;desktop&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;20px&quot;,&quot;right&quot;:&quot;0px&quot;},&quot;tablet&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;20px&quot;,&quot;right&quot;:&quot;0px&quot;},&quot;mobile&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;20px&quot;,&quot;right&quot;:&quot;0px&quot;}}},&quot;markup&quot;:{&quot;view&quot;:&quot;decimal&quot;,&quot;icon&quot;:&quot;fa-solid fa-circle&quot;,&quot;color&quot;:&quot;#000&quot;,&quot;markupSize&quot;:{&quot;desktop&quot;:&quot;16px&quot;,&quot;tablet&quot;:&quot;16px&quot;,&quot;mobile&quot;:&quot;16px&quot;}},&quot;theme&quot;:&quot;default&quot;,&quot;sticky&quot;:{&quot;toggle&quot;:false,&quot;device&quot;:[&quot;Desktop&quot;],&quot;width&quot;:{&quot;desktop&quot;:&quot;617px&quot;,&quot;tablet&quot;:&quot;90%&quot;,&quot;mobile&quot;:&quot;100%&quot;},&quot;horizonAlign&quot;:&quot;left&quot;,&quot;verticalAlign&quot;:&quot;top&quot;,&quot;right&quot;:{&quot;desktop&quot;:&quot;0px&quot;,&quot;tablet&quot;:&quot;0px&quot;,&quot;mobile&quot;:&quot;0px&quot;},&quot;left&quot;:{&quot;desktop&quot;:&quot;0px&quot;,&quot;tablet&quot;:&quot;0px&quot;,&quot;mobile&quot;:&quot;0px&quot;},&quot;top&quot;:{&quot;desktop&quot;:&quot;0px&quot;,&quot;tablet&quot;:&quot;0px&quot;,&quot;mobile&quot;:&quot;0px&quot;},&quot;bottom&quot;:{&quot;desktop&quot;:&quot;0px&quot;,&quot;tablet&quot;:&quot;0px&quot;,&quot;mobile&quot;:&quot;0px&quot;},&quot;zIndex&quot;:{&quot;desktop&quot;:100,&quot;tablet&quot;:100,&quot;mobile&quot;:100}},&quot;slideTitle&quot;:{&quot;titleColor&quot;:&quot;#2e2e2e&quot;,&quot;slideBarColor&quot;:&quot;#abababbf&quot;,&quot;spaceDevice&quot;:&quot;desktop&quot;,&quot;space&quot;:{&quot;desktop&quot;:&quot;15px&quot;,&quot;tablet&quot;:&quot;15px&quot;,&quot;mobile&quot;:&quot;15px&quot;},&quot;spaceBottomDevice&quot;:&quot;desktop&quot;,&quot;spaceBottom&quot;:{&quot;desktop&quot;:&quot;15px&quot;,&quot;tablet&quot;:&quot;15px&quot;,&quot;mobile&quot;:&quot;15px&quot;},&quot;spaceBottomUnit&quot;:{&quot;desktop&quot;:&quot;px&quot;,&quot;tablet&quot;:&quot;px&quot;,&quot;mobile&quot;:&quot;px&quot;}},&quot;slideList&quot;:{&quot;spaceDevice&quot;:&quot;desktop&quot;,&quot;space&quot;:{&quot;desktop&quot;:&quot;15px&quot;,&quot;tablet&quot;:&quot;15px&quot;,&quot;mobile&quot;:&quot;15px&quot;},&quot;fontSize&quot;:{&quot;desktop&quot;:&quot;16px&quot;,&quot;tablet&quot;:&quot;16px&quot;,&quot;mobile&quot;:&quot;16px&quot;},&quot;fontUnit&quot;:{&quot;desktop&quot;:&quot;px&quot;,&quot;tablet&quot;:&quot;px&quot;,&quot;mobile&quot;:&quot;px&quot;}},&quot;advanced&quot;:{&quot;dimension&quot;:{&quot;padding&quot;:{&quot;desktop&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;right&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;0px&quot;},&quot;tablet&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;right&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;0px&quot;},&quot;mobile&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;right&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;0px&quot;}}},&quot;borderShadow&quot;:{&quot;normal&quot;:{&quot;radius&quot;:{&quot;top&quot;:&quot;0px&quot;,&quot;right&quot;:&quot;0px&quot;,&quot;bottom&quot;:&quot;0px&quot;,&quot;left&quot;:&quot;0px&quot;},&quot;shadow&quot;:[{&quot;hOffset&quot;:&quot;0px&quot;,&quot;vOffset&quot;:&quot;0px&quot;,&quot;blur&quot;:&quot;0px&quot;,&quot;spreed&quot;:&quot;0px&quot;,&quot;color&quot;:&quot;#7090b0&quot;,&quot;isInset&quot;:false}]}},&quot;background&quot;:{&quot;normal&quot;:{&quot;type&quot;:&quot;color&quot;,&quot;color&quot;:&quot;#fff&quot;,&quot;gradient&quot;:{&quot;type&quot;:&quot;radial&quot;,&quot;radialType&quot;:&quot;ellipse&quot;,&quot;colors&quot;:[{&quot;color&quot;:&quot;rgba(58, 66, 222, 1)&quot;,&quot;position&quot;:&quot;0&quot;},{&quot;color&quot;:&quot;rgba(176, 195, 235, 1)&quot;,&quot;position&quot;:&quot;80&quot;}],&quot;centerPositions&quot;:{&quot;x&quot;:50,&quot;y&quot;:50},&quot;angel&quot;:90},&quot;img&quot;:{&quot;url&quot;:&quot;&quot;,&quot;desktop&quot;:{&quot;position&quot;:&quot;center center&quot;,&quot;xPosition&quot;:0,&quot;yPosition&quot;:0,&quot;attachment&quot;:&quot;&quot;,&quot;repeat&quot;:&quot;no-repeat&quot;,&quot;size&quot;:&quot;&quot;,&quot;customSize&quot;:&quot;0px&quot;},&quot;tablet&quot;:{&quot;position&quot;:&quot;center center&quot;,&quot;xPosition&quot;:0,&quot;yPosition&quot;:0,&quot;attachment&quot;:&quot;&quot;,&quot;repeat&quot;:&quot;no-repeat&quot;,&quot;size&quot;:&quot;&quot;,&quot;customSize&quot;:&quot;0px&quot;},&quot;mobile&quot;:{&quot;position&quot;:&quot;center center&quot;,&quot;xPosition&quot;:0,&quot;yPosition&quot;:0,&quot;attachment&quot;:&quot;&quot;,&quot;repeat&quot;:&quot;no-repeat&quot;,&quot;size&quot;:&quot;&quot;,&quot;customSize&quot;:&quot;0px&quot;}},&quot;video&quot;:{&quot;url&quot;:&quot;&quot;,&quot;loop&quot;:false},&quot;transition&quot;:0.3}}},&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true}}'><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span id=\"bppb-heading-anchor-0\"><\/span>Introduction<\/h2>\n\n\n\n<p>In today\u2019s software ecosystem, APIs are everywhere. Whether you are building a mobile application, a microservices architecture, or an internal company platform, your API is often the backbone of the system. But even the best API becomes useless if developers cannot understand how to consume it. This is why API documentation(<strong>Scalar<\/strong> \/<strong>Swagger<\/strong>) is crucial.<\/p>\n\n\n\n<p>For a long time, .NET developers relied mainly on <strong>Swagger \/ Swashbuckle<\/strong> to automatically generate OpenAPI documentation. Swagger is still good, but it lacks a modern design and sometimes feels outdated. This is where <strong>Scalar<\/strong> comes in.<\/p>\n\n\n\n<p><strong>Scalar<\/strong> is a modern, fast, and beautifully designed API documentation tool compatible with OpenAPI specifications. It integrates very well with <strong>.NET Core<\/strong>, giving developers a clean UI, theme customization, and a highly polished developer experience.<\/p>\n\n\n\n<p>In this article, you will learn:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What Scalar is and why it\u2019s better than traditional Swagger UI<\/li>\n\n\n\n<li>How to install and configure Scalar in .NET Core<\/li>\n\n\n\n<li>How to document your API using attributes and XML comments<\/li>\n\n\n\n<li>How to generate clean, professional API docs<\/li>\n\n\n\n<li>How to customize Scalar UI<\/li>\n\n\n\n<li>A full .NET Core API example with working code<\/li>\n\n\n\n<li>Best practices and tips for API documentation<\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s get started.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Scalar?<\/h2>\n\n\n\n<p>Scalar is a modern alternative to Swagger UI for generating interactive API documentation.<br>Instead of the old-style Swagger design, Scalar offers a:<\/p>\n\n\n\n<p>&#x2714; Clean UI<br>&#x2714; Dark\/light theme<br>&#x2714; Fast performance<br>&#x2714; Easy customization<br>&#x2714; Beautiful developer experience<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Developers Prefer Scalar<\/h3>\n\n\n\n<p>\u279c <strong>Better UX:<\/strong> The interface is modern and responsive.<br>\u279c <strong>Developer-first:<\/strong> Easy to extend and configure.<br>\u279c <strong>Zero learning curve:<\/strong> Works with the same OpenAPI definitions as Swagger.<br>\u279c <strong>Supports .NET, Node, Go, Python\u2026<\/strong><br>\u279c <strong>Open-source<\/strong> and actively maintained.<\/p>\n\n\n\n<p>For teams building APIs in <strong>.NET 7, .NET 8, or .NET 9<\/strong>, Scalar is a perfect fit.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use Scalar Instead of Swagger UI?<\/h2>\n\n\n\n<p>While Swagger UI is widely used, it has some limitations:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Swagger UI<\/th><th>Scalar<\/th><\/tr><\/thead><tbody><tr><td>Modern UI<\/td><td>&#x274c; Old design<\/td><td>&#x2705; Stylish, clean<\/td><\/tr><tr><td>Performance<\/td><td>Medium<\/td><td>High<\/td><\/tr><tr><td>Dark mode<\/td><td>Limited<\/td><td>Full<\/td><\/tr><tr><td>Customization<\/td><td>Basic<\/td><td>Advanced<\/td><\/tr><tr><td>Developer experience<\/td><td>OK<\/td><td>Excellent<\/td><\/tr><tr><td>Search &amp; navigation<\/td><td>Average<\/td><td>Great<\/td><\/tr><tr><td>OpenAPI 3.1 support<\/td><td>Partial<\/td><td>Full<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If your project needs <strong>better quality documentation<\/strong>, especially for clients or teams, Scalar is an excellent choice.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Scalar in a .NET Core Web API Project<\/h2>\n\n\n\n<p>Scalar works seamlessly with .NET 7, .NET 8, .NET 9, and .NET 10.<br>Below is a step-by-step example using .NET 9 Web API, but the same works on .NET 8 or .NET 7.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create a New .NET Web API<\/h3>\n\n\n\n<p>If you don\u2019t have a project yet, create one:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dotnet new webapi -n ScalarApiDemo\ncd ScalarApiDemo<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Add Scalar Package<\/h3>\n\n\n\n<p>Install the official Scalar package from NuGet:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dotnet add package Scalar.AspNetCore<\/pre>\n\n\n\n<p>Or from NuGet package manager<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img fetchpriority=\"high\" decoding=\"async\" width=\"461\" height=\"803\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image.png\" alt=\"add Scalar  package using nuget\" class=\"wp-image-1339\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image.png 461w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-172x300.png 172w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-7x12.png 7w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-147x256.png 147w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"428\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-1024x428.png\" alt=\"add Scalar  package using nuget\" class=\"wp-image-1340\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-1024x428.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-300x126.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-768x321.png 768w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-1536x643.png 1536w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-18x8.png 18w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-256x107.png 256w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1-950x398.png 950w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-1.png 1888w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Enable XML Comments (Required for Documentation)<\/h3>\n\n\n\n<p>Edit your <code>.csproj<\/code> file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;PropertyGroup>\n  &lt;TargetFramework>net9.0&lt;\/TargetFramework>\n  &lt;GenerateDocumentationFile>true&lt;\/GenerateDocumentationFile>\n  &lt;NoWarn>$(NoWarn);1591&lt;\/NoWarn>\n&lt;\/PropertyGroup>\n<\/pre>\n\n\n\n<p>This allows Scalar to read method descriptions, parameters, and examples.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Configure Scalar in <code>Program.cs<\/code><\/h3>\n\n\n\n<p>Add this code to enable Scalar:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using Scalar.AspNetCore;\n\nvar builder = WebApplication.CreateBuilder(args);\n\n\/\/ Add services\nbuilder.Services.AddControllers();\nbuilder.Services.AddEndpointsApiExplorer();\nbuilder.Services.AddOpenApi(); \/\/ OpenAPI generator\n\nvar app = builder.Build();\n\n\/\/ Enable OpenAPI JSON\napp.MapOpenApi();\n\n\/\/ Enable Scalar UI at \/docs\napp.MapScalarApiReference(options =>\n{\n    options.Title = \"SAIDI Oussama Tuto : My API Documentation\";\n    options.Theme = ScalarTheme.Dark;\n});\n\napp.MapControllers();\n\napp.Run();\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Configure Scalar in <code>launchSettings.json<\/code><\/strong><\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n  \"$schema\": \"https:\/\/json.schemastore.org\/launchsettings.json\",\n  \"profiles\": {\n    \"http\": {\n      \/\/Other config here\n      \"launchBrowser\": true,\n      \"launchUrl\": \"http:\/\/localhost:5083\/Scalar\",\n     \/\/Other config here\n    }\n    }\n  }\n}<\/pre>\n\n\n\n<p>That\u2019s it\u2014Scalar is now active at: <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">https:\/\/localhost:5001\/Scalar<\/pre>\n\n\n\n<p>Creating an Example API Controller<\/p>\n\n\n\n<p>Below is a simple example of an API controller with full Scalar-friendly documentation.<\/p>\n\n\n\n<p>Create file: <strong>Controllers\/ProductsController.cs<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using Microsoft.AspNetCore.Mvc;\n\nnamespace ScalarApiDemo.Controllers\n{\n    [ApiController]\n    [Route(\"api\/[controller]\")]\n    public class ProductsController : ControllerBase\n    {\n        \/\/\/ &lt;summary>\n        \/\/\/ Returns a list of all products.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;remarks>\n        \/\/\/ This endpoint retrieves all products from the store.\n        \/\/\/ &lt;\/remarks>\n        \/\/\/ &lt;returns>A list of product objects.&lt;\/returns>\n        [HttpGet]\n        public IActionResult GetProducts()\n        {\n            var products = new List&lt;Product>\n            {\n                new Product { Id = 1, Name = \"Laptop\", Price = 1200 },\n                new Product { Id = 2, Name = \"Keyboard\", Price = 40 }\n            };\n\n            return Ok(products);\n        }\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Returns a single product by ID.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"id\">The product ID.&lt;\/param>\n        \/\/\/ &lt;returns>The product object.&lt;\/returns>\n        [HttpGet(\"{id}\")]\n        public IActionResult GetProduct(int id)\n        {\n            var product = new Product { Id = id, Name = \"Laptop\", Price = 1200 };\n\n            return Ok(product);\n        }\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Creates a new product.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"product\">The product to create.&lt;\/param>\n        \/\/\/ &lt;returns>The created product.&lt;\/returns>\n        [HttpPost]\n        public IActionResult CreateProduct(Product product)\n        {\n            product.Id = new Random().Next(100, 999);\n            return CreatedAtAction(nameof(GetProduct), new { id = product.Id }, product);\n        }\n    }\n\n    public class Product\n    {\n        \/\/\/ &lt;summary>The ID of the product.&lt;\/summary>\n        public int Id { get; set; }\n\n        \/\/\/ &lt;summary>The name of the product.&lt;\/summary>\n        public string Name { get; set; }\n\n        \/\/\/ &lt;summary>The price of the product.&lt;\/summary>\n        public decimal Price { get; set; }\n    }\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Result: Clean, Professional API Documentation<\/h2>\n\n\n\n<p>Once your project runs, navigate to <code>\/docs<\/code>.<br>You will see:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Automatic list of all endpoints<\/li>\n\n\n\n<li>Parameters &amp; schemas<\/li>\n\n\n\n<li>Response examples<\/li>\n\n\n\n<li>Beautiful layout<\/li>\n\n\n\n<li>Dark mode option<\/li>\n\n\n\n<li>Automatic JSON formatting<\/li>\n\n\n\n<li>Interactive Request Maker<\/li>\n<\/ul>\n\n\n\n<p>Scalar transforms your API into a <strong>professional-grade documentation platform<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"608\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-1024x608.png\" alt=\"\" class=\"wp-image-1342\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-1024x608.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-300x178.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-768x456.png 768w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-1536x912.png 1536w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-18x12.png 18w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-256x152.png 256w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2-950x564.png 950w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-2.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Customizing Scalar UI<\/h2>\n\n\n\n<p>Scalar offers multiple customization options, including:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">app.MapScalarApiReference(options =>\n{\n    options.Title = \"SAIDI Oussama Tuto : E-Commerce API Documentation\";\n    options.Layout = ScalarLayout.Modern;\n    options.DarkMode = true;\n    options.Theme = ScalarTheme.BluePlanet;\n});\n<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-1024x608.png\" alt=\"\" class=\"wp-image-1343\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-1024x608.png 1024w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-300x178.png 300w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-768x456.png 768w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-1536x912.png 1536w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-18x12.png 18w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-256x152.png 256w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3-950x564.png 950w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/image-3.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Available themes<\/h4>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Default<\/li>\n\n\n\n<li>None<\/li>\n\n\n\n<li>Alternate<\/li>\n\n\n\n<li>Moon<\/li>\n\n\n\n<li>Purple<\/li>\n\n\n\n<li>Solarized<\/li>\n\n\n\n<li>BluePlanet<\/li>\n\n\n\n<li>Saturn<\/li>\n\n\n\n<li>Kepler<\/li>\n\n\n\n<li>Mars<\/li>\n\n\n\n<li>DeepSpace<\/li>\n\n\n\n<li>Laserwave<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Layouts<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Classic<\/li>\n\n\n\n<li>Modern<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Branding<\/h4>\n\n\n\n<p>You can add logo, colors, description.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Improve Your API Documentation<\/h2>\n\n\n\n<p>Scalar helps automatically, but you can improve documentation quality by:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. <\/strong>Use XML documentation on controllers<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/\/ &lt;summary>\n\/\/\/ Updates the price of a product.\n\/\/\/ &lt;\/summary>\n\/\/\/ &lt;param name=\"id\">Product ID&lt;\/param>\n\/\/\/ &lt;param name=\"price\">New price&lt;\/param>\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Add example responses<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[ProducesResponseType(typeof(Product), 200)]<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. <\/strong>Use request\/response DTOs<\/h3>\n\n\n\n<p>Avoid exposing database entities directly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. <\/strong>Provide clear error messages<\/h3>\n\n\n\n<p>Document all responses: 200, 400, 404, 500\u2026<\/p>\n\n\n\n<p>for more details the official <a href=\"https:\/\/guides.scalar.com\/scalar\/introduction\" target=\"_blank\" rel=\"noopener\" title=\"\">Scalar documentation<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Scalar is quickly becoming one of the best alternatives to Swagger for .NET developers. It offers a <strong>modern<\/strong>, <strong>clean<\/strong>, and <strong>fast<\/strong> documentation experience that works perfectly with .NET Core APIs.<\/p>\n\n\n\n<p>In this guide, you learned:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What Scalar is and why it\u2019s better than Swagger<\/li>\n\n\n\n<li>How to install and configure Scalar in .NET Core<\/li>\n\n\n\n<li>How to write clean API documentation with examples<\/li>\n\n\n\n<li>How to customize Scalar UI<\/li>\n\n\n\n<li>Complete .NET Core tutorial with ready-to-run code<\/li>\n<\/ul>\n\n\n\n<p>If you want to provide <strong>professional-grade API documentation<\/strong> for your .NET Core application, Scalar is an excellent choice.<\/p>\n\n\n\n<p>Full <a href=\"https:\/\/github.com\/oussama-saidi\/os-tuto-scalar-api-demo\" target=\"_blank\" rel=\"noopener\" title=\"\">Github <\/a>source code <a href=\"https:\/\/github.com\/oussama-saidi\/os-tuto-scalar-api-demo\" target=\"_blank\" rel=\"noopener\" title=\"\">here<\/a><\/p>\n\n\n\n<div class=\"buy-coffee-container\">\n<p style=\"text-align:center; color:#555; font-size:14px;\">\n  If this article helped you, consider supporting my work.\n<\/p>\n  <a\n    href=\"https:\/\/buymeacoffee.com\/oussamasaii\"\n    target=\"_blank\"\n    rel=\"noopener noreferrer\"\n    class=\"buy-coffee-button\"\n  >\n    &#x2615; Buy me a coffee\n  <\/a>\n<\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"bppb-heading-anchor-18\"><\/span>Last blogs<\/h2>\n\n\n<ul class=\"wp-block-latest-posts__list is-grid columns-3 has-author wp-block-latest-posts\"><li><div class=\"wp-block-latest-posts__featured-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/react-19-and-vite-for-dotnet-developers-build-fast-modern-frontends-150x150.png\" class=\"attachment-thumbnail size-thumbnail wp-post-image\" alt=\"react-19-and-vite-for-dotnet-developers-build-fast-modern-frontends\" style=\"\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/react-19-and-vite-for-dotnet-developers-build-fast-modern-frontends-150x150.png 150w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/react-19-and-vite-for-dotnet-developers-build-fast-modern-frontends-140x140.png 140w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/oussamasaidi.com\/en\/react-19-and-vite-for-dotnet-developers-build-fast-modern-frontends\/\">React 19 &amp; Vite: Build Fast Frontends for .NET Developers<\/a><div class=\"wp-block-latest-posts__post-author\">by Saidi Oussama<\/div><\/li>\n<li><div class=\"wp-block-latest-posts__featured-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r-150x150.png\" class=\"attachment-thumbnail size-thumbnail wp-post-image\" alt=\"RESTful API Mastery\" style=\"\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r-150x150.png 150w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r-140x140.png 140w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/oussamasaidi.com\/en\/https-oussamasaidi-com-restful-api-mastery-best-practices-with-asp-net-core-part-2\/\">RESTful API best practices\u00a0with ASP.NET Core Part 2<\/a><div class=\"wp-block-latest-posts__post-author\">by Saidi Oussama<\/div><\/li>\n<li><div class=\"wp-block-latest-posts__featured-image aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-150x150.png\" class=\"attachment-thumbnail size-thumbnail wp-post-image\" alt=\"RESTful API Mastery\" style=\"\" srcset=\"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-150x150.png 150w, https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-140x140.png 140w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/div><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/oussamasaidi.com\/en\/restful-api-mastery-best-practices-with-asp-net-core\/\">RESTful API Best Practices with ASP.NET Core<\/a><div class=\"wp-block-latest-posts__post-author\">by Saidi Oussama<\/div><\/li>\n<\/ul>\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction In today\u2019s software ecosystem, APIs are everywhere. Whether you are building a mobile application, a microservices architecture, or an&#8230; <\/p>\n<div class=\"art-el-more\"><a href=\"https:\/\/oussamasaidi.com\/en\/building-professional-modern-api-documentation-in-net-core-with-scalar\/\" class=\"art-link art-color-link art-w-chevron\">Read more<\/a><\/div>","protected":false},"author":1,"featured_media":1364,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[40,68,45,41,56,279,86,282,98,60,20,61],"tags":[47,48,49,54,97,53],"ppma_author":[286],"class_list":["post-1325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-netcore","category-api","category-asp-net","category-c","category-c-2","category-en","category-podman","category-scalar","category-solid","category-swagger-ui","category-technology","category-web-api","tag-net-core","tag-asp-net","tag-c-sharp","tag-c","tag-clean-code","tag-dot-net-core"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/Building-Professional-Modern-API-Documentation-in-.NET-Core-with-Scalar.png","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1714,"url":"https:\/\/oussamasaidi.com\/en\/https-oussamasaidi-com-restful-api-mastery-best-practices-with-asp-net-core-part-2\/","url_meta":{"origin":1325,"position":0},"title":"RESTful API best practices\u00a0with ASP.NET Core Part 2","author":"Saidi Oussama","date":"December 20, 2025","format":false,"excerpt":"Testing, Performance, Security, Microservices & Deployment Introduction: From Solid Foundations to Production Excellence In Part 1 of RESTful API Mastery, we established the architectural and technical foundations required to build reliable, evolvable RESTful APIs with ASP.NET Core. However, a well-designed API only becomes truly valuable when it is tested, observable,\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-2r.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1639,"url":"https:\/\/oussamasaidi.com\/en\/restful-api-mastery-best-practices-with-asp-net-core\/","url_meta":{"origin":1325,"position":1},"title":"RESTful API Best Practices with ASP.NET Core","author":"Saidi Oussama","date":"December 16, 2025","format":false,"excerpt":"Professional Best Practices, Versioning Strategies & Advanced Serialization (Part 1) In this blog Introduction: Building Enterprise-Grade RESTful APIs with ASP.NET Core1. RESTful APIs in the Modern ASP.NET Core EcosystemWhy REST Still Dominates2. REST Architectural Constraints Every ASP.NET Core API Must EnforceClient\u2013Server SeparationStatelessnessUniform Interface3. Establishing a Clean and Scalable ASP.NET Core\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"RESTful API Mastery","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/12\/restful-api-mastery-best-practices-with-asp-net-core-cover-scaled.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":838,"url":"https:\/\/oussamasaidi.com\/en\/comment-implementer-authentification-cle-api-aspnet-core\/","url_meta":{"origin":1325,"position":2},"title":".NET Core : impl\u00e9menter l\u2019authentification par cl\u00e9 API en C#","author":"Saidi Oussama","date":"August 22, 2024","format":false,"excerpt":"ContexteCr\u00e9ation de l'attribut de cl\u00e9 APIImpl\u00e9menter du filtre d'autorisation ApiKeyimpl\u00e9mentation de l'ApiKeyValidatorTester l'APIUtilisez le middlewareConclusionDerniers Articles Vous pouvez trouver le code source complet sur github Contexte Alors, qu\u2019est-ce que l\u2019authentification par cl\u00e9 API dans ASP.NET Core ? Prenons un exemple concret. Imaginez que vous ayez d\u00e9velopp\u00e9 un tableau de bord\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2024\/07\/Capture00.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2024\/07\/Capture00.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2024\/07\/Capture00.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1035,"url":"https:\/\/oussamasaidi.com\/en\/creer-un-chatbot-avec-deepseek-et-net-9-tutoriel-complet\/","url_meta":{"origin":1325,"position":3},"title":"Cr\u00e9er un Chatbot avec DeepSeek et .NET 9 : Tutoriel Complet","author":"Saidi Oussama","date":"April 6, 2025","format":false,"excerpt":"Ce tutoriel vous guidera pas \u00e0 pas pour construire un chatbot utilisant l'API de DeepSeek avec .NET 9. Nous allons cr\u00e9er une application web de chatbot avec ASP.NET Core. Pr\u00e9requis\u00c9tape 1 : Cr\u00e9er une nouvelle application Web ASP.NET Core\u00c9tape 2 : Ajouter les packages n\u00e9cessaires\u00c9tape 3 : Cr\u00e9er les mod\u00e8les\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"AI Chatbot with .net core","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/https___dev-to-uploads.s3.amazonaws.com_uploads_articles_w4yx4rdp1ohuvcb96ypg.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/https___dev-to-uploads.s3.amazonaws.com_uploads_articles_w4yx4rdp1ohuvcb96ypg.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/https___dev-to-uploads.s3.amazonaws.com_uploads_articles_w4yx4rdp1ohuvcb96ypg.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/04\/https___dev-to-uploads.s3.amazonaws.com_uploads_articles_w4yx4rdp1ohuvcb96ypg.webp?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":927,"url":"https:\/\/oussamasaidi.com\/en\/announcing-dotnet-9-whats-new-key-features-you-need-to-know-part-2\/","url_meta":{"origin":1325,"position":4},"title":"Les Nouveaut\u00e9s de .NET 9 : Un Aper\u00e7u Complet [Partie 2]","author":"Saidi Oussama","date":"January 6, 2025","format":false,"excerpt":"Si les nouveaut\u00e9s pr\u00e9c\u00e9demment \u00e9voqu\u00e9es sont d\u00e9j\u00e0 impressionnantes, .NET 9 propose \u00e9galement d'autres fonctionnalit\u00e9s tout aussi importantes. Voici un aper\u00e7u des fonctionnalit\u00e9s suppl\u00e9mentaires : 1. Am\u00e9liorations dans les Minimal APIs2. Am\u00e9liorations de l'Interop\u00e9rabilit\u00e93. SignalR Optimis\u00e94. Prise en Charge du Framework MAUI5. Nouveaux Sc\u00e9narios pour les Tests Unitaires6. Gestion Optimis\u00e9e de\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/01\/buildanything-dot-net9.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1254,"url":"https:\/\/oussamasaidi.com\/en\/how-to-build-an-idempotent-api-with-net-9-ef-core-9-and-polly-v8\/","url_meta":{"origin":1325,"position":5},"title":"How to Build an Idempotent API with .NET 9, EF Core 9 and Polly v8","author":"Saidi Oussama","date":"November 6, 2025","format":false,"excerpt":"Introduction Have you ever hit \u201cPay\u201d on a checkout page, the page froze, and you clicked again \u2014 only to be charged twice?That\u2019s exactly what idempotency prevents. In distributed and cloud-native architectures, duplicate requests happen often: client-side retries (mobile poor signal), API Gateway or load-balancer retries, users refreshing a browser\u2026","rel":"","context":"In &quot;.Net Core&quot;","block_context":{"text":".Net Core","link":"https:\/\/oussamasaidi.com\/en\/category\/netcore\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/oussamasaidi.com\/wp-content\/uploads\/2025\/11\/oussama-saidi-tuto-net-core-rest-api-Idempotent-1.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"authors":[{"term_id":286,"user_id":1,"is_guest":0,"slug":"oussama_sa","display_name":"Saidi Oussama","avatar_url":{"url":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg","url2x":"https:\/\/oussamasaidi.com\/wp-content\/uploads\/2022\/02\/001_001_cv1.jpg"},"author_category":"1","first_name":"Oussama","last_name":"SAIDI","user_url":"https:\/\/oussamasaidi.com","job_title":"Senior Fullstack .NET Developer","description":"I\u2019m a Senior Fullstack .NET Developer specializing in building scalable, high-performance web applications with .NET, C#, and modern frontend frameworks like React.js. I\u2019m passionate about clean architecture, automated testing, and sharing knowledge through blogs and tutorials."}],"_links":{"self":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/comments?post=1325"}],"version-history":[{"count":60,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1325\/revisions"}],"predecessor-version":[{"id":1711,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/posts\/1325\/revisions\/1711"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media\/1364"}],"wp:attachment":[{"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/media?parent=1325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/categories?post=1325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/tags?post=1325"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/oussamasaidi.com\/en\/wp-json\/wp\/v2\/ppma_author?post=1325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}