1

I'm using the last (and only)

 <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
 </dependency>

with spring boot

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.1</version>
    <relativePath/> <!-- lookup parent from repository -->
 </parent>

I would like to have ability to upload file and model in one controller, so I created one: image

in this case on swagger-ui I see only file uploading without model: image

I tried this case in postman and it works fine image

Is it a bug? Or should I add some other annotations to make it work?

Konstantin
  • 97
  • 5

1 Answers1

2

The problem was in Configuration class, in Docket Bean. Here I'm defining route to my Controllers to exclude others from swagger-ui. The problem was in DocumentationType, OpenApi3.0 is maintaining multitype files uploading, and Swagger2 don't.

enter image description here

Next problem which I faced was:

415 Unsupported Media Type

Resolution:

First way: If you will use postman/javaScript framework -> you have to define media-type of every RequestPart (actually don't need for file, for file it will be set automatically). example in POSTMAN: enter image description here

Second way: is implement maintaining of octet-stream, because spring set it by default in AbstractMessageConverterMethodArgumentResolver.class if there is no content-type header in request part. (I'm using spring-boot-starter-parent 2.4.1 -> spring-webmvc 5.3.2) Y

So here is 2 cases I found (to map response JSON to DTO):

1 case (not recommended): Set supporting to JSON converter: enter image description here

2 case: Define new Converter class which will work definitely for needed classes (in my case it is MDVersionDTO.class) and definitely when it comes like octet-stream, to implement it, ovveride canRead() method. enter image description here

Konstantin
  • 97
  • 5