From 4f62ea57f9d5399d44e9cfe3ff0b147c7f09111d Mon Sep 17 00:00:00 2001 From: Tao Sun Date: Wed, 17 Jul 2024 14:02:25 +0800 Subject: [PATCH 1/2] Add Encoding to multiple files and JSON payloads request test case. Fixes #2649 --- .../test/org/springdoc/api/v30/app119/HelloController.java | 5 ++++- .../src/test/resources/results/3.0.1/app119.json | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java index f403d4fce..22d058493 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java @@ -27,6 +27,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Encoding; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; @@ -44,7 +46,8 @@ public class HelloController { produces = MediaType.TEXT_PLAIN_VALUE) public String multiFilesInMultiPart( @RequestPart("params") - @Parameter( + @RequestBody(content = @Content(encoding = @Encoding(name="params", contentType=MediaType.APPLICATION_JSON_VALUE))) + @Parameter( description = "This is the configuration", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) final JsonRequest jsonRequest, @RequestPart(value = "file1", required = false) @Parameter(description = "This is file1") final MultipartFile file1, diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app119.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app119.json index a377e00fb..5f03c5312 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app119.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app119.json @@ -41,6 +41,11 @@ "$ref": "#/components/schemas/JsonRequest" } } + }, + "encoding": { + "params": { + "contentType": "application/json" + } } } } From 08e6ad4646815772a7daf0c067289c64dc06c06b Mon Sep 17 00:00:00 2001 From: Tao Sun Date: Thu, 18 Jul 2024 14:52:44 +0800 Subject: [PATCH 2/2] Replace space with tab --- .../java/test/org/springdoc/api/v30/app119/HelloController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java index 22d058493..6a0385656 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java @@ -47,7 +47,7 @@ public class HelloController { public String multiFilesInMultiPart( @RequestPart("params") @RequestBody(content = @Content(encoding = @Encoding(name="params", contentType=MediaType.APPLICATION_JSON_VALUE))) - @Parameter( + @Parameter( description = "This is the configuration", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) final JsonRequest jsonRequest, @RequestPart(value = "file1", required = false) @Parameter(description = "This is file1") final MultipartFile file1,