google / google/googleapis.dart
Generated JsonMap object by discovery_apis_generator does not store the value
- Dominant language
- Dart
- Stars
- 419
- Forks
- 136
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 5
Description
**Reposteps**
1. Have an discovery document with an object that contains JsonMap.
2. Use the discovery_apis generator
3. Notice the JsonMap object is created:
```dart
class Foo{
core.String? bar;
JsonMap? baz;
```
```dart
class JsonMap {
JsonMap();
JsonMap.fromJson(
// ignore: avoid_unused_constructor_parameters
core.Map _json);
core.Map toJson() => {};
}
```
There is no way to retrieve the actual value of the JsonMap and casting throws an cast error.
**Desired solution**
A way to retrieve the values of the JsonMap. For example the object can look like:
```dart
class JsonMap {
JsonMap();
JsonMap.fromJson(
// ignore: avoid_unused_constructor_parameters
core.Map _json) {
_map = _json as core.Map?;
}
core.Map? get raw => _map;
core.Map? _map;
core.Map toJson() => {};
}
```
Btw if you agree with my proposal I can create a pr.
Contributor guide
Assessment
This issue has not been assessed yet.