OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.57k stars 6.52k forks source link

[BUG] Multipart/form-data encoding object requires contentType #5902

Open naleczynskia opened 4 years ago

naleczynskia commented 4 years ago
Description

Validation fails when multipart request description contains encoding without contentType.

Using openapi-generator-cli@1.0.12-4.3.0

OpenAPI declaration file content or url
       "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "nullable": true
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          }
        },
Command line used for generation

openapi-generator generate -i swagger.json -g typescript-redux-query -o src/openapi-client

Steps to reproduce

After removing the encoding element entirely, validation passes. It should be possible to specify encoding without content type in this context.

auto-labeler[bot] commented 4 years ago

šŸ‘ Thanks for opening this issue! šŸ· I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

mix4242 commented 4 years ago

Encountering the same bug: ...requestBody.content.encoding.contentType is missing Specifying a content type should not be required if default one is ok. It is a valid spec without it.

The defaults are listed here: https://swagger.io/docs/specification/describing-request-body/multipart-requests/ (nicer formatting)

or first description table cell in official OpenAPI spec.

Predictor commented 3 years ago

This may be related https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1820