ComboSecurityScheme.fromJson constructor
ComboSecurityScheme.fromJson()
Creates a ComboSecurityScheme from a json
object.
Implementation
factory ComboSecurityScheme.fromJson(
Map<String, dynamic> json,
PrefixMapping prefixMapping,
Set<String> parsedFields,
) {
final description = json.parseField<String>("description", parsedFields);
final descriptions =
json.parseMapField<String>("descriptions", parsedFields);
final jsonLdType = json.parseArrayField<String>("@type");
final proxy = json.parseUriField("proxy", parsedFields);
final oneOf = json.parseArrayField<String>(
"oneOf",
parsedFields: parsedFields,
minimalSize: 2,
);
final allOf = json.parseArrayField<String>(
"allOf",
parsedFields: parsedFields,
minimalSize: 2,
);
final count =
[oneOf, allOf].nonNulls.fold(0, (previous, _) => previous + 1);
if (count != 1) {
throw FormatException(
"Expected exactly one of allOf or oneOf to be "
"defined, but $count were given.",
);
}
final additionalFields =
json.parseAdditionalFields(prefixMapping, parsedFields);
return ComboSecurityScheme(
description: description,
descriptions: descriptions,
jsonLdType: jsonLdType,
proxy: proxy,
oneOf: oneOf,
allOf: allOf,
additionalFields: additionalFields,
);
}