-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple file upload Flux<FilePart> error on the swagger-ui. Fixes #678
- Loading branch information
bnasslahsen
committed
Jun 7, 2020
1 parent
46dff5b
commit 86f57e2
Showing
5 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...gdoc-openapi-webflux-core/src/test/java/test/org/springdoc/api/app78/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* * Copyright 2019-2020 the original author or authors. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.app78; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import reactor.core.publisher.Flux; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.http.codec.multipart.FilePart; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class HelloController<T> { | ||
|
||
|
||
@PostMapping(value = "/files", produces = { MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) | ||
@Operation(summary = "files") | ||
public Flux<Void> handleFileUpload( | ||
@RequestPart("files") @Parameter(description = "files", | ||
content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) | ||
Flux<FilePart> filePartFux) throws IOException { | ||
File tmp = File.createTempFile("tmp", ""); | ||
return filePartFux.flatMap(filePart -> { | ||
Path path = Paths.get(tmp.toString() + filePart.filename()); | ||
System.out.println(path); | ||
return filePart.transferTo(path); | ||
}); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...c-openapi-webflux-core/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2020 the original author or authors. | ||
* * * * | ||
* * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * you may not use this file except in compliance with the License. | ||
* * * * You may obtain a copy of the License at | ||
* * * * | ||
* * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * | ||
* * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * See the License for the specific language governing permissions and | ||
* * * * limitations under the License. | ||
* * * | ||
* * | ||
* | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.app78; | ||
|
||
import test.org.springdoc.api.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
public class SpringDocApp78Test extends AbstractSpringDocTest { | ||
|
||
@SpringBootApplication | ||
@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app78" }) | ||
static class SpringDocTestApp {} | ||
} |
59 changes: 59 additions & 0 deletions
59
springdoc-openapi-webflux-core/src/test/resources/results/app78.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/files": { | ||
"post": { | ||
"tags": [ | ||
"hello-controller" | ||
], | ||
"summary": "files", | ||
"operationId": "handleFileUpload", | ||
"requestBody": { | ||
"content": { | ||
"multipart/form-data": { | ||
"schema": { | ||
"type": "object", | ||
"properties": { | ||
"files": { | ||
"type": "array", | ||
"description": "files", | ||
"items": { | ||
"type": "string", | ||
"format": "binary" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": {} | ||
} |