SecurityRequirement.fromJson constructor
Parses a SecurityRequirement from JSON (map with one key).
Implementation
factory SecurityRequirement.fromJson(Map<String, dynamic> json) {
if (json.length != 1) {
throw const FormatException(
'SecurityRequirement must have exactly one key.',
);
}
final name = json.keys.first;
final rawScopes = json[name];
if (rawScopes is! List) {
throw const FormatException('Scopes must be a list of strings.');
}
return SecurityRequirement(
name: name,
scopes: List<String>.from(rawScopes),
);
}