leancodepl / contractsgenerator-dart

Dart contracts client generator for a CQRS API
3 stars 1 forks source link

Uri as a result of query is not properly parsed #75

Closed Xezolpl closed 2 years ago

Xezolpl commented 2 years ago

Generated class:

class AffectedQuery with EquatableMixin implements Query<Uri?> {
  AffectedQuery({
    required this.inputParam,
  });

  factory AffectedQuery.fromJson(Map<String, dynamic> json) =>
      _$AffectedQueryFromJson(json);

  final String inputParam;

  get props => [inputParam];

  Map<String, dynamic> toJson() => _$AffectedQueryToJson(this);
  Uri? resultFactory(dynamic decodedJson) =>
      decodedJson == null ? null : Uri.parse(decodedJson);
  String getFullName() =>
      'AffectedQuery';
}

Throws an error The argument type 'dynamic' can't be assigned to the parameter type 'String'. in line Uri? resultFactory(dynamic decodedJson) => decodedJson == null ? null : Uri.parse(decodedJson);

Expected behavior: resultFactory should use .toString() on decodedJson when parsing

shilangyu commented 2 years ago

Thanks for reporting. Will push a fix tomorrow