Skip to content

[BUG] swagger 2.0 to openapi 3.x conversion for multipart/form-data type: object missing #663

Open
@Agossi

Description

@Agossi

Hi all,
I am currently struggeling with some conversion issue from a swagger 2.0 definition to the openapi 3.0.1
I have a upload route defined with this:

swagger: '2.0'
info:
  version: 1.0.0
  title: REST
  description:  A simple API 
  contact:
    name: Just me
    url: 'https://www..de'
basePath: /
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json

securityDefinitions:
  AdminSecurity:
    type: apiKey
    in: header
    name: Authorization
    description: 'Admin' 

paths:
  /a:
    post:
      summary:  Upload
      description: Upload file
      security:
        - AdminSecurity: []
      consumes:
        - multipart/form-data
      parameters:
        - name: File
          in: formData
          type: file
          description: The  file
          required: true
      responses:
        '200':
          description: OK
        '401':
          description: Access denied 

which gets converted to openapi 3 as:

openapi: 3.0.1
info:
  contact:
    name: Just me
    url: https://www..de
  description: A simple API
  title: REST
  version: 1.0.0
servers:
- url: /
paths:
  /a:
    post:
      description: Upload file
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                File:
                  description: The  file
                  format: binary
                  type: string
              required:
              - File
        required: true
      responses:
        "200":
          content: {}
          description: OK
        "401":
          content: {}
          description: Access denied - not authenticated
      security:
      - AdminSecurity: []
      summary: Upload
components:
  schemas: {}
  securitySchemes:
    AdminSecurity:
      description: Admin
      in: header
      name: Authorization
      type: apiKey

But from what I know there must be the type: object in openapi 3.

openapi: 3.0.1
info:
  contact:
    name: Just me
    url: https://www..de
  description: A simple API
  title: REST
  version: 1.0.0
servers:
- url: /
paths:
  /a:
    post:
      description: Upload file
      requestBody:
        content:
          multipart/form-data:
            schema:

###########
              type: object
###########

              properties:
                File:
                  description: The  file
                  format: binary
                  type: string
              required:
              - File
        required: true
      responses:
        "200":
          content: {}
          description: OK
        "401":
          content: {}
          description: Access denied - not authenticated
      security:
      - AdminSecurity: []
      summary: Upload
components:
  schemas: {}
  securitySchemes:
    AdminSecurity:
      description: Admin
      in: header
      name: Authorization
      type: apiKey


Is this a known issue or is something wrong with my source definition?
I am using CLI version 6.0.1 with the follwing command:

java -jar openapi-generator-cli.jar generate -g openapi-yaml -i api.yaml -o test



Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions