Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions modules/openapi-generator/src/main/resources/r/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@
#' @param data_file (optional) name of the data file to save the result
{{/returnType}}
#' @param ... Other optional arguments
{{#returnType}}
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
{{/returnType}}
#'
#' @return {{{returnType}}}{{^returnType}}void{{/returnType}}
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
local_var_response <- self${{{operationId}}}{{WithHttpInfo}}({{#allParams}}{{paramName}}, {{/allParams}}{{#vendorExtensions.x-streaming}}stream_callback = stream_callback, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = data_file, {{/returnType}}...)
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...{{#returnType}}, .parse = TRUE{{/returnType}}) {
local_var_response <- self${{{operationId}}}{{WithHttpInfo}}({{#allParams}}{{paramName}}, {{/allParams}}{{#vendorExtensions.x-streaming}}stream_callback = stream_callback, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = data_file, {{/returnType}}...{{#returnType}}, .parse = .parse{{/returnType}})
{{#vendorExtensions.x-streaming}}
if (typeof(stream_callback) == "closure") { # return void if streaming is enabled
return(invisible(NULL))
Expand Down Expand Up @@ -178,9 +181,12 @@
#' @param data_file (optional) name of the data file to save the result
{{/returnType}}
#' @param ... Other optional arguments
{{#returnType}}
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
{{/returnType}}
#'
#' @return API response ({{{returnType}}}{{^returnType}}void{{/returnType}}) with additional information such as HTTP status code, headers
{{{operationId}}}{{WithHttpInfo}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
{{{operationId}}}{{WithHttpInfo}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...{{#returnType}}, .parse = TRUE{{/returnType}}) {
args <- list(...)
query_params <- list()
header_params <- c()
Expand Down Expand Up @@ -559,6 +565,10 @@
if (!is.null(data_file)) {
self$api_client$WriteFile(local_var_resp, data_file)
}
if (!.parse) {
local_var_resp$content <- local_var_resp$response_as_text()
return(local_var_resp)
}

ApiResponse$new(content = content, response = resp, status_code = local_var_resp$status_code)
{{/isPrimitiveType}}
Expand All @@ -567,6 +577,10 @@
if (!is.null(data_file)) {
self$api_client$WriteFile(local_var_resp, data_file)
}
if (!.parse) {
local_var_resp$content <- local_var_resp$response_as_text()
return(local_var_resp)
}

deserialized_resp_obj <- tryCatch(
self$api_client$DeserializeResponse(local_var_resp, "{{returnType}}"),
Expand Down
24 changes: 18 additions & 6 deletions samples/client/echo_api/r/R/auth_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ AuthApi <- R6::R6Class(
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
#'
#' @return character
TestAuthHttpBasic = function(data_file = NULL, ...) {
local_var_response <- self$TestAuthHttpBasicWithHttpInfo(data_file = data_file, ...)
TestAuthHttpBasic = function(data_file = NULL, ..., .parse = TRUE) {
local_var_response <- self$TestAuthHttpBasicWithHttpInfo(data_file = data_file, ..., .parse = .parse)
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
return(local_var_response$content)
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
Expand All @@ -93,9 +94,10 @@ AuthApi <- R6::R6Class(
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
#'
#' @return API response (character) with additional information such as HTTP status code, headers
TestAuthHttpBasicWithHttpInfo = function(data_file = NULL, ...) {
TestAuthHttpBasicWithHttpInfo = function(data_file = NULL, ..., .parse = TRUE) {
args <- list(...)
query_params <- list()
header_params <- c()
Expand Down Expand Up @@ -135,6 +137,10 @@ AuthApi <- R6::R6Class(
if (!is.null(data_file)) {
self$api_client$WriteFile(local_var_resp, data_file)
}
if (!.parse) {
local_var_resp$content <- local_var_resp$response_as_text()
return(local_var_resp)
}

deserialized_resp_obj <- tryCatch(
self$api_client$DeserializeResponse(local_var_resp, "character"),
Expand Down Expand Up @@ -168,10 +174,11 @@ AuthApi <- R6::R6Class(
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
#'
#' @return character
TestAuthHttpBearer = function(data_file = NULL, ...) {
local_var_response <- self$TestAuthHttpBearerWithHttpInfo(data_file = data_file, ...)
TestAuthHttpBearer = function(data_file = NULL, ..., .parse = TRUE) {
local_var_response <- self$TestAuthHttpBearerWithHttpInfo(data_file = data_file, ..., .parse = .parse)
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
return(local_var_response$content)
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
Expand All @@ -188,9 +195,10 @@ AuthApi <- R6::R6Class(
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#' @param .parse Logical. If \code{TRUE} then the response will be parsed to a generated type. If \code{FALSE} the response will be returned as unparsed text.
#'
#' @return API response (character) with additional information such as HTTP status code, headers
TestAuthHttpBearerWithHttpInfo = function(data_file = NULL, ...) {
TestAuthHttpBearerWithHttpInfo = function(data_file = NULL, ..., .parse = TRUE) {
args <- list(...)
query_params <- list()
header_params <- c()
Expand Down Expand Up @@ -230,6 +238,10 @@ AuthApi <- R6::R6Class(
if (!is.null(data_file)) {
self$api_client$WriteFile(local_var_resp, data_file)
}
if (!.parse) {
local_var_resp$content <- local_var_resp$response_as_text()
return(local_var_resp)
}

deserialized_resp_obj <- tryCatch(
self$api_client$DeserializeResponse(local_var_resp, "character"),
Expand Down
Loading
Loading