Error when using multipart/form-data and setting specific content-Type in stoplight

559 Views Asked by At

I have an API where I have to pass both file and an object. The API is working properly in postman. Following image shows how I have done this in postman. enter image description here

I am trying to do the same thing in stoplight. I have written the following code in yaml file.

content:
    multipart/form-data:
      schema:
        type: object
        properties:
          files:
            type: string
            format: binary
          data:
            type: object
      encoding:
        data:
          contentType: apllication/json

When I run the API in stoplight I get following error. enter image description here

I have followed this link https://swagger.io/docs/specification/describing-request-body/multipart-requests/. Anyone know how can I solve this problem? Thanks!

1

There are 1 best solutions below

1
On

I am guessing this is about mocking your API via Stoplight. If yes, this looks like something that Stoplight mock doesn't support yet.

Also, you don't need to specify the contentType if you are using the default types. One potential issue I can see is that your data parameter is marked as object but doesn't have any properties defined.