usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.6k stars 1.27k forks source link

Bruno doesn't import as file binary data from OpenAPI definition #3425

Open stephane-archer opened 2 weeks ago

stephane-archer commented 2 weeks ago

I have checked the following:

Describe the bug

Here is a simple OpenAPI definition:

openapi: 3.0.0
info:
  title: Media Engine Server API
  version: 1.0.1
  description: |
    API for the Media Engine Server, enabling video transcoding into various codecs and profiles.
    This API allows users to submit video files for transcoding into specified formats and resolutions, 
    catering to various media production needs.

paths:
  /transcode-video:
    post:
      summary: Transcode a video file to create a proxy
      description: Accepts a video file along with codec and resolution parameters to return a transcoded video file.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - originalVideoFile
              properties:
                originalVideoFile:
                  type: string
                  format: binary
                  description: |
                    The video file to be transcoded, provided as a binary file in a `multipart/form-data` request.
                videoCodec:
                  type: string
                  enum: [H.264, H.265, Apple ProRes, DNxHR]
                  default: H.264
                  description: |
                    The codec for transcoding. Choices affect file size and playback compatibility:
                      - **H.264** (default): Common codec for general playback.
                      - **H.265**: Higher compression than H.264 with similar quality.
                      - **Apple ProRes**: High-quality for post-production (requires `proresProfile`).
                      - **DNxHR**: High-resolution for editing workflows (requires `dnxhrProfile`).
                proresProfile:
                  type: string
                  enum: [Proxy, LT, Standard, HQ, Unset]
                  default: Standard
                  description: |
                    Profile for Apple ProRes (used only if `videoCodec` is `Apple ProRes`):
                      - **Proxy**: Lower quality, suitable for offline editing.
                      - **LT**: Light quality for smaller file sizes.
                      - **Standard** (default): Standard quality.
                      - **HQ**: High quality for enhanced color fidelity.
                      - **Unset**: Uses default ProRes profile.
                dnxhrProfile:
                  type: string
                  enum: [LB, SQ, HQ, HQX, 444, Unset]
                  default: SQ
                  description: |
                    Profile for DNxHR (used only if `videoCodec` is `DNxHR`):
                      - **LB**: Low bandwidth, ideal for proxies.
                      - **SQ** (default): Standard quality.
                      - **HQ**: High quality.
                      - **HQX**: Higher chroma fidelity.
                      - **444**: Full color resolution.
                      - **Unset**: Uses default DNxHR profile.
                height:
                  type: integer
                  description: |
                    Height of output resolution in pixels. Set to -1 to auto-calculate based on aspect ratio. 
                    If both width and height are -1, retains the original dimensions.
                    A typicall value would be 1920 for example.
                  default: -1
                  example:
                    FullHD:
                      value: 1920
                    HD:
                      value: 1280
                width:
                  type: integer
                  description: |
                    Width of output resolution in pixels. Set to -1 to auto-calculate based on aspect ratio. 
                    If both width and height are -1, retains the original dimensions.
                    A typicall value would be 1080 for example
                  default: -1
                  example:
                    FullHD:
                      value: 1080
                    HD:
                      value: 720
      responses:
        '200':
          description: Successfully returns the transcoded video file.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
              example: "transcoded_video.mp4"
        '400':
          description: Bad Request - Invalid parameters or missing required fields.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "Error: height value is invalid"
        '405':
          description: Method Not Allowed - Only POST is allowed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "Error: Method Not Allowed - Only POST is allowed."
        '500':
          description: Internal Server Error - Error occurred during transcoding.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: "Error: Server disk is full"

servers:
  - url: http://localhost:{port}
    description: Local server for testing and development.
    variables:
      port:
        default: "80"
        description: Port for server access (default is 80).

originalVideoFile is imported as a param in the body, not as a file. but in the definition we can see that originalVideoFile is a binary data:

originalVideoFile:
                  type: string
                  format: binary

Is it my OpenAPI definition that is not correct? or that Bruno should consider binary data as a file here?

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Screenshot 2024-11-05 at 11 40 33 Screenshot 2024-11-05 at 11 40 45
anusreesubash commented 2 weeks ago

Hi @stephane-archer Are you requesting that Bruno handle binary files in the body like this, where the file is treated as a file upload and the "Select Files" button is displayed in the value field, as shown in the screenshot? image

stephane-archer commented 2 weeks ago

Exactly, I don't expect people to copy paste binary data into Bruno, that data is probably already in a file

anusree-bruno commented 2 weeks ago

Thanks for confirming! We will get this fixed. I will update you on the progress.