documentComponents method Null safety

  1. @override
void documentComponents(
  1. APIDocumentContext context
)

/// ///

Implementation

// APIDocumentable overrides
//////
@override
void documentComponents(APIDocumentContext context) {
  final basic = APISecurityScheme.http("basic")
    ..description =
        "This endpoint requires an OAuth2 Client ID and Secret as the Basic Authentication username and password. "
            "If the client ID does not have a secret (public client), the password is the empty string (retain the separating colon, e.g. 'com.conduit.app:').";
  context.securitySchemes.register("oauth2-client-authentication", basic);

  final oauth2 = APISecurityScheme.oauth2({
    "authorizationCode": documentedAuthorizationCodeFlow,
    "password": documentedPasswordFlow
  })
    ..description = "Standard OAuth 2.0";

  context.securitySchemes.register("oauth2", oauth2);

  context.defer(() {
    if (documentedAuthorizationCodeFlow.authorizationURL == null) {
      oauth2.flows!.remove("authorizationCode");
    }

    if (documentedAuthorizationCodeFlow.tokenURL == null) {
      oauth2.flows!.remove("authorizationCode");
    }

    if (documentedPasswordFlow.tokenURL == null) {
      oauth2.flows!.remove("password");
    }
  });
}