fermyon / spin-dotnet-sdk

Apache License 2.0
43 stars 11 forks source link

async minimal apis throw Exception at runtime #60

Closed bacongobbler closed 3 months ago

bacongobbler commented 3 months ago

Given a minimal API endpoint such as the following:

app.MapPost("/", async ([FromServices] IMyService myService) =>
{
    app.Logger.LogInformation("doing something");
    await myService.DoSomething();
    app.Logger.LogInformation("completed something");
    return "";
});

Results in an error at runtime:

Unhandled exception. System.AggregateException: One or more errors occurred. (JsonTypeInfo metadata for type 'System.Threading.Tasks.Task`1[System.String]' was not provided by TypeInfoResolver of type '[SpinHttpWorld.wit.exports.wasi.http.v0_2_0.AppJsonSerializerContext, Microsoft.AspNetCore.OpenApi.OpenApiJsonSchemaContext]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.)