Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0-preview-0651 Multiple File Upload Support #902

Closed
saurabhrajguru opened this issue Oct 8, 2018 · 5 comments
Closed

4.0.0-preview-0651 Multiple File Upload Support #902

saurabhrajguru opened this issue Oct 8, 2018 · 5 comments
Milestone

Comments

@saurabhrajguru
Copy link

I am using build from myget "4.0.0-preview-0651" to try OpenAPI 3.0 support.
I have one endpoint which is defined as List<IFormFile> fileList.
I am aware that swagger 2.0 does not support the list of Files.

However It seems that OpenAPI 3.0 has support for Multiple File Upload.
https://swagger.io/docs/specification/describing-request-body/file-upload/

Is there anything I can use to achieve that ?

@a-z-hub
Copy link

a-z-hub commented Oct 11, 2018

@saurabhrajguru in common case required to add support for IFormFileCollection and IEnumerable<IFormFile>.

I need this feature too

@domaindrivendev
Copy link
Owner

Need to get OpenAPi 3.0 support in place first as 2.0 does not support multiple file uploads. The 3.0 support is in work

@a-z-hub
Copy link

a-z-hub commented Oct 15, 2018

@domaindrivendev how to do it? Can you please explain it?

@domaindrivendev domaindrivendev added this to the v5.0.0 milestone Jul 19, 2019
@domaindrivendev
Copy link
Owner

So far as generating the correct Swagger/OA3 JSON, this is already supported in 5.0.0-rc2. You just have to use IFormFileCollection or IEnumerable<IFormFile> in your action signature.

With that said, the swagger-ui library (an independent project) does not fully support this yet, so you won't be able to get the "Try Out" feature working for multiple files until they add this. See swagger-api/swagger-ui#4600 if you want to track their progress.

@dhilgarth
Copy link

Is it supposed to generate the correct swagger.json if there are multiple parameters?
The signature looks like this:

[HttpPost]
public async Task<ActionResult> StartOptimizationRun(
    OptimizationRunParameters parameters, IFormFileCollection modelFiles)

The generated swagger.json looks like this:

"/OptimizationRun": {
      "post": {
        "tags": [
          "OptimizationRun"
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/OptimizationRunParameters"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },

...

    "OptimizationRunParameters": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ModelRunInputData"
          },
          "modelName": {
            "type": "string",
            "nullable": true
          },
          "modelVersion": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },

It's completely missing the modelFiles parameter. Is this a bug or am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants