OpenAPITools / OpenAPITools/openapi-generator

Error deserializing

Open
#15,177 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

When receiving JSON:
[ { "id": 1, "name": "Test", "schedule": { "slots": [ [], [], [], [], [], [], [ { "time_from": "10:30:00", "time_to": "15:45:00" } ] ] } } ]

I get an error after the response:
DioError [unknown]: null I/flutter (19668): │ Error: Deserializing '[{id: 2, name: Test, email: test@gmail.com...' to 'BuiltList' failed due to: Deserializing '[id, 2, name, Test, email, test@gmail.com...' to 'OverviewPlace' failed due to: Deserializing '[slots, [[], [{time_from: 07:00:00, time_to: 14:00:00}, {time_from: 15:00:00,...' to 'Schedule?' failed due to: Deserializing '[[], [{time_from: 07:00:00, time_to: 14:00:00}, {time_from: 15:00:00, time_to...' to 'BuiltList<BuiltList>' failed due to: Deserializing '[]' to 'BuiltList' failed due to: Bad state: No builder factory for BuiltList. Fix by adding one, see SerializersBuilder.addBuilderFactory.

It was solved by adding the code to the serializers.dart file:
..addBuilderFactory( const FullType(BuiltList, [FullType(TimeSlot)]), () => ListBuilder(), )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the generated serializers.dart file and shows a nested empty-list deserialization failure. Start by reproducing the response with empty schedule slots and inspecting the generated serializer registrations. Done means the generated client deserializes the nested BuiltList without manually editing serializers.dart.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.