Language

InvocationHandler.GetAsyncApiJsonAsync Method

Definition

Handles GET /invocations/docs/asyncapi.json. Returns 404 by default. Override to return an AsyncAPI (JSON) spec for the agent's event-driven contract (e.g. the invocations_ws WebSocket protocol) — the AsyncAPI companion to GetOpenApiAsync(HttpRequest, HttpResponse, CancellationToken) for streaming/bidirectional surfaces that OpenAPI cannot express.

public virtual System.Threading.Tasks.Task GetAsyncApiJsonAsync(Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.AspNetCore.Http.HttpResponse response, System.Threading.CancellationToken cancellationToken);
abstract member GetAsyncApiJsonAsync : Microsoft.AspNetCore.Http.HttpRequest * Microsoft.AspNetCore.Http.HttpResponse * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.GetAsyncApiJsonAsync : Microsoft.AspNetCore.Http.HttpRequest * Microsoft.AspNetCore.Http.HttpResponse * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function GetAsyncApiJsonAsync (request As HttpRequest, response As HttpResponse, cancellationToken As CancellationToken) As Task

Parameters

request
HttpRequest

The incoming HTTP request.

response
HttpResponse

The outgoing HTTP response.

cancellationToken
CancellationToken

A token to observe for cancellation.

Returns

A task representing the async operation.

Remarks

The path extension is authoritative for the returned content type — no Accept negotiation and no format conversion between the JSON and YAML representations. Override GetAsyncApiYamlAsync(HttpRequest, HttpResponse, CancellationToken) independently; publishing both is recommended for tooling compatibility.

When overriding, you MUST set StatusCode explicitly. This method returns 404 by default; once you override it the default no longer runs (unless the override calls base.GetAsyncApiJsonAsync(...) / base.GetAsyncApiYamlAsync(...)), so if you forget to set a status the response defaults to 200 with whatever body you wrote (or empty).

Applies to