Skip to content

Null check operator used on a null value #55

Description

@catalunha

Congratulations on the package. Fantastic.
But I need it to work for an API with 342 endpoints.
The initial project was done in Chopper, but I want to switch to RetroFit and see if I can win the battle with this package of yours.

The OpenAPI file I'm using for testing is the same one used in the Chopper example: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/blob/master/example/input_folder/pet_service_json.json
I converted from Swagger to OpenAPI. The converted file is: swagger/pet_service_json_openapi.json, which is the same as: swagger/schema.json

See my test repo: https://github.com/catalunha/swagger_retrofit_test/tree/petError

I'm trying to convert and encountering the following error:

catalunha@pop-os:~/apps/tests/swagger_retrofit_test$ dart run swagger_to_dart
{
  "input_directory": "swagger/schema.json",
  "output_directory": "lib/data/api",
  "model": {
    "support_generic_arguments": true,
    "union_class_fallback_name": "fallback",
    "enum_fallback_type": "first"
  },
  "api_client": {
    "base_api_client_class_name": "BaseApiClient",
    "use_class_for_query_parameters": true,
    "use_class_for_multipart_form_data": false,
    "skipped_parameters": [
      "Language",
      "X-API-Key"
    ]
  }
}
Output directory: lib/data/api
Unhandled exception:
Null check operator used on a null value
#0      OpenApiSchemaDartTypeConverter.getType (package:swagger_to_dart/src/generator/model/strategy/open_api_schema_dart_type_converter.dart:202:58)
#1      OpenApiSchemaDartTypeConverter.get (package:swagger_to_dart/src/generator/model/strategy/open_api_schema_dart_type_converter.dart:18:35)
#2      PropertyGeneratorStrategy.build (package:swagger_to_dart/src/generator/model/strategy/property_generator_strategy.dart:19:54)
#3      RegularModelGeneratorStrategy.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:swagger_to_dart/src/generator/model/strategy/regular_model_generator_strategy.dart:81:68)
#4      MappedIterator.moveNext (dart:_internal/iterable.dart:420:20)
#5      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:194:27)
#6      new _GrowableList.of (dart:core-patch/growable_array.dart:154:28)
#7      new List.of (dart:core-patch/array_patch.dart:39:18)
#8      RegularModelGeneratorStrategy.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:swagger_to_dart/src/generator/model/strategy/regular_model_generator_strategy.dart:79:49)
#9      _$ConstructorBuilder.update (package:code_builder/src/specs/constructor.g.dart:318:33)
#10     new _$Constructor (package:code_builder/src/specs/constructor.g.dart:36:34)
#11     RegularModelGeneratorStrategy.build.<anonymous closure>.<anonymous closure> (package:swagger_to_dart/src/generator/model/strategy/regular_model_generator_strategy.dart:71:17)
#12     _$ClassBuilder.update (package:code_builder/src/specs/class.g.dart:348:33)
#13     new _$Class (package:code_builder/src/specs/class.g.dart:40:28)
#14     RegularModelGeneratorStrategy.build.<anonymous closure> (package:swagger_to_dart/src/generator/model/strategy/regular_model_generator_strategy.dart:42:11)
#15     _$LibraryBuilder.update (package:code_builder/src/specs/library.g.dart:232:33)
#16     new _$Library (package:code_builder/src/specs/library.g.dart:28:30)
#17     RegularModelGeneratorStrategy.build (package:swagger_to_dart/src/generator/model/strategy/regular_model_generator_strategy.dart:26:12)
#18     ModelGenerator.build (package:swagger_to_dart/src/generator/model/model_generator.dart:26:21)
#19     ModelGenerator.generate (package:swagger_to_dart/src/generator/model/model_generator.dart:33:23)
#20     GenerationContext.generate (package:swagger_to_dart/src/config/generation_context.dart:61:30)
#21     SwaggerToDartCodeGenerator.generate (package:swagger_to_dart/src/generator/swagger_to_dart_code_generator.dart:17:13)
#22     main (file:///home/catalunha/.pub-cache/hosted/pub.dev/swagger_to_dart-3.4.0/bin/swagger_to_dart.dart:16:21)
<asynchronous suspension>

Could you help me?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions