gibahjoe / openapi-generator-dart

Openapi Generator for Dart/Flutter
BSD 3-Clause "New" or "Revised" License
123 stars 34 forks source link

Error deserializing #85

Open knightsforce opened 1 year ago

knightsforce commented 1 year ago

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<OverviewPlace>' 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<TimeSlot>>' failed due to: Deserializing '[]' to 'BuiltList<TimeSlot>' failed due to: Bad state: No builder factory for BuiltList<TimeSlot>. 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<TimeSlot>(), )