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

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

Open
Agossi opened this issue Sep 7, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Agossi
Copy link

Agossi commented Sep 7, 2022

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



@Agossi Agossi added the bug Something isn't working label Sep 7, 2022
@alimoli
Copy link

alimoli commented Oct 20, 2023

Is multipart/form-data supported for the generation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants