Skip to content

Support multiple contentTypes in encoding multipart/form-data #594

Open
@mbachircherif

Description

@mbachircherif

Question

Hi !

I have tried to upload an image that can be either a png or a jpeg, but It didn't work for me.

Here's a demo of a requestBody that I used to achieve the following according to OpenAPI encoding specification:

requestBody:
description: The avatar file
  required: true
  content:
    multipart/form-data:
      schema:
        type: object
        properties:
          file:
            type: string
      encoding:
        file:
          contentType: image/png, image/jpeg

Unfortunatly, I'm getting this error:

Validation warning: Inconsistency encountered when parsing ``: 'image/png, image/jpeg' could not be parsed as a Content Type. Content Types should have the format '<type>/<subtype>'. [context: codingPath=.paths['/profiles/{id}/avatar'].post.requestBody.content['multipart/form-data'].encoding.file.contentType, contextString=, subjectName=]warning: Validation warning: Inconsistency encountered when parsing ``: 'image/png, image/jpeg' could not be parsed as a Content Type. Content Types should have the format '<type>/<subtype>'. [context: codingPath=.paths['/profiles/{id}/avatar'].post.requestBody.content['multipart/form-data'].encoding.file.contentType, contextString=, subjectName=]Error: Invalid content type string: 'image/png, image/jpeg', must have 2 components separated by a slash.

Can you tell me what I did wrong ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generatorAffects: plugin, CLI, config file.kind/enhancementImprovements to existing feature.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions