CoreSystem.OpenApi 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CoreSystem.OpenApi --version 1.0.0
                    
NuGet\Install-Package CoreSystem.OpenApi -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoreSystem.OpenApi" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreSystem.OpenApi" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CoreSystem.OpenApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoreSystem.OpenApi --version 1.0.0
                    
#r "nuget: CoreSystem.OpenApi, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoreSystem.OpenApi@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoreSystem.OpenApi&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CoreSystem.OpenApi&version=1.0.0
                    
Install as a Cake Tool

🧭 CoreSystem.OpenApi

Generate the OpenAPI document once. Reuse the conventions everywhere.

CoreSystem.OpenApi provides the OpenAPI and Swagger infrastructure shared by CoreSystem-based APIs on .NET 8, .NET 9 and .NET 10. It owns the document wiring, the response attributes and the filters, while each application keeps its own title, servers, examples and error vocabulary.

NuGet Downloads License .NET


✨ Features

  • ✅ One-call Swagger generation wiring (AddCoreOpenApi) and hosting (UseCoreOpenApi)
  • ✅ Bearer security scheme applied to every operation
  • ✅ ProducesOk<T>, ProducesCreated<T> and ProducesNoContent response attributes
  • ✅ Location header documented on every 201 Created response
  • ✅ Redundant text/plain and text/json representations removed
  • ✅ Shared problem-details responses declared once as $ref components
  • ✅ Configurable error codes, type URIs, examples and schemas
  • ✅ Patched document cached in memory instead of rebuilt per request
  • ✅ Invalid JSON is returned unchanged, so the patcher is safe to compose

📦 Installation

dotnet add package CoreSystem.OpenApi

🚀 Quick Start

Register the document and map the endpoint:

using Core.OpenApi.DependencyInjection;
using Core.OpenApi.Extensions;
using Core.OpenApi.Options;

builder.Services.AddCoreOpenApi(options =>
{
    options.Title = "Orders API";
    options.Description = "Order management endpoints";
    options.Servers.Add(new OpenApiServerDescriptor
    {
        Url = "https://api.example.com",
        Description = "Production"
    });
});

var app = builder.Build();

app.UseCoreOpenApi();

The application now serves:

Route Content
/swagger/v1/swagger.json The patched document
/swagger Swagger UI
swagger-original/v1/swagger.json The unpatched generator output

Annotate controllers with the response attributes:

using Core.OpenApi.Attributes;

[HttpPost]
[ProducesCreated<OrderResponse>]
public async Task<IActionResult> Create(CreateOrderRequest request)

⚙️ Problem Responses

Every configured error response is declared once in components.responses and referenced from the operations that already document the status code:

builder.Services.AddCoreOpenApi(options =>
{
    options.ProblemResponses.SchemaId = "AppProblemDetails";
    options.ProblemResponses.TypePrefix = "urn:orders:error:";
    options.ProblemResponses.TraceIdExample =
        "00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01";

    // Rate limiting is applied to every endpoint, so document 429 everywhere.
    options.ProblemResponses.Definitions
        .Single(definition => definition.StatusCode == "429")
        .IncludeWhenMissing = true;
});

IncludeWhenMissing is false by default, so a status code is only added to operations that already declare it. Set it to true only when the corresponding middleware really applies to the whole API.

An existing 400 response is replaced only when it already looks like a problem response (application/problem+json, or a schema reference to one of the configured problem schemas). That keeps a custom validation payload untouched.


🔌 Extending the Generator

Features that live in other packages stay out of this one. Use the callback:

using Swashbuckle.AspNetCore.Annotations;
using Swashbuckle.AspNetCore.Filters;

builder.Services.AddCoreOpenApi(options =>
{
    options.ConfigureSwaggerGen = gen =>
    {
        gen.EnableAnnotations();
        gen.ExampleFilters();
    };
});

The same pattern applies to the JSON endpoint, for example to keep it out of the rate limiter and out of the document:

builder.Services.AddCoreOpenApi(options =>
{
    options.ConfigureJsonEndpoint = endpoint => endpoint
        .DisableRateLimiting()
        .ExcludeFromDescription();
});

📖 Public API

Type Description
AddCoreOpenApi() Registers Swagger generation, the filters and the options.
UseCoreOpenApi() Maps the patched document endpoint and configures Swagger UI.
CoreOpenApiOptions Title, servers, security, XML comments and callbacks.
OpenApiProblemResponsesOptions The shared problem response catalog.
ProblemResponseDefinition One response: status code, component, error code and example.
OpenApiDocumentPatcher Applies the catalog to a serialized document.
JsonOnlyResponsesOperationFilter Removes redundant text media types.
CreatedWithLocationDocumentFilter Documents the Location header on 201.
ProducesOk<T> / ProducesCreated<T> / ProducesNoContent Response attributes.

📚 Documentation

  • Getting Started
  • Configuration
  • Problem Responses

🤝 Contributing

Issues, discussions and pull requests are welcome.


📄 License

Released under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CoreSystem.OpenApi:

Package Downloads
CoreSystem.OpenApi.Swashbuckle

Reusable OpenAPI and Swagger infrastructure for ASP.NET Core APIs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 76 11/17/2026
2.1.0 180 11/10/2026
2.0.0 164 11/7/2026
1.0.0 105 11/1/2026

Initial release. Swagger generation wiring, response attributes, operation and document
filters, and a configurable OpenAPI document patcher that turns inline error responses
into shared component references.