Swashbuckle.AspNetCore.JsonMultipartFormDataSupport
1.1.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Swashbuckle.AspNetCore.JsonMultipartFormDataSupport --version 1.1.2
NuGet\Install-Package Swashbuckle.AspNetCore.JsonMultipartFormDataSupport -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Swashbuckle.AspNetCore.JsonMultipartFormDataSupport" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Swashbuckle.AspNetCore.JsonMultipartFormDataSupport --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Swashbuckle.AspNetCore.JsonMultipartFormDataSupport, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Swashbuckle.AspNetCore.JsonMultipartFormDataSupport as a Cake Addin #addin nuget:?package=Swashbuckle.AspNetCore.JsonMultipartFormDataSupport&version=1.1.2 // Install Swashbuckle.AspNetCore.JsonMultipartFormDataSupport as a Cake Tool #tool nuget:?package=Swashbuckle.AspNetCore.JsonMultipartFormDataSupport&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Swashbuckle.AspNetCore.JsonMultipartFormDataSupport
Adds support for json in multipart/form-data requests.
Usage
- Simple add this to your
ConfigureServices
services.AddJsonMultipartFormDataSupport();
Or manually:
- Binder
services
.AddMvc(
properties => {
// ...
properties.ModelBinderProviders.Insert(0, new FormDataJsonBinderProvider()); // Here
}
)
- Operation filter
services.AddSwaggerGen(c => {
c.OperationFilter<MultiPartJsonOperationFilter>();
});
- Add to your
Controller
[HttpPost]
[Consumes("multipart/form-data")]
public async Task<IActionResult> Post([FromForm] MultipartFormData<Product> multiPartData) {
var file = multiPartData.File;
var product = multiPartData.Json;
}
or
[HttpPost]
[Consumes("multipart/form-data")]
public async Task<IActionResult> Post([FromForm] MultipartRequiredFormData<Product> multiPartData) {
var file = multiPartData.File;
var product = multiPartData.Json;
}
Or you can create your on wrapper
public class MyWrapper {
[FromJson] // <-- This attribute is required for binding.
public MyModel Json { get; set; }
public IFormFile File { get; set; }
}
and then
[HttpPost]
[Consumes("multipart/form-data")]
public async Task<IActionResult> Post([FromForm] MyWrapper myWrapper) {
// code
}
Notes:
It automatically adds examples from class which implements IExampleProvider<MyModel>
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.2 is compatible. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 2.2
- Microsoft.AspNetCore.Http.Features (>= 2.2.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Newtonsoft.Json (>= 12.0.2)
- Swashbuckle.AspNetCore.Filters (>= 5.0.0-rc8)
- Swashbuckle.AspNetCore.SwaggerGen (>= 5.0.0-rc3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Swashbuckle.AspNetCore.JsonMultipartFormDataSupport:
Repository | Stars |
---|---|
caioavidal/OpenCoreMMO
Modern MMORPG server emulator written in C#
|
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 398 | 11/17/2024 |
1.10.1 | 158 | 11/15/2024 |
1.10.0 | 1,323 | 10/22/2024 |
1.9.0 | 56,595 | 12/17/2023 |
1.8.0 | 82,253 | 1/25/2023 |
1.7.1 | 21,341 | 7/24/2022 |
1.7.0 | 23,465 | 4/14/2022 |
1.6.1 | 10,245 | 11/2/2021 |
1.6.0 | 378 | 10/31/2021 |
1.5.0 | 3,846 | 6/28/2021 |
1.4.2 | 38,214 | 9/22/2020 |
1.4.1 | 46,296 | 6/20/2020 |
1.4.0 | 3,974 | 4/6/2020 |
1.3.0 | 1,969 | 1/13/2020 |
1.2.3 | 563 | 1/10/2020 |
1.2.2 | 605 | 1/9/2020 |
1.2.1 | 617 | 1/9/2020 |
1.2.0 | 597 | 1/9/2020 |
1.1.2 | 598 | 11/25/2019 |
1.1.1 | 565 | 11/6/2019 |
1.1.0 | 589 | 10/29/2019 |
1.0.1 | 604 | 9/25/2019 |
1.0.0 | 620 | 9/25/2019 |
- Fixed bug, when there was not ExmapleProvider for given [FromJson] class.