![]() |
VOOZH | about |
dotnet add package Swashbuckle.AspNetCore.Community.OData --version 2.0.1
NuGet\Install-Package Swashbuckle.AspNetCore.Community.OData -Version 2.0.1
<PackageReference Include="Swashbuckle.AspNetCore.Community.OData" Version="2.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore.Community.OData" Version="2.0.1" />Directory.Packages.props
<PackageReference Include="Swashbuckle.AspNetCore.Community.OData" />Project file
paket add Swashbuckle.AspNetCore.Community.OData --version 2.0.1
#r "nuget: Swashbuckle.AspNetCore.Community.OData, 2.0.1"
#:package Swashbuckle.AspNetCore.Community.OData@2.0.1
#addin nuget:?package=Swashbuckle.AspNetCore.Community.OData&version=2.0.1Install as a Cake Addin
#tool nuget:?package=Swashbuckle.AspNetCore.Community.OData&version=2.0.1Install as a Cake Tool
👁 GitHub Actions Status
👁 Swashbuckle.AspNetCore.Community.OData NuGet Package Downloads
👁 GitHub Actions Build History
The most comprehensive OpenAPI (Swagger) documentation generator for ASP.NET Core OData APIs.
Provides full support for OData query options ($filter, $select, $expand, etc.), real endpoint-based path generation, and seamless Swashbuckle integration.
<img src="./Images/swagger-ui-demo.webp" alt="Swagger UI demo" width="800" />
If animation is not shown in your Markdown viewer, open directly.
Start with for the canonical reference and for change history and breaking changes.
AddEnhancedSwaggerGenOData* is the default API path. AddSwaggerGenOData remains only as an obsolete compatibility shim.
$filter, $select, $expand, $orderby, $top, $skip, $count, $search$value, $refdotnet add package Swashbuckle.AspNetCore.Community.OData
public void ConfigureServices(IServiceCollection services)
{
// Add OData with query features
services.AddControllers()
.AddOData(o => o
.AddRouteComponents("odata", GetEdmModel())
.EnableQueryFeatures(100)
);
// Add enhanced OData Swagger with query options
services.AddEnhancedSwaggerGenODataWithQueryOptions(
odataSetupAction: opt =>
{
opt.SwaggerDoc(
"v1",
"odata",
new OpenApiInfo
{
Title = "My OData API",
Version = "v1",
Description = "Full OData query support with $filter, $select, $expand!"
}
);
},
queryOptionsSettings: new ODataQueryOptionsSettings
{
EnableFilter = true,
EnableSelect = true,
EnableExpand = true,
MaxTop = 100,
FilterExample = "Name eq 'John' and Age gt 18"
}
);
// Add Swashbuckle services
services.AddSwaggerGen();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
// Enable Swagger
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My OData API v1");
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
private static IEdmModel GetEdmModel()
{
var builder = new ODataConventionModelBuilder();
builder.EntitySet<Product>("Products");
return builder.GetEdmModel();
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers()
.AddOData(o => o
.AddRouteComponents("odata", GetEdmModel())
.EnableQueryFeatures(100));
builder.Services.AddEnhancedSwaggerGenODataWithQueryOptions(
odataSetupAction: opt =>
{
opt.SwaggerDoc("v1", "odata", new OpenApiInfo
{
Title = "My OData API",
Version = "v1"
});
});
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My OData API v1"));
app.MapControllers();
app.Run();
$filter, $select, $expand, etc./Products(1)/Name), $value, $ref pathsTrack current release status in . See for detailed feature documentation.
| Feature | Basic EDM | OData's Sample | Enhanced Swashbuckle |
|---|---|---|---|
| OData Query Options | ❌ | ❌ | ✅ Full support |
| Real Endpoint Paths | ❌ | ✅ | ✅ + Enhanced |
| Property Access Paths | ❌ | ❌ | ✅ Added |
| $value/$ref Paths | ❌ | ❌ | ✅ Added |
| Method Overloads | ❌ | ⚠️ | ✅ Full |
| Swashbuckle Integration | ✅ | ❌ | ✅ Native |
paths:
/Products:
get:
summary: Get entities from Products
parameters:
- name: $filter
in: query
description: Filter using OData expressions
example: "Name eq 'John' and Price gt 100"
- name: $select
in: query
description: Select specific properties
example: "Name,Price,Category"
- name: $expand
in: query
description: Expand related entities
example: "Category,Orders"
- name: $top
in: query
schema:
type: integer
maximum: 100
post:
summary: Create a new Product
/Products({key}):
get:
summary: Get Product by key
put:
summary: Update Product (full)
patch:
summary: Update Product (partial with Delta)
delete:
summary: Delete Product
/Products({key})/Category/$ref:
get:
summary: Get Category reference
put:
summary: Update Category reference
delete:
summary: Remove Category reference
services.AddEnhancedSwaggerGenODataWithQueryOptions(
odataSetupAction: opt =>
{
opt.SwaggerDoc("v1", "odata", new OpenApiInfo { Title = "Public API", Version = "v1" });
opt.SwaggerDoc("internal", "internal", new OpenApiInfo { Title = "Internal API", Version = "v1" });
},
queryOptionsSettings: new ODataQueryOptionsSettings
{
MaxTop = 1000,
EnableSearch = true,
FilterExample = "CreatedDate gt 2023-01-01"
}
);
services.AddEnhancedSwaggerGenOData(opt =>
{
opt.SwaggerDoc("odata", "odata", new OpenApiInfo { Title = "OData API", Version = "v1" });
});
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("rest", new OpenApiInfo { Title = "REST API", Version = "v1" });
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { ... });
});
git clone https://github.com/Tiberriver256/Swashbuckle.AspNetCore.Community.OData.git
cd Swashbuckle.AspNetCore.Community.OData
dotnet restore
dotnet build
dotnet test
Contributions are welcome. Please read our .
For behavior-affecting changes, contributions are expected to include:
README.md and/or DOCUMENTATION.md)RELEASE_NOTES.md when appropriateThis project is licensed under the MIT License - see the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.