Belitsoft > Features and benefits of the built-in OpenAPI support in ASP.NET Core 10

Features and benefits of the built-in OpenAPI support in ASP.NET Core 10

.NET 10 has built-in OpenAPI now, so .NET developers  don’t need to manually wire up third-party tools for API documentation. Built-in OpenAPI means one less NuGet package, one less headache compared with .NET 8 or or earlier version of .NET. The ASP.NET Core team built Microsoft.AspNetCore.OpenApi so developers can create their API documentation without downloading external libraries like Swashbuckle.  Built-in OpenAPI is another strong supporting point for migrating to .NET 10. If you need a team of expert .NET developers to help you with this, let’s talk.

Contents

Using this package gives developers a few specific advantages. 

1. Rely on built-in tools

ASP.NET Core builds your API documents directly. You skip downloading and updating outside packages to list your endpoints.

"Starting with .NET 9, ASP.NET Core includes built-in OpenAPI support. ASP.NET Core provides first-party support for generating information about endpoints in an app through the Microsoft.AspNetCore.OpenApi package."
Microsoft Documentation

While you do add a package, Microsoft.AspNetCore.OpenApi, the documentation categorizes it as "built-in" and "first-party" support maintained directly by the ASP.NET Core team, allowing you to sidestep third-party/outside tools that were required in previous versions.

For Whom This is Important 

Application Developers & Maintainers

In the past, whenever Microsoft released a new major version of .NET or new C# features, .NET teams often had to wait weeks or months for third-party package maintainers to update their libraries to fully support the new features. A built-in solution means OpenAPI support is guaranteed to be fully compatible with new ASP.NET Core features (like new Minimal API route handlers) on day one. It reduces "dependency bloat" and means one less third-party package to track, update, and configure.

Software Architects & Performance Engineers

A massive focus in modern .NET development is Native AOT (Ahead-of-Time compilation) and Trimming (removing unused code to make extremely small, fast-starting microservices). Older third-party tools relied heavily on runtime reflection, which breaks when using Native AOT.

Microsoft engineered the new built-in Microsoft.AspNetCore.OpenApi package specifically to rely on System.Text.Json and a design that is 100% Native AOT and Trim-compatible. This is critical for teams trying to build high-performance, containerized microservices where startup time and memory footprints must be minimal.

Security & Compliance Teams

Software supply chain security is a top priority. Every third-party open-source package added to a project introduces a potential surface area for vulnerabilities or abandoned maintenance.

2. Write documentation using newest standards

The package writes your documentation using the OpenAPI 3.1 standard and the latest JSON formats by default, though you can shift it down to the older 3.0 standard.

"The package provides the following features: support for generating OpenAPI version 3.1 documents, and support for JSON Schema draft 2020-12. The default OpenAPI version for generated documents is 3.1. The version can be changed by explicitly setting the OpenApiVersion property of the OpenApiOptions in the configureOptions delegate parameter of AddOpenApi. By default, OpenAPI document generation creates a document that is compliant with the OpenAPI specification. "
Microsoft Documentation

Because OpenAPI 3.1 finally converged with strict JSON Schema standards, the third-party tooling (from UI generators to security scanners) can interact with your ASP.NET Core API with zero friction or translation errors. While it acts behind the scenes, you keep the ability to optionally shift down to 3.0) to maintain backward compatibility with older legacy systems.

For Whom This is Important 

Frontend & Mobile Developers (API Consumers)

Under older standards (OpenAPI 3.0), OpenAPI did not perfectly match standard JSON. It used a custom "subset" of JSON Schema. This meant tools that generated TypeScript, Swift, or Kotlin client code often ran into bugs when translating complex data models.

OpenAPI 3.1 is 100% aligned with the JSON Schema draft 2020-12. This means that frontend developers can plug the generated API document directly into any standard JSON Schema tool or code generator on the market. It results in flawlessly generated client SDKs, perfectly typed models in TypeScript, and robust client-side validation logic without awkward workarounds.

Enterprise API Designers & Architects

Modern APIs are rarely just "Request/Response." They are often event-driven, relying heavily on Webhooks (Stripe or GitHub APIs). Older OpenAPI specs had no native way to document these asynchronous events.

OpenAPI 3.1 introduced native, first-class support for defining Webhooks. Architects can now use a single specification standard to accurately map out both their synchronous HTTP endpoints and their asynchronous event streams. Furthermore, JSON Schema 2020-12 allows architects to build highly modular, re-usable data schemas across massive codebases without duplication.

QA Engineers & Security Teams

Automated testing tools (like API fuzzers, DAST security scanners, and contract testers) programmatically read API documentation to try and "break" an API by sending bad data maliciously.

The JSON Schema draft 2020-12 introduces much more rigorous and mathematically sound ways to define payloads, arrays, and object constraints. Because the new ASP.NET Core tools generate these highly precise schemas by default, automated security scanners and QA frameworks can instantly understand the exact boundaries of the API payload, making security modeling highly effective.

3. Read routes from any API style

The package scans your code and maps your endpoints, whether you organize them into traditional Controllers or write modern Minimal APIs.

"ASP.NET Core supports the generation of OpenAPI documents in controller-based and Minimal API apps. [...] An API operation represents a specific action or capability that an API provides [...] Controller action methods in MVC-style APIs and Route handlers in Minimal APIs. An endpoint is a combination of the API's base URL and a specific path to the desired resource, along with the supported HTTP methods: For controller-based APIs, endpoints combine the route template with controller and action. For Minimal APIs, endpoints are explicitly defined with app.MapGet(), app.MapPost(), etc."
Microsoft Documentation

The built-in system scans and processes your endpoints identically, regardless of which architectural style you choose to build your API.

For Whom This is Important 

Migration Teams & Legacy Maintainers

Many enterprise applications are years old and built entirely on traditional MVC Controllers. When these teams decide to adopt the newer, much faster Minimal APIs in .NET, they usually do so progressively (adding new features in Minimal APIs while leaving legacy features in Controllers).

Without this unified support, teams would have fragmented API documentation (part of it documented one way, part another). Because the built-in generator maps both styles automatically, teams can safely migrate large codebases over time without breaking or splitting their public API documentation.

Full-Stack / Hybrid Development Teams

Controllers exist because they are great for complex logic with heavy routing and dependencies. Minimal APIs exist because they are incredibly lightweight, fast, and perfect for simple read/write data microservices.

Developers are no longer forced to pick just one architectural style simply to keep their Swagger/OpenAPI working. A team can freely mix and match, using Controllers for a complex payment gateway and Minimal APIs for a simple health check, and the built-in tooling will perfectly read both into the exact same standardized OpenAPI JSON file.

External API Consumers & Partners

The developers or businesses consuming your company's API do not care, and should not know, how you structured your backend code in ASP.NET Core. They only care about the JSON contract.

By reading routes agnostically across any API style, ASP.NET Core guarantees that the generated OpenAPI document is clean and uniform. When a partner uses a tool to auto-generate a TypeScript or Java client from your OpenAPI document, they receive a perfectly structured client SDK that hides the fact your backend uses two entirely different routing frameworks internally.

4. Keep the app small and fast

The package survives code trimming and ahead-of-time compilation. The compiler cuts out unused code, leaving a smaller app that starts up instantly.

The Microsoft.AspNetCore.OpenApi package provides the following features: Takes advantage of JSON schema support provided by System.Text.Json. Compatible with native AoT. Trimming and Native AOT OpenAPI in ASP.NET Core supports trimming and native AOT.
Microsoft Documentation

Native AOT (Ahead-of-Time compilation) and Code Trimming has been the single most heavily advertised feature by Microsoft in recent .NET releases. Historically, third-party OpenAPI tools (like Swashbuckle) heavily relied on "reflection," which completely broke when developers tried to use AOT or trimming. By making OpenAPI generation fully compatible with AOT, Microsoft solved an industry headache.

For Whom This is Important 

Cloud Architects & FinOps Teams

In large-scale enterprise environments (like Kubernetes), cloud providers bill you based on exactly how much CPU and RAM your deployment consumes, as well as the storage cost of Docker images.

Code trimming cuts out every piece of unused .NET framework code before the app is deployed. Combined with Native AOT, teams can shrink an API's Docker image from +200MB down to under 50MB, and idle memory usage can drop below 20MB. When scaled across hundreds of microservices, this translates directly into massive reductions in monthly AWS/Azure cloud computing bills.

Serverless Developers (Azure Functions / AWS Lambda)

In Serverless computing, your API shuts down completely when no one is using it to save money. When a new user sends a request, the API has to boot up from zero (a "Cold Start"). Standard .NET applications use Just-In-Time (JIT) compilation, which can make this cold start take 1 to 3 seconds.

Native AOT pre-compiles the app directly into raw machine code (like C++ or Rust). This means the API starts up instantly (in milliseconds). By ensuring the new OpenAPI package natively supports AOT, serverless developers can finally have great API documentation without sacrificing those blazing-fast cold start times.

Edge Computing & IoT Developers

Edge computing (running code on smart factory devices, medical equipment, or small IoT hubs) typically involves hardware with highly restrictive CPU, storage, and memory limits.

An app that "survives code trimming" is essential here. Because the compiler aggressively cuts out unused code, an ASP.NET Core API can run efficiently on highly constrained edge devices where bloated, standard runtime installations are physically impossible to deploy.

5. Process data with standard tools

The package relies on System.Text.Json to read and write the shapes of your data. This cuts out extra processing steps because the app already shares this exact tool for other tasks.

Microsoft engineered the new built-in Microsoft.AspNetCore.OpenApi package specifically to rely on System.Text.Json and a design that is 100% Native AOT and Trim-compatible. The Microsoft.AspNetCore.OpenApi package provides the following features: Takes advantage of JSON schema support provided by System.Text.Json.
Microsoft Documentation

Because ASP.NET Core already uses System.Text.Json internally for its standard HTTP Request/Response processing, having the OpenAPI tools use this exact same engine means the framework doesn't have to load a separate, third-party parser (like Newtonsoft.Json) just to read data shapes. This cuts out extra processing steps, saves memory, and ensures perfectly consistent serialization across the entire app.

For Whom This is Important 

API Developers

In the past, if a developer told ASP.NET Core to serialize an Enum as a string instead of a number, they also had to write custom mapping code so that Swashbuckle/OpenAPI would know about that rule. Because the built-in generator uses System.Text.Json, it automatically inherits every custom configuration, JsonSerializerOptions, and naming policy the developer applied to the app. What you configure for your app is automatically and flawlessly reflected in your Swagger documentation - no duplicate work required.

Performance & System Engineers

Every time you add a new library that processes data shapes, it increases the memory overhead of the application. By reusing the exact same serialization engine the framework already uses for HTTP requests, the API dramatically reduces its physical memory footprint and prevents duplicate computational work on startup.

Security & Compliance Teams

System.Text.Json is built inherently into the .NET runtime core and is aggressively vetted by Microsoft's security teams. By removing third-party data serialization frameworks from the OpenAPI generation pipeline, security teams remove a massive vector of potential transitive dependency vulnerabilities (CVEs) from the software supply chain.

6. Change the documentation while the app runs

Developers write specific functions called "transformers." These transformers scan the raw documentation and update it just before the app sends the final page to the browser.

"The Microsoft.AspNetCore.OpenApi package provides the following features: Support for generating OpenAPI documents at runtime and accessing them through an endpoint on the application. Support for "transformer" APIs that modify the generated document. The OpenAPI document is regenerated every time a request to the OpenAPI endpoint is sent. Regeneration enables transformers to incorporate dynamic app state into their operation".
Microsoft Documentation

Because the document generates "at runtime" and regenerates on each request, developers can use these "transformer" APIs to inject real-time data like current configuration states or HTTP context details right before the JSON is sent to the client's browser.

For Whom This is Important 

Security & DevSecOps Teams

You often want different levels of API visibility depending on where the app is running. For instance, you might want internal "admin" endpoints visible in a Staging environment but completely scrubbed from the OpenAPI document in Production.

Because transformers evaluate code dynamically per request, security engineers can write a simple transformer that checks the environment (like if (builder.Environment.IsProduction())). It can then automatically strip out sensitive endpoint schemas or dynamically inject required Security Policies (like OAuth2 or JWT Bearer definitions) globally before presenting the document to the outside world.

Multi-Tenant Enterprise Architects

Many modern enterprise APIs are "Multi-tenant," meaning the same backend serves multiple different companies. Their API base URLs, or even the endpoints available to them, might differ based on their subscription tier or server region.

Transformers can read the active state of the application (or the HTTP Request context). Architects can write logic that mutates the OpenAPI document dynamically on-the-fly, changing the documented Server URL to match the exact tenant requesting the document, or injecting custom vendor extensions (x-tenant-id) dynamically into the JSON.

7. Create documentation files during the build

Developers configure the compiler to save the documentation to a text file before the app even runs. Other tools then read this file to automatically write client code or run tests.

"The Microsoft.Extensions.ApiDescription.Server package supports generating OpenAPI documents at build time and serializing them. [...] By default, the generated OpenAPI document is saved to the obj directory [...] These scenarios include generating OpenAPI documentation that is: Committed into source control. Used for spec-based integration testing. Served statically from the web server. [...] This structured format allows tools to generate client libraries, server stubs, and interactive documentation automatically."
Microsoft Documentation

For Whom This is Important 

Frontend & Mobile Development Teams (API Consumers)

In large companies, frontend and backend teams work simultaneously. Frontend developers rely on code-generation tools (like NSwag, Orval, or OpenAPI Generator) to automatically build their TypeScript or Swift API client code.

Getting the documentation at build-time means the backend team does not need to deploy or run the server for the frontend team to get the API contract. As soon as the backend developer types dotnet build and commits the code to GitHub, the build pipeline can grab the generated .json file and instantly push it to the frontend repo, triggering their client SDK generators immediately.

QA & Integration Testing Teams

Testing teams write "Contract Tests" or "Spec-based Integration Tests" to ensure the API never breaks its promises (like ensuring a POST /purchase route always returns a strictly typed integer ID).

QA automation frameworks securely ingest the locally generated OpenAPI JSON file right after the build step finishes in the CI/CD pipeline. They can programmatically analyze the static document to verify that no breaking changes (like a deleted endpoint or a renamed JSON field) were introduced before the application is ever deployed to a testing or staging environment.

DevOps Engineers & CI/CD Pipeline maintainers

Historically, to get a Swagger JSON file to publish to an API Portal (like Azure API Management), DevOps pipelines had to start up the .NET application server, wait for it to boot up, send an HTTP GET /swagger/v1/swagger.json request with curl, save the file, and then shut the server down.

This eliminates that headache. DevOps engineers no longer have to mock database connections in their pipelines just to boot the server temporarily. The pipeline simply runs dotnet build, and the perfectly formed openapi.json is sitting in the obj folder waiting to be uploaded to their documentation site instantly.

8. Group endpoints into separate documents

Developers tag their API routes and tell the package to spit out different documents for each group. This way, public users read the public API document, and internal teams read the private API document.

"The Microsoft.AspNetCore.OpenApi package provides [...] Support for generating multiple OpenAPI documents with different content from a single ASP.NET Core API app. These scenarios include generating OpenAPI documentation for different: Audiences, such as public and internal APIs. Versions of an API. Parts of an app, such as a frontend and backend API. [...] To generate [them], call the AddOpenApi extension method once for each document [...] The framework uses the ShouldInclude delegate method of OpenApiOptions [...] set on an endpoint using either the WithGroupName extension method or the EndpointGroupNameAttribute attribute [which] determines which endpoints to include in the document."
Microsoft Documentation

For Whom This is Important 

Product Managers & API Strategists (Public vs. Private)

Most enterprise applications are monoliths (or large APIs) that contain both publicly marketable endpoints (e.g., GET /products) and highly sensitive internal administrative endpoints (e.g., POST /admin/wipe-database).

Instead of splitting the code into two entirely separate C# applications, which drastically increases maintenance, teams keep the code unified. The AddOpenApi groupings allow the system to spit out a clean, safe "Public.json" that gets published to external customer portals, while simultaneously generating a comprehensive "Internal.json" that is only shared privately with backend engineers. Data leakage is prevented securely and natively.

Full-Stack Developers & Client SDK Generators

When a frontend developer uses automated tools (like NSwag or TypeScript-Fetch) to generate their client code from an OpenAPI document, the size of the generated SDK depends entirely on the size of the Swagger file.

If an application has thousands of endpoints, but the React frontend only needs 30 of them, passing a massive OpenAPI document creates bloat. By grouping endpoints into a specific "Frontend" document, the frontend team receives a perfectly tailored, tiny JSON file, resulting in lightweight, highly optimized client SDKs.

API Versioning Teams (Maintaining Legacy Systems)

When a company updates its API (moving from v1 to v2), they cannot immediately turn off the old version, or they will break existing customers' software.

Teams tag their old controllers with "v1" and their new ones with "v2". The ASP.NET Core package automatically produces two distinct documents: v1.json and v2.json. This seamless separation ensures that old customers continue to see accurate legacy documentation, while new integrations use the updated standards, all hosted cleanly from a single running API project.

9. Hide the documentation from real users

Developers wrap the endpoint setup in a simple checking statement so the app only turns on the documentation on local computers. This blocks the app from leaking sensitive details to the live internet.

"The ASP.NET Core minimal web API template generates the following code [...] if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } [...] MapOpenApi adds an endpoint into the application for viewing the OpenAPI document serialized into JSON. The OpenAPI endpoint is restricted to the Development environment to minimize the risk of exposing sensitive information and reduce the vulnerabilities in production."
Microsoft Documentation

For Whom This is Important 

Security Operations (SecOps) & Penetration Testers

In cybersecurity, an OpenAPI/Swagger JSON file is considered an absolute goldmine for hackers. It provides a perfect, fully typed "roadmap" of every single endpoint mapped on the server, including hidden administrative paths, required query parameters, and data payloads.

By wrapping the documentation in an IsDevelopment() check, developers ensure the API goes completely "dark" when pushed to the live internet. It drastically reduces the attack surface because automated vulnerability scanners and malicious actors can no longer easily map the application's internal structure or find an overlooked internal endpoint to exploit.

Compliance & Legal Verification Teams

Heavily regulated industries (like banking under PCI DSS, or healthcare under HIPAA) have strict guidelines about "security by obscurity" and data minimization. You cannot legally expose the technical schematic of a highly sensitive medical database to the public internet.

This template behavior guarantees that sensitive intellectual property, proprietary business logic algorithms, and internal data structures are statically blocked from ever leaking into the public domain unless explicitly and purposefully unblocked by an architect.

Site Reliability Engineers (SREs)

In modern ASP.NET Core, the OpenAPI document regenerates dynamically (which is useful for transformers but utilizes CPU and memory on every request).

SREs are tasked with keeping production servers as fast and lean as possible. By blocking the OpenAPI generation in production, they ensure that internet bots, web scrapers, or low-level DDoS attacks cannot waste server CPU cycles repeatedly asking for a massive JSON documentation file, preserving 100% of the server's resources for actual customer traffic.

Never miss a post! Share it!

Written by
Microsoft .NET Development Delivery Manager
5.0
1 review

Rate this article

Leave a comment
Your email address will not be published.

Our Clients' Feedback

zensai
technicolor
crismon
berkeley
hathway
howcast
fraunhofer
apollomatrix
key2know
regenmed
moblers
showcast
ticken
Next slide
Let's Talk Business
Do you have a software development project to implement? We have people to work on it. We will be glad to answer all your questions as well as estimate any project of yours. Use the form below to describe the project and we will get in touch with you within 1 business day.
Contact form
We will process your personal data as described in the privacy notice
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply
Contact us

USA +1 (917) 410-57-57
700 N Fairfax St Ste 614, Alexandria, VA, 22314 - 2040, United States

UK +44 (20) 3318-18-53
26/28 Hammersmith Grove, London W6 7HA

Poland +48 222 922 436
Warsaw, Poland, st. Elektoralna 13/103

Email us

[email protected]

to top