Closed as duplicate of#56021
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Microsoft.AspNetCore.OpenApi.OpenApiSchemaStore
prepopulate the Stream
schema (note that it doesn't use the latest openapi representation but that would be an enhancement) but the key uses parameterinfo (set to null by default) so the getoradd in the store fails cause when using [FromBody] Stream body
there is a parameter info.
Note that setting Stream
as metadata to avoid to have a parameter fails in Microsoft.AspNetCore.OpenApi.OpenApiSchemaService.GetOrCreateSchemaAsync
cause there is an api description so it still tries to lookup a JsonTypeInfo
.
TIP: using this code can workaround the issue in an ugly manner:
[JsonSourceGenerationOptions]
[JsonSerializable(typeof(Stream))] // make GetOrCreateSchemaAsync happy (ApplyParameterInfo)
public partial class OpenApiWorkaroundForStream : JsonSerializerContext;
builder.Services.ConfigureHttpJsonOptions(o => o
.SerializerOptions
.TypeInfoResolverChain
.Add(OpenApiWorkaroundForStream.Default));
app
.MapPost(....)
.WithMetadata(new AcceptsMetadata(["application/octect-stream"], typeof(Stream))); // no param so hardcoded schema is used
Expected Behavior
The Stream
schema is looked up as expected
Steps To Reproduce
use an minimal api endpoint with request body in parameters
Exceptions (if any)
No response
.NET Version
9
Anything else?
No response