AspNet.Evaluation.OpenAPI
0.0.1-pre-cc8c3194
See the version list below for details.
dotnet add package AspNet.Evaluation.OpenAPI --version 0.0.1-pre-cc8c3194
NuGet\Install-Package AspNet.Evaluation.OpenAPI -Version 0.0.1-pre-cc8c3194
<PackageReference Include="AspNet.Evaluation.OpenAPI" Version="0.0.1-pre-cc8c3194" />
paket add AspNet.Evaluation.OpenAPI --version 0.0.1-pre-cc8c3194
#r "nuget: AspNet.Evaluation.OpenAPI, 0.0.1-pre-cc8c3194"
// Install AspNet.Evaluation.OpenAPI as a Cake Addin #addin nuget:?package=AspNet.Evaluation.OpenAPI&version=0.0.1-pre-cc8c3194&prerelease // Install AspNet.Evaluation.OpenAPI as a Cake Tool #tool nuget:?package=AspNet.Evaluation.OpenAPI&version=0.0.1-pre-cc8c3194&prerelease
OpenAPI.Evaluation.AspNet
Adds ASP.NET support for OpenAPI.Evaluation.
Installation
dotnet add package AspNet.Evaluation.OpenAPI
https://www.nuget.org/packages/AspNet.Evaluation.OpenAPI/
Getting Started
Load and register the OpenAPI specification, see OpenAPI.Evaluation for more details.
var builder = WebApplication.CreateBuilder(args);
using var openApiStream = File.OpenRead("path/to/openapi-specification.json");
var specification = OpenAPI.Evaluation.Specification.OpenAPI.Parse(JsonNode.Parse(openApiStream));
builder.Services.AddOpenApiEvaluation(specification);
var app = builder.Build();
// Register evaluation into the request pipeline
app.UseOpenApiEvaluation();
// Register route handlers
...
Evaluating From a Route Handler
HttpContext
has some extension methods which can be used to evaluate the current request and response.
app.Run(context =>
{
var requestEvaluationResult = context.EvaluateRequest();
...
var responseCode = ...
IHeaderDictionary responseHeaders = ...
var responseContent = ...
var responseEvaluation = context.EvaluateResponse(responseCode, responseHeaders, responseContent);
...
return Task.CompletedTask;
});
Response Evaluation Caviat
Be aware that once response headers have been sent over the wire the response can no longer be changed. If you want to evaluate using the response make sure it's buffered. It's recommended to evaluate the response before setting it in the http context that way if evaluation fails it's possible to return a proper response or abort the request without leaking invalid information to the client.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- Evaluation.OpenAPI (>= 0.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.2 | 368 | 11/14/2023 |
0.0.2-pre-86f234d2 | 157 | 11/3/2023 |
0.0.2-pre-05fe66fd | 112 | 11/14/2023 |
0.0.1 | 165 | 10/20/2023 |
0.0.1-pre-cc8c3194 | 147 | 10/20/2023 |
0.0.1-pre-4f831d12 | 122 | 10/19/2023 |
## v0.0.1-pre-cc8c3194 (2023-10-20)