Altemiq.AspNetCore.OpenApi
9.0.8
dotnet add package Altemiq.AspNetCore.OpenApi --version 9.0.8
NuGet\Install-Package Altemiq.AspNetCore.OpenApi -Version 9.0.8
<PackageReference Include="Altemiq.AspNetCore.OpenApi" Version="9.0.8" />
<PackageVersion Include="Altemiq.AspNetCore.OpenApi" Version="9.0.8" />
<PackageReference Include="Altemiq.AspNetCore.OpenApi" />
paket add Altemiq.AspNetCore.OpenApi --version 9.0.8
#r "nuget: Altemiq.AspNetCore.OpenApi, 9.0.8"
#:package Altemiq.AspNetCore.OpenApi@9.0.8
#addin nuget:?package=Altemiq.AspNetCore.OpenApi&version=9.0.8
#tool nuget:?package=Altemiq.AspNetCore.OpenApi&version=9.0.8
Altemiq.AspNetCore.OpenApi
This contains methods to extend Microsoft.AspNetCore.OpenApi
with extra functionality
OpenApi
SetInfo
This sets the information for the document
services.AddOpenApi(options => options.SetInfo("API Title"));
results in
"info": {
"title": "API Title | v1",
"version": "1.0.0.0"
}
UsePathBase
This sets the path base for the service section
services.AddOpenApi(options => options.UsePathBase("/api"));
results in
"servers": [
{
"url": "/api"
}
]
Add* (SecurityScheme)
This adds and returns the added security scheme
AddApiKey
services.AddOpenApi(options => options.AddApiKey());
AddHttp
services.AddOpenApi(options => options.AddHttp());
AddOAuth2
services.AddOpenApi(options =>
{
var scheme = options.AddOAuth2(
new Microsoft.OpenApi.Models.OpenApiOAuthFlows
{
Password = new Microsoft.OpenApi.Models.OpenApiOAuthFlow
{
Scopes =
{
["first"] = "First Scope",
["second"] = "Second Scope",
["third"] = "Third Scope",
["forth"] = "Forth Scope",
},
},
});
});
AddOpenIdConnect
services.AddOpenApi(options => options.AddOpenIdConnect("http://auth.local.dev/.well-known/openid-configuration"));
WithAuthorizeCheck
This adds a check to see if the end point has any IAuthorizeData
metadata, and if so, adds the standard responses. This also adds the specified security scheme to the end point, and also configures the requirements for the scheme.
services.AddOpenApi(options => options.WithAuthorizeCheck(securityScheme));
This takes into account the scopes specified if the scheme is either OAuth2
or OpenIdConnect
HTTP
This extends IEndpointConventionBuilder
to include extra metadata
WithScopes
/ ScopesAttribute
Adds scopes to the authorization.
app
.MapGet("requires-scopes", () => "Requires Scopes")
.RequireAuthorization()
.WithScopes("first", "second");
[ApiController]
[Route("controllers/[controller]")]
public class WeatherForecastController : ControllerBase
{
[HttpGet(Name = "GetWeatherForecast")]
[Microsoft.AspNetCore.Authorization.Authorize]
[Scopes("third", "forth")]
public IEnumerable<WeatherForecast> Get() => WeatherForecast.Get();
}
This will only be taken into account if the end point requires authorization.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net9.0
- Altemiq.OpenApi (>= 1.6.17)
- Microsoft.AspNetCore.OpenApi (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.