normalizePostmanCollection function

Map<String, Object?> normalizePostmanCollection(
  1. Object? json
)

json as a v2.1 collection map (envelope unwrapped, v1/v2.0 upgraded).

Implementation

Map<String, Object?> normalizePostmanCollection(Object? json) {
  final collection = _unwrap(json);
  if (_isV1(collection)) {
    // String keys throughout, as `jsonDecode` gives: the v1 conversion keeps
    // some sub-maps as they came, and the typed models need string keys.
    return _stringKeyed(_fromV1(collection as Map<Object?, Object?>))
        as Map<String, Object?>;
  }
  if (!_isV2(collection)) {
    throw const FormatException('Not a Postman collection');
  }
  final v21 = _copy(collection) as Map<String, Object?>;
  return {
    ...v21,
    'info': {...v21['info'] as Map<String, Object?>, 'schema': v21SchemaUrl},
  };
}