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.

[BUG] [dart-dio] No builder factory for BuiltMap<String, JsonObject>

See original GitHub issue
Description

When describing an object whose type is a List<Dictionary<string, object>> dart-dio fails to generate a proper serializor prompting an exception

Deserializing '[a.b, 123]' to 'BuiltMap<String, JsonObject>' failed due to: Bad state: No builder factory for BuiltMap<String, JsonObject>. Fix by adding one, see SerializersBuilder.addBuilderFactory.
openapi-generator version

"@openapitools/openapi-generator-cli": "~1.0.13-4.3.1"

OpenAPI declaration file content or url
"ModelThatFails": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": false
              }
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
Command line used for generation

Options besides this only include the swagger file location and package name/version. openapi-generator generate --enable-post-process-file -o headset_mobile_api

Steps to reproduce

Include that model and generate the dart code. Try and deserialize it with this example input '[a.b, 123]'

Related issues/PRs
Suggest a fix

It seems the issue is within the Built_Value serializor or the Model that got generated. Not too knowledgeable in mustache templating

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Tomuchacommented, Jun 30, 2021

OK I have it, in my case I need to add:

  var customSerializers = (standardSerializers.toBuilder()
        ..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(JsonObject)]),
            () => MapBuilder<String, JsonObject>()))
      .build();

   return MyApiClient(dio: ..., serializers: customSerializers);

I guess it should be part of the “default” build.

0reactions
kuhnroyalcommented, Dec 1, 2021

Could you guys try the fix from the PR branch please.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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