Skip to content

Commit

Permalink
Handle parameters of type Stream and PipeReader
Browse files Browse the repository at this point in the history
Do not generate schema models for `Stream` and `PipeReader`.
See dotnet/aspnetcore#44677 (comment).
  • Loading branch information
kellystar999 committed Apr 13, 2024
1 parent 0e88fa0 commit 587fb68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ private OpenApiSchema GeneratePolymorphicSchema(
{
typeof(IFormFile),
typeof(FileResult),
typeof(System.IO.Stream),
#if NETCOREAPP3_0_OR_GREATER
typeof(System.IO.Pipelines.PipeReader),
#endif
};

private OpenApiSchema GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class NewtonsoftSchemaGeneratorTests
[Theory]
[InlineData(typeof(IFormFile))]
[InlineData(typeof(FileResult))]
public void GenerateSchema_GeneratesFileSchema_IfFormFileOrFileResultType(Type type)
[InlineData(typeof(System.IO.Stream))]
public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type)
{
var schema = Subject().GenerateSchema(type, new SchemaRepository());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public class JsonSerializerSchemaGeneratorTests
[Theory]
[InlineData(typeof(IFormFile))]
[InlineData(typeof(FileResult))]
public void GenerateSchema_GeneratesFileSchema_IfFormFileOrFileResultType(Type type)
[InlineData(typeof(System.IO.Stream))]
[InlineData(typeof(System.IO.Pipelines.PipeReader))]
public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type)
{
var schema = Subject().GenerateSchema(type, new SchemaRepository());

Expand Down

0 comments on commit 587fb68

Please sign in to comment.