File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/main/kotlin/com/cosmotech/api/config Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) Cosmo Tech.
2+ // Licensed under the MIT license.
3+ package com.cosmotech.api.config
4+
5+ import org.springframework.context.annotation.Configuration
6+ import org.springframework.http.MediaType
7+ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
8+
9+ /* *
10+ * This class is here as a suggested workaround for the following issues. Swagger UI does not handle
11+ * multipart requests correctly even if `encoding` property is set in openapi.yaml Each part of a
12+ * multipart/form-data is sent with a content-type set to application/octet-stream The following
13+ * workaround adds application/octet-stream has a supported MediaType for the
14+ * MappingJackson2HttpMessageConverter https://github.com/swagger-api/swagger-ui/issues/6462
15+ * https://github.com/swagger-api/swagger-ui/issues/5356
16+ * https://github.com/swagger-api/swagger-ui/issues/9548
17+ * https://github.com/swagger-api/swagger-ui/issues/6462
18+ * https://github.com/swagger-api/swagger-ui/issues/9548
19+ */
20+ @Configuration
21+ open class SwaggerBeanConfiguration (converter : MappingJackson2HttpMessageConverter ) {
22+
23+ init {
24+ val supportedMediaTypes = ArrayList <MediaType ?>(converter.supportedMediaTypes)
25+ supportedMediaTypes.add(MediaType (" application" , " octet-stream" ))
26+ converter.supportedMediaTypes = supportedMediaTypes
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments