diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs index 0c937612..d9349be7 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs @@ -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) diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs index 58b91c44..040380ed 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs @@ -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()); diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs index 30da476c..efa3f7ad 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs @@ -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());