question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[DART-DIO] Dart dio generated code can't handle binary upload

See original GitHub issue
Description

The code generated by dart dio generator is wrong for the type string binary (for files).

 "/api/v1/shops/{shop_id}/transactions/{id}/signature":
    patch:
      operationId: patch_shops_transaction_signature_partial
      description: ""
      requestBody:
        content:
          image/png:
            schema:
              type: string
              nullable: true
              format: binary
        description: signature image to upload
        required: true
      responses:
        "201":
          description: All good
      tags:
        - transactions
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
      - name: shop_id
        in: path
        required: true
        schema:
          type: integer
openapi-generator version

I’ve tried with the 5.0.0

Details

The generated code compile with no issues, but once you tried to do the call you get an error saying there is no serializer for Uint8list

Suggest a fix

isPrimitiveType should be true for Uint8list, like this they will be no usage of built_value as it’s not needed for Uint8list

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jaumardcommented, Jan 21, 2021

Look like this one is fixed too on master ^^ Thanks !

1reaction
kuhnroyalcommented, Jan 21, 2021

So json.encode probably has no effect for a Uint8List, well that works. I guess this was fixed with https://github.com/OpenAPITools/openapi-generator/pull/8367

You can try the current master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter DIO: upload image using binary body with Dio package
Couldn't implement using the DIO plugin, I resolved the issue using the DART HTTP package, Below is a sample code.
Read more >
Documentation for the dart-dio Generator
Generates a Dart Dio client library with null-safety. #CONFIG OPTIONS. These options may be applied as additional-properties (cli) or ...
Read more >
10 things that are wrong with Flutter - Vladimir Ivanov Dev Blog
Dart is called a statically typed language. It also has this dynamic keyword which basically mean, not so statically. I know this depends...
Read more >
Flutter Tutorials | Upload Image to Server using Dio | Dart
In this video, I'll show you how we can upload image to a server using API from our Flutter App. You might not...
Read more >
[Solved]-Could not upload image with Dio-Flutter
This was definitely a problem from the backend because they were expecting the key to be file . Changed that and it all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found