documentRequirementsForAuthorizer method

  1. @override
List<APISecurityRequirement> documentRequirementsForAuthorizer(
  1. APIDocumentContext context,
  2. Authorizer authorizer, {
  3. List<AuthScope>? scopes,
})
override

// //

Implementation

// AuthValidator overrides
/////
@override
List<APISecurityRequirement> documentRequirementsForAuthorizer(
  APIDocumentContext context,
  Authorizer authorizer, {
  List<AuthScope>? scopes,
}) {
  if (authorizer.parser is AuthorizationBasicParser) {
    return [
      APISecurityRequirement({"oauth2-client-authentication": []})
    ];
  } else if (authorizer.parser is AuthorizationBearerParser) {
    return [
      APISecurityRequirement(
        {"oauth2": scopes?.map((s) => s.toString()).toList() ?? []},
      )
    ];
  }

  return [];
}