Redocly / redoc

📘 OpenAPI/Swagger-generated API Reference Documentation
https://redocly.github.io/redoc/
MIT License
23.54k stars 2.3k forks source link

Support request samples for JSON parts in multipart/form-data requests #707

Open gyszalai opened 5 years ago

gyszalai commented 5 years ago

We have an API with an endpoint that handles file uploads. The endpoint accepts multipart/form-data requests with two parts being a json content in the first part and binary file data in the second part. We would like to give a request sample to the first (JSON) part.

We use openapi 3.0.0 spec, the request definition looks like this:

requestBody:
    required: true
    content:
        multipart/form-data:
            schema:
                type: object
                properties:
                    meta:
                        $ref: './meta.schema.json'
                    attachment:
                        type: string
                        format: binary
                        required: true
                required:
                - meta
                - attachment
            encoding:
                meta:
                    contentType: application/json; charset=utf-8

The meta schema contains an example, and it renders correctly if the request body is application/json. Are we doing something wrong or ReDoc does not support our use case? Thanks!

RomanHotsiy commented 5 years ago

You're doing nothing wrong. ReDoc just doesn't support your use case yet.

bautrukevich commented 5 years ago

@RomanGotsiy Can I make PR to fix this issue? Because I need this feature too. Please, can you explain, what is the problem with it? And where I can fix that? Thank you.

jthiel1996 commented 5 years ago

I am seeing the same issue described by gyszalai on Nov 10, 2018 Here is what i tried to do:

  1. npm install redoc --save . To reinstall Redoc. I still get the error.
  2. Attempted to use code from CDN () assuming that this had latest.

Is there a third way that I need to do this to get the fix?

jessevdp commented 4 years ago

I noticed that the PR that would supposedly implement support for this was closed without merging. Any reason for that?

Simon-Gregory-LG commented 3 years ago

I'll add my voice to those that think multipart support is a must

agaertner commented 3 years ago

We are using ReDoc and would like to see this supported as well. Multipart/form-data is very common.

MarcLevisse commented 3 years ago

on my side, I have the following example that displays (badly, stylesheet issue I guess) :

"requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "oneshotEtl": {
                                        "$ref": "#/components/schemas/etl-oneshot-create"
                                    },
                                    "inputFile": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                }
                            },
                            "examples": {
                                "oneshot-etl-execution-provided" : {
                                    "value": {
                                        "test": "test"
                                    }
                                }
                            }
                        },

multipart-redoc-json-and-binary

reubenur-rahman commented 3 years ago

+1 We had to add a bad warning message for the customer to not try the upload API from redocly portal and instead asked them to use their favorite REST tool. I wonder that being a production-ready software this minimal feature is not implemented for the last 2 years!

Layap commented 2 years ago

Is multipart/form-data request and response supported in redocly (the premium version)?

gmile commented 2 years ago

@Layap no sure about the premium version, but as of RC.76 it's still not supported it seems (just tested it)

rajendra-kumar-kandpal commented 1 year ago

hello there

is there an update to support this? or there are no plans yet Please let me know, thanks!

DanielRasho commented 5 days ago

Hi, I want to add up to the people that think this will be a really useful feature.