diff --git a/modules/openapi-generator/src/main/resources/r/api.mustache b/modules/openapi-generator/src/main/resources/r/api.mustache index 377ffbca446..527b62d4eb2 100644 --- a/modules/openapi-generator/src/main/resources/r/api.mustache +++ b/modules/openapi-generator/src/main/resources/r/api.mustache @@ -438,17 +438,6 @@ {{/isApiKey}} {{#isOAuth}} # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - {{#useDefaultExceptionHandling}} - stop("oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.") - {{/useDefaultExceptionHandling}} - {{#useRlangExceptionHandling}} - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `{{{operationId}}}`.")) - {{/useRlangExceptionHandling}} - } is_oauth <- TRUE oauth_scopes <- "{{#scopes}}{{scope}}{{^-last}} {{/-last}}{{/scopes}}" {{/isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index ea138ef2b36..bf4f3580efe 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -276,7 +276,7 @@ ApiClient <- R6::R6Class( {{#hasOAuthMethods}} # use oauth authentication if the endpoint requires it - if (is_oauth) { + if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) { client <- oauth_client( id = self$oauth_client_id, secret = obfuscated(self$oauth_secret), diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index 64fdd510a3e..a368e8a5360 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -267,7 +267,7 @@ ApiClient <- R6::R6Class( req <- req %>% req_method(method) # use oauth authentication if the endpoint requires it - if (is_oauth) { + if (is_oauth && !is.null(self$oauth_client_id) && !is.null(self$oauth_secret)) { client <- oauth_client( id = self$oauth_client_id, secret = obfuscated(self$oauth_secret), diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R index 303fb961653..dee8427bc05 100644 --- a/samples/client/petstore/R-httr2/R/pet_api.R +++ b/samples/client/petstore/R-httr2/R/pet_api.R @@ -776,12 +776,6 @@ PetApi <- R6::R6Class( } # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `delete_pet`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `delete_pet`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets" @@ -887,12 +881,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet/findByStatus" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_status`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_status`.")) - } is_oauth <- TRUE oauth_scopes <- "read:pets" @@ -1011,12 +999,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet/findByTags" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_tags`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `find_pets_by_tags`.")) - } is_oauth <- TRUE oauth_scopes <- "read:pets" @@ -1522,12 +1504,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `update_pet`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `update_pet`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets" @@ -1766,12 +1742,6 @@ PetApi <- R6::R6Class( } # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `upload_file`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `upload_file`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets" diff --git a/samples/client/petstore/R/R/pet_api.R b/samples/client/petstore/R/R/pet_api.R index dcc0c09ddd9..59e9af1259b 100644 --- a/samples/client/petstore/R/R/pet_api.R +++ b/samples/client/petstore/R/R/pet_api.R @@ -776,12 +776,6 @@ PetApi <- R6::R6Class( } # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `DeletePet`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `DeletePet`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets" @@ -887,12 +881,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet/findByStatus" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByStatus`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByStatus`.")) - } is_oauth <- TRUE oauth_scopes <- "read:pets" @@ -1011,12 +999,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet/findByTags" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByTags`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `FindPetsByTags`.")) - } is_oauth <- TRUE oauth_scopes <- "read:pets" @@ -1522,12 +1504,6 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet" # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UpdatePet`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UpdatePet`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets" @@ -1766,12 +1742,6 @@ PetApi <- R6::R6Class( } # OAuth-related settings - if (is.null(self$api_client$oauth_client_id) || is.null(self$api_client$oauth_secret)) { - rlang::abort(message = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UploadFile`.", - .subclass = "ApiException", - ApiException = ApiException$new(status = 0, - reason = "oauth_client_id, oauth_secret in `api_client` must be set for authentication in the endpoint `UploadFile`.")) - } is_oauth <- TRUE oauth_scopes <- "write:pets read:pets"