1

I am trying to create a swagger documentation for some REST API Calls. The POST method in one of the API Calls accept a multi-part form data content with 1st part as binary file data and 2nd part as json instance. I am looking for a way to allow the users accessing the swagger ui to enter the value of the Content-Disposition header and the Content-Range header for the 1st part of the multi-part form data content only. I have tried to use the Header Object inside the Encoding Object but it did not create any change in the swagger-ui. I was expecting to get a parameter field for the header inside the request body like the request header parameters given by the parameter list. Maybe I am missing something. If this is not the right way, is there any other way through which I can make this happen? Thanks in advance.

Here is the part of the swagger.json with the request body :

{
    "requestBody": {
        "content": {
            "multipart/form-data": {
                "schema": {
                    "type": "object",
                    "properties": {
                        "file": {
                            "type": "string",
                            "format": "binary"
                        },
                        "instance": {
                            "type": "object",
                            "properties": {
                                "fileName": {
                                    "type": "string"
                                },
                                "fileType": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                },
                "encoding": {
                    "file": {
                        "headers": {
                            "content-disposition": {
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "content-range": {
                                 "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Expected Result: A parameter field for each of the header inside the request Body.

Actual Result: No such parameter field comes up in the swagger ui.

  • 1
    Currently Swagger UI does not support `encoding` and `headers` for multipart bodies. Please open an issue at https://github.com/swagger-api/swagger-ui/issues/new/choose. – Helen Jan 28 '19 at 21:09

0 Answers0