fromJson static method
Returns a new DiscoveryDocument instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DiscoveryDocument? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
assert(json.containsKey(r'issuer'), 'Required key "DiscoveryDocument[issuer]" is missing from JSON.');
assert(json[r'issuer'] != null, 'Required key "DiscoveryDocument[issuer]" has a null value in JSON.');
assert(json.containsKey(r'authorization_endpoint'), 'Required key "DiscoveryDocument[authorization_endpoint]" is missing from JSON.');
assert(json[r'authorization_endpoint'] != null, 'Required key "DiscoveryDocument[authorization_endpoint]" has a null value in JSON.');
assert(json.containsKey(r'token_endpoint'), 'Required key "DiscoveryDocument[token_endpoint]" is missing from JSON.');
assert(json[r'token_endpoint'] != null, 'Required key "DiscoveryDocument[token_endpoint]" has a null value in JSON.');
assert(json.containsKey(r'jwks_uri'), 'Required key "DiscoveryDocument[jwks_uri]" is missing from JSON.');
assert(json[r'jwks_uri'] != null, 'Required key "DiscoveryDocument[jwks_uri]" has a null value in JSON.');
assert(json.containsKey(r'scopes_supported'), 'Required key "DiscoveryDocument[scopes_supported]" is missing from JSON.');
assert(json[r'scopes_supported'] != null, 'Required key "DiscoveryDocument[scopes_supported]" has a null value in JSON.');
return true;
}());
return DiscoveryDocument(
issuer: mapValueOfType<String>(json, r'issuer')!,
authorizationEndpoint: mapValueOfType<String>(json, r'authorization_endpoint')!,
tokenEndpoint: mapValueOfType<String>(json, r'token_endpoint')!,
registrationEndpoint: mapValueOfType<String>(json, r'registration_endpoint'),
introspectionEndpoint: mapValueOfType<String>(json, r'introspection_endpoint'),
revocationEndpoint: mapValueOfType<String>(json, r'revocation_endpoint'),
userinfoEndpoint: mapValueOfType<String>(json, r'userinfo_endpoint'),
jwksUri: mapValueOfType<String>(json, r'jwks_uri')!,
responseTypesSupported: json[r'response_types_supported'] is Iterable
? (json[r'response_types_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
grantTypesSupported: json[r'grant_types_supported'] is Iterable
? (json[r'grant_types_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
tokenEndpointAuthMethodsSupported: json[r'token_endpoint_auth_methods_supported'] is Iterable
? (json[r'token_endpoint_auth_methods_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
codeChallengeMethodsSupported: json[r'code_challenge_methods_supported'] is Iterable
? (json[r'code_challenge_methods_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
scopesSupported: json[r'scopes_supported'] is Iterable
? (json[r'scopes_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
subjectTypesSupported: json[r'subject_types_supported'] is Iterable
? (json[r'subject_types_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
idTokenSigningAlgValuesSupported: json[r'id_token_signing_alg_values_supported'] is Iterable
? (json[r'id_token_signing_alg_values_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
promptValuesSupported: json[r'prompt_values_supported'] is Iterable
? (json[r'prompt_values_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
claimsSupported: json[r'claims_supported'] is Iterable
? (json[r'claims_supported'] as Iterable).cast<String>().toList(growable: false)
: const [],
serviceDocumentation: mapValueOfType<String>(json, r'service_documentation'),
);
}
return null;
}