Skip to content

Commit 802596d

Browse files
committed
improve docs
1 parent b2807d2 commit 802596d

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

docs/modules/ROOT/pages/processor/requestbody.adoc

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ and a `Book` pojo.
6060

6161
== multipart/form-data
6262

63-
[.badge .badge-since]+since 1.0.0.M5+
64-
6563
For file uploads, where the `content` of the `requestBody` is `multipart/form-data`, the resulting
6664
code looks a bit different and requires a specific type mapping.
6765

@@ -142,3 +140,48 @@ to get the following code:
142140
@PostMapping(path = "/file-upload")
143141
ResponseEntity<Void> postFileUpload(@RequestParam(name = "files") MultipartFile[] files);
144142
----
143+
144+
=== multi-part encoding
145+
146+
[.badge .badge-since]+since 2021.4+
147+
148+
the parsing step extracts the `encoding/contentType` of a multipart content. This allows a processor to consider the encoding content type when selecting the annotation for the part.
149+
150+
the Spring processor uses this to select between `@RequestPart` and `@RequestParam` annotation. If an `encoding/contentType` is available it will use `@RequestPart`, if no `encoding/contentType` is available it will use `@RequestParam`.
151+
152+
[source,yaml]
153+
----
154+
openapi: 3.0.2
155+
info:
156+
title: params-request-body-multipart
157+
version: 1.0.0
158+
159+
paths:
160+
/multipart:
161+
post:
162+
requestBody:
163+
required: true
164+
content:
165+
multipart/form-data:
166+
schema:
167+
type: object
168+
properties:
169+
file:
170+
type: string
171+
format: binary
172+
json:
173+
type: object
174+
properties:
175+
foo:
176+
type: string
177+
bar:
178+
type: string
179+
encoding:
180+
file:
181+
contentType: application/octet-stream
182+
json:
183+
contentType: application/json
184+
responses:
185+
'204':
186+
description: empty
187+
----

0 commit comments

Comments
 (0)