diff --git a/.github/workflows/samples-r.yaml b/.github/workflows/samples-r.yaml new file mode 100644 index 00000000000..dc5205fb2d7 --- /dev/null +++ b/.github/workflows/samples-r.yaml @@ -0,0 +1,42 @@ +name: Samples R + +on: + push: + paths: + - 'samples/client/echo_api/r/**' + pull_request: + paths: + - 'samples/client/echo_api/r/**' + +jobs: + build: + name: Build R + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sample: + - 'samples/client/echo_api/r/' + steps: + - uses: actions/checkout@v4 + - name: Setup node.js + uses: actions/setup-node@v4 + - name: Run echo server + run: | + git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server + (cd http-echo-server && npm install && npm start &) + - uses: r-lib/actions/setup-r@v2 + with: + r-version: 3.6.1 + - uses: r-lib/actions/setup-r-dependencies@v2 + working-directory: ${{ matrix.sample }} + with: + cache-version: 2 + - name: Install curl + run: sudo apt-get install -y r-cran-curl + - name: build and test + working-directory: ${{ matrix.sample }} + run: | + # export _R_CHECK_FORCE_SUGGESTS_=false + /bin/bash build_and_test.bash + shell: bash diff --git a/bin/configs/r-echo-api.yaml b/bin/configs/r-echo-api.yaml new file mode 100644 index 00000000000..4e631725783 --- /dev/null +++ b/bin/configs/r-echo-api.yaml @@ -0,0 +1,6 @@ +generatorName: r +outputDir: samples/client/echo_api/r +inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml +templateDir: modules/openapi-generator/src/main/resources/r +additionalProperties: + hideGenerationTimestamp: "true" diff --git a/samples/client/echo_api/r/.Rbuildignore b/samples/client/echo_api/r/.Rbuildignore new file mode 100644 index 00000000000..75126be0d34 --- /dev/null +++ b/samples/client/echo_api/r/.Rbuildignore @@ -0,0 +1,20 @@ +^.*\.Rproj$ # Designates the directory as an RStudio Project +^\.Rproj\.user$ # Used by RStudio for temporary files +^README\.Rmd$ # An Rmd file used to generate README.md +^LICENSE\.md$ # Full text of the license +^cran-comments\.md$ # Comments for CRAN submission +^data-raw$ # Code used to create data included in the package +^pkgdown$ # Resources used for the package website +^_pkgdown\.yml$ # Configuration info for the package website +^\.github$ # Contributing guidelines, CoC, issue templates, etc. +^\.Rhistory$ +^\.gitignore$ +^\.openapi-generator-ignore$ +^\.travis\.yml$ +^\.lintr$ +^\.github$ +^\.openapi-generator$ +^docs$ +^git_push\.sh$ +^openapi\.Rcheck$ +^\.\.Rcheck$ diff --git a/samples/client/echo_api/r/.github/workflows/r-client.yaml b/samples/client/echo_api/r/.github/workflows/r-client.yaml new file mode 100644 index 00000000000..216ebe6c003 --- /dev/null +++ b/samples/client/echo_api/r/.github/workflows/r-client.yaml @@ -0,0 +1,33 @@ +# This file is automatically generated by openapi-generator (https://openapi-generator.tech) +# +# Based on https://github.com/r-lib/actions/tree/v2/examples +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck, any::roxygen2, any::lintr, local::. + needs: check, roxygen2, lint + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} + - name: Roxygenize + run: | + roxygen2::roxygenize('.', roclets = c('rd', 'collate', 'namespace')) + shell: Rscript {0} + - uses: r-lib/actions/check-r-package@v2 diff --git a/samples/client/echo_api/r/.gitignore b/samples/client/echo_api/r/.gitignore new file mode 100644 index 00000000000..5d21150e0ca --- /dev/null +++ b/samples/client/echo_api/r/.gitignore @@ -0,0 +1,35 @@ +# ref: https://github.com/github/gitignore/blob/master/R.gitignore + +# History files +.Rhistory +.Rapp.history + +# Session Data files +.RData + +# Example code in package build process +*-Ex.R + +# Output files from R CMD build +/*.tar.gz + +# Output files from R CMD check +/*.Rcheck/ + +# RStudio files +.Rproj.user/ + +# produced vignettes +vignettes/*.html +vignettes/*.pdf + +# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 +.httr-oauth + +# knitr and R markdown default cache directories +/*_cache/ +/cache/ + +# Temporary files created by R markdown +*.utf8.md +*.knit.md diff --git a/samples/client/echo_api/r/.lintr b/samples/client/echo_api/r/.lintr new file mode 100644 index 00000000000..54ee36a49cd --- /dev/null +++ b/samples/client/echo_api/r/.lintr @@ -0,0 +1,7 @@ +linters: linters_with_defaults( + line_length_linter(160), + object_name_linter = NULL, + cyclocomp_linter = NULL + ) +exclusions: list( + ) diff --git a/samples/client/echo_api/r/.openapi-generator-ignore b/samples/client/echo_api/r/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/echo_api/r/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/echo_api/r/.openapi-generator/FILES b/samples/client/echo_api/r/.openapi-generator/FILES new file mode 100644 index 00000000000..00661ff72f6 --- /dev/null +++ b/samples/client/echo_api/r/.openapi-generator/FILES @@ -0,0 +1,46 @@ +.Rbuildignore +.github/workflows/r-client.yaml +.gitignore +.lintr +.travis.yml +DESCRIPTION +NAMESPACE +R/api_client.R +R/api_response.R +R/auth_api.R +R/bird.R +R/body_api.R +R/category.R +R/data_query.R +R/default_value.R +R/form_api.R +R/header_api.R +R/number_properties_only.R +R/path_api.R +R/pet.R +R/query.R +R/query_api.R +R/string_enum_ref.R +R/tag.R +R/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R +R/test_query_style_form_explode_true_array_string_query_object_parameter.R +README.md +docs/AuthApi.md +docs/Bird.md +docs/BodyApi.md +docs/Category.md +docs/DataQuery.md +docs/DefaultValue.md +docs/FormApi.md +docs/HeaderApi.md +docs/NumberPropertiesOnly.md +docs/PathApi.md +docs/Pet.md +docs/Query.md +docs/QueryApi.md +docs/StringEnumRef.md +docs/Tag.md +docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md +docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md +git_push.sh +tests/testthat.R diff --git a/samples/client/echo_api/r/.openapi-generator/VERSION b/samples/client/echo_api/r/.openapi-generator/VERSION new file mode 100644 index 00000000000..fff4bdd7ab5 --- /dev/null +++ b/samples/client/echo_api/r/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/echo_api/r/.travis.yml b/samples/client/echo_api/r/.travis.yml new file mode 100644 index 00000000000..b96a0ef5a85 --- /dev/null +++ b/samples/client/echo_api/r/.travis.yml @@ -0,0 +1,18 @@ +# ref: https://docs.travis-ci.com/user/languages/r/ +language: r +cache: + directories: + - /home/travis/R/Library +r_packages: +- jsonlite +- httr +- testthat +# uncomment below to install deps with devtools +#install: +#- R -e 'devtools::install_deps(dep = T)' +script: +- R CMD build . +- R CMD check *tar.gz +- R CMD INSTALL *tar.gz +after_failure: +- cat ${TRAVIS_BUILD_DIR}/namsor.Rcheck/tests/testthat.Rout.fail diff --git a/samples/client/echo_api/r/DESCRIPTION b/samples/client/echo_api/r/DESCRIPTION new file mode 100644 index 00000000000..9d255d5abc1 --- /dev/null +++ b/samples/client/echo_api/r/DESCRIPTION @@ -0,0 +1,15 @@ +Package: openapi +Title: R Package Client for Echo Server API +Version: 1.0.0 +Author: person("OpenAPI Generator community", email = "team@openapitools.org", role = c("aut", "cre")) +Maintainer: OpenAPI Generator community +Description: Echo Server API +URL: https://github.com/GIT_USER_ID/GIT_REPO_ID +BugReports: https://github.com/GIT_USER_ID/GIT_REPO_ID/issues +Depends: R (>= 3.3) +Encoding: UTF-8 +License: Apache 2.0 +LazyData: true +Suggests: testthat +Imports: jsonlite, httr, R6, base64enc, stringr +RoxygenNote: 7.2.1 diff --git a/samples/client/echo_api/r/NAMESPACE b/samples/client/echo_api/r/NAMESPACE new file mode 100644 index 00000000000..ba08b5eee57 --- /dev/null +++ b/samples/client/echo_api/r/NAMESPACE @@ -0,0 +1,34 @@ +# Generated by openapi-generator: https://openapi-generator.tech +# Do not edit by hand + +import(R6) +import(jsonlite) +import(httr) +import(base64enc) +import(stringr) + + +# Core +export(ApiClient) +export(ApiResponse) + +# Models +export(Bird) +export(Category) +export(DataQuery) +export(DefaultValue) +export(NumberPropertiesOnly) +export(Pet) +export(Query) +export(StringEnumRef) +export(Tag) +export(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter) +export(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter) + +# APIs +export(AuthApi) +export(BodyApi) +export(FormApi) +export(HeaderApi) +export(PathApi) +export(QueryApi) diff --git a/samples/client/echo_api/r/R/api_client.R b/samples/client/echo_api/r/R/api_client.R new file mode 100644 index 00000000000..dedada13adc --- /dev/null +++ b/samples/client/echo_api/r/R/api_client.R @@ -0,0 +1,391 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' ApiClient Class +#' +#' Generic API client for OpenAPI client library builds. +#' OpenAPI generic API client. This client handles the client- +#' server communication, and is invariant across implementations. Specifics of +#' the methods and models for each application are generated from the OpenAPI Generator +#' templates. +#' +#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +#' Ref: https://openapi-generator.tech +#' Do not edit the class manually. +#' +#' @docType class +#' @title ApiClient +#' @description ApiClient Class +#' @format An \code{R6Class} generator object +#' @field base_path Base url +#' @field user_agent Default user agent +#' @field default_headers Default headers +#' @field username Username for HTTP basic authentication +#' @field password Password for HTTP basic authentication +#' @field api_keys API keys +#' @field bearer_token Bearer token +#' @field timeout Default timeout in seconds +#' @field retry_status_codes vector of status codes to retry +#' @field max_retry_attempts maximum number of retries for the status codes +#' @importFrom httr add_headers accept timeout content +#' @export +ApiClient <- R6::R6Class( + "ApiClient", + public = list( + # base path of all requests + base_path = "http://localhost:3000", + # user agent in the HTTP request + user_agent = "OpenAPI-Generator/1.0.0/r", + # default headers in the HTTP request + default_headers = NULL, + # username (HTTP basic authentication) + username = NULL, + # password (HTTP basic authentication) + password = NULL, + # API keys + api_keys = NULL, + # Bearer token + bearer_token = NULL, + # Time Out (seconds) + timeout = NULL, + # Vector of status codes to retry + retry_status_codes = NULL, + # Maximum number of retry attempts for the retry status codes + max_retry_attempts = NULL, + #' Initialize a new ApiClient. + #' + #' @description + #' Initialize a new ApiClient. + #' + #' @param base_path Base path. + #' @param user_agent User agent. + #' @param default_headers Default headers. + #' @param username User name. + #' @param password Password. + #' @param api_keys API keys. + #' @param access_token Access token. + #' @param bearer_token Bearer token. + #' @param timeout Timeout. + #' @param retry_status_codes Status codes for retry. + #' @param max_retry_attempts Maxmium number of retry. + #' @export + initialize = function(base_path = NULL, user_agent = NULL, + default_headers = NULL, + username = NULL, password = NULL, api_keys = NULL, + access_token = NULL, bearer_token = NULL, timeout = NULL, + retry_status_codes = NULL, max_retry_attempts = NULL) { + if (!is.null(base_path)) { + self$base_path <- base_path + } + + if (!is.null(default_headers)) { + self$default_headers <- default_headers + } + + if (!is.null(username)) { + self$username <- username + } + + if (!is.null(password)) { + self$password <- password + } + + if (!is.null(access_token)) { + self$access_token <- access_token + } + + if (!is.null(bearer_token)) { + self$bearer_token <- bearer_token + } + + if (!is.null(api_keys)) { + self$api_keys <- api_keys + } else { + self$api_keys <- list() + } + + if (!is.null(user_agent)) { + self$`user_agent` <- user_agent + } + + if (!is.null(timeout)) { + self$timeout <- timeout + } + + if (!is.null(retry_status_codes)) { + self$retry_status_codes <- retry_status_codes + } + + if (!is.null(max_retry_attempts)) { + self$max_retry_attempts <- max_retry_attempts + } + }, + #' Prepare to make an API call with the retry logic. + #' + #' @description + #' Prepare to make an API call with the retry logic. + #' + #' @param url URL. + #' @param method HTTP method. + #' @param query_params The query parameters. + #' @param header_params The header parameters. + #' @param form_params The form parameters. + #' @param file_params The form parameters for uploading files. + #' @param accepts The list of Accept headers. + #' @param content_types The list of Content-Type headers. + #' @param body The HTTP request body. + #' @param stream_callback Callback function to process the data stream + #' @param ... Other optional arguments. + #' @return HTTP response + #' @export + CallApi = function(url, method, query_params, header_params, form_params, + file_params, accepts, content_types, + body, stream_callback = NULL, ...) { + + resp <- self$Execute(url, method, query_params, header_params, + form_params, file_params, + accepts, content_types, + body, stream_callback = stream_callback, ...) + + if (is.null(self$max_retry_attempts)) { + self$max_retry_attempts <- 3 + } + + if (!is.null(self$retry_status_codes)) { + + for (i in 1 : self$max_retry_attempts) { + if (resp$status_code %in% self$retry_status_codes) { + Sys.sleep((2 ^ i) + stats::runif(n = 1, min = 0, max = 1)) + resp <- self$Execute(url, method, query_params, header_params, + form_params, file_params, accepts, content_types, + body, stream_callback = stream_callback, ...) + } else { + break + } + } + } + + resp + }, + #' Make an API call + #' + #' @description + #' Make an API call + #' + #' @param url URL. + #' @param method HTTP method. + #' @param query_params The query parameters. + #' @param header_params The header parameters. + #' @param form_params The form parameters. + #' @param file_params The form parameters for uploading files. + #' @param accepts The list of Accept headers + #' @param content_types The list of Content-Type headers + #' @param body The HTTP request body. + #' @param stream_callback Callback function to process data stream + #' @param ... Other optional arguments. + #' @return HTTP response + #' @export + Execute = function(url, method, query_params, header_params, + form_params, file_params, + accepts, content_types, + body, stream_callback = NULL, ...) { + headers <- httr::add_headers(c(header_params, self$default_headers)) + + http_timeout <- NULL + if (!is.null(self$timeout)) { + http_timeout <- httr::timeout(self$timeout) + } + + # set HTTP accept header + accept = self$select_header(accepts) + if (!is.null(accept)) { + headers['Accept'] = accept + } + + # set HTTP content-type header + content_type = self$select_header(content_types) + if (!is.null(content_type)) { + headers['Content-Type'] = content_type + } + + if (typeof(stream_callback) == "closure") { # stream data + if (method == "GET") { + httr::GET(url, query = query_params, headers, http_timeout, + httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else if (method == "POST") { + httr::POST(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else if (method == "PUT") { + httr::PUT(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else if (method == "PATCH") { + httr::PATCH(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else if (method == "HEAD") { + httr::HEAD(url, query = query_params, headers, http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else if (method == "DELETE") { + httr::DELETE(url, query = query_params, headers, http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + } else { + err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`." + stop(err_msg) + } + } else { # no streaming + if (method == "GET") { + httr_response <- httr::GET(url, query = query_params, headers, http_timeout, + httr::user_agent(self$`user_agent`), ...) + } else if (method == "POST") { + httr_response <- httr::POST(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + httr::user_agent(self$`user_agent`), ...) + } else if (method == "PUT") { + httr_response <- httr::PUT(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), ...) + } else if (method == "PATCH") { + httr_response <- httr::PATCH(url, query = query_params, headers, body = body, + httr::content_type("application/json"), http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), ...) + } else if (method == "HEAD") { + httr_response <- httr::HEAD(url, query = query_params, headers, http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), ...) + } else if (method == "DELETE") { + httr_response <- httr::DELETE(url, query = query_params, headers, http_timeout, + http_timeout, httr::user_agent(self$`user_agent`), ...) + } else { + err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`." + stop(err_msg) + } + + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- httr::status_code(httr_response) + api_response$status_code_desc <- httr::http_status(httr_response)$reason + api_response$response <- httr::content(httr_response, "text", encoding = "UTF-8") + api_response$headers <- httr::headers(httr_response) + + api_response + } + }, + #' Deserialize the content of API response to the given type. + #' + #' @description + #' Deserialize the content of API response to the given type. + #' + #' @param raw_response Raw response. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserialize = function(raw_response, return_type, pkg_env) { + resp_obj <- jsonlite::fromJSON(raw_response) + self$deserializeObj(resp_obj, return_type, pkg_env) + }, + #' Deserialize the response from jsonlite object based on the given type + #' + #' @description + #' Deserialize the response from jsonlite object based on the given type + #' by handling complex and nested types by iterating recursively + #' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc., + #' + #' @param obj Response object. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserializeObj = function(obj, return_type, pkg_env) { + return_obj <- NULL + primitive_types <- c("character", "numeric", "integer", "logical", "complex") + + # To handle the "map" type + if (startsWith(return_type, "map(")) { + inner_return_type <- regmatches(return_type, + regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2] + return_obj <- lapply(names(obj), function(name) { + self$deserializeObj(obj[[name]], inner_return_type, pkg_env) + }) + names(return_obj) <- names(obj) + } else if (startsWith(return_type, "array[")) { + # To handle the "array" type + inner_return_type <- regmatches(return_type, + regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2] + if (c(inner_return_type) %in% primitive_types) { + return_obj <- vector("list", length = length(obj)) + if (length(obj) > 0) { + for (row in 1:length(obj)) { + return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env) + } + } + } else { + if (!is.null(nrow(obj))) { + return_obj <- vector("list", length = nrow(obj)) + if (nrow(obj) > 0) { + for (row in 1:nrow(obj)) { + return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], + inner_return_type, pkg_env) + } + } + } + } + } else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) { + # To handle model objects which are not array or map containers. Ex:"Pet" + return_type <- get(return_type, envir = as.environment(pkg_env)) + return_obj <- return_type$new() + # check if discriminator is defined + if (!is.null(return_obj$`_discriminator_property_name`)) { + data_type <- return_obj$`_discriminator_property_name` + # use discriminator mapping if provided + if (!is.null(return_obj$`_discriminator_mapping_name`)) { + data_type <- (return_obj$`_discriminator_mapping_name`)[[obj[[data_type]]]] + } else { + # no mapping provided, use the value directly + data_type <- obj[[data_type]] + } + # create an object of the mapped type (e.g. Cat) + return_type <- get(data_type, envir = as.environment(pkg_env)) + return_obj <- return_type$new() + } + return_obj$fromJSON( + jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE) + ) + } else { + # To handle primitive type + return_obj <- obj + } + return_obj + }, + #' Return a property header (for accept or content-type). + #' + #' @description + #' Return a property header (for accept or content-type). If JSON-related MIME is found, + #' return it. Otherwise, return the first one, if any. + #' + #' @param headers A list of headers + #' @return A header (e.g. 'application/json') + #' @export + select_header = function(headers) { + if (length(headers) == 0) { + return(invisible(NULL)) + } else { + for (header in headers) { + if (str_detect(header, "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$")) { + # return JSON-related MIME + return(header) + } + } + + # not json mime type, simply return the first one + return(headers[1]) + } + } + ) +) diff --git a/samples/client/echo_api/r/R/api_response.R b/samples/client/echo_api/r/R/api_response.R new file mode 100644 index 00000000000..c6d45622464 --- /dev/null +++ b/samples/client/echo_api/r/R/api_response.R @@ -0,0 +1,50 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title ApiResponse +#' @description ApiResponse Class +#' @format An \code{R6Class} generator object +#' @field content The deserialized response body. +#' @field response The raw response from the endpoint. +#' @field status_code The HTTP response status code. +#' @field status_code_desc The brief description of the HTTP response status code. +#' @field headers The HTTP response headers. +#' @export +ApiResponse <- R6::R6Class( + "ApiResponse", + public = list( + content = NULL, + response = NULL, + status_code = NULL, + status_code_desc = NULL, + headers = NULL, + #' Initialize a new ApiResponse class. + #' + #' @description + #' Initialize a new ApiResponse class. + #' + #' @param content The deserialized response body. + #' @param response The raw response from the endpoint. + #' @param status_code The HTTP response status code. + #' @param status_code_desc The brief description of the HTTP response status code. + #' @param headers The HTTP response headers. + #' @export + initialize = function(content = NULL, + response = NULL, + status_code = NULL, + status_code_desc = NULL, + headers = NULL) { + self$content <- content + self$response <- response + self$status_code <- status_code + self$status_code_desc <- status_code_desc + self$headers <- headers + } + ) +) diff --git a/samples/client/echo_api/r/R/auth_api.R b/samples/client/echo_api/r/R/auth_api.R new file mode 100644 index 00000000000..b78961ddbbf --- /dev/null +++ b/samples/client/echo_api/r/R/auth_api.R @@ -0,0 +1,288 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Auth operations +#' @description AuthApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestAuthHttpBasic } \emph{ To test HTTP basic authentication } +#' To test HTTP basic authentication +#' +#' \itemize{ +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestAuthHttpBearer } \emph{ To test HTTP bearer authentication } +#' To test HTTP bearer authentication +#' +#' \itemize{ +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestAuthHttpBasic #################### +#' +#' library(openapi) +#' +#' #To test HTTP basic authentication +#' api_instance <- AuthApi$new() +#' +#' # Configure HTTP basic authorization: http_auth +#' api_instance$api_client$username <- Sys.getenv("USERNAME") +#' api_instance$api_client$password <- Sys.getenv("PASSWORD") +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestAuthHttpBasic(data_file = "result.txt") +#' result <- api_instance$TestAuthHttpBasic() +#' dput(result) +#' +#' +#' #################### TestAuthHttpBearer #################### +#' +#' library(openapi) +#' +#' #To test HTTP bearer authentication +#' api_instance <- AuthApi$new() +#' +#' # Configure HTTP bearer authorization: http_bearer_auth +#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN") +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestAuthHttpBearer(data_file = "result.txt") +#' result <- api_instance$TestAuthHttpBearer() +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +AuthApi <- R6::R6Class( + "AuthApi", + public = list( + api_client = NULL, + #' Initialize a new AuthApi. + #' + #' @description + #' Initialize a new AuthApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' To test HTTP basic authentication + #' + #' @description + #' To test HTTP basic authentication + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestAuthHttpBasic = function(data_file = NULL, ...) { + local_var_response <- self$TestAuthHttpBasicWithHttpInfo(data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' To test HTTP basic authentication + #' + #' @description + #' To test HTTP basic authentication + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestAuthHttpBasicWithHttpInfo = function(data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + local_var_url_path <- "/auth/http/basic" + # HTTP basic auth + if (!is.null(self$api_client$username) || !is.null(self$api_client$password)) { + header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":")))) + } + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' To test HTTP bearer authentication + #' + #' @description + #' To test HTTP bearer authentication + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestAuthHttpBearer = function(data_file = NULL, ...) { + local_var_response <- self$TestAuthHttpBearerWithHttpInfo(data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' To test HTTP bearer authentication + #' + #' @description + #' To test HTTP bearer authentication + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestAuthHttpBearerWithHttpInfo = function(data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + local_var_url_path <- "/auth/http/bearer" + # Bearer token + if (!is.null(self$api_client$bearer_token)) { + header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ") + } + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/bird.R b/samples/client/echo_api/r/R/bird.R new file mode 100644 index 00000000000..57616beecb7 --- /dev/null +++ b/samples/client/echo_api/r/R/bird.R @@ -0,0 +1,188 @@ +#' Create a new Bird +#' +#' @description +#' Bird Class +#' +#' @docType class +#' @title Bird +#' @description Bird Class +#' @format An \code{R6Class} generator object +#' @field size character [optional] +#' @field color character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Bird <- R6::R6Class( + "Bird", + public = list( + `size` = NULL, + `color` = NULL, + #' Initialize a new Bird class. + #' + #' @description + #' Initialize a new Bird class. + #' + #' @param size size + #' @param color color + #' @param ... Other optional arguments. + #' @export + initialize = function(`size` = NULL, `color` = NULL, ...) { + if (!is.null(`size`)) { + if (!(is.character(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be a string:", `size`)) + } + self$`size` <- `size` + } + if (!is.null(`color`)) { + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } + self$`color` <- `color` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Bird in JSON format + #' @export + toJSON = function() { + BirdObject <- list() + if (!is.null(self$`size`)) { + BirdObject[["size"]] <- + self$`size` + } + if (!is.null(self$`color`)) { + BirdObject[["color"]] <- + self$`color` + } + BirdObject + }, + #' Deserialize JSON string into an instance of Bird + #' + #' @description + #' Deserialize JSON string into an instance of Bird + #' + #' @param input_json the JSON input + #' @return the instance of Bird + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`size`)) { + self$`size` <- this_object$`size` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Bird in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`size`)) { + sprintf( + '"size": + "%s" + ', + self$`size` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Bird + #' + #' @description + #' Deserialize JSON string into an instance of Bird + #' + #' @param input_json the JSON input + #' @return the instance of Bird + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`size` <- this_object$`size` + self$`color` <- this_object$`color` + self + }, + #' Validate JSON input with respect to Bird + #' + #' @description + #' Validate JSON input with respect to Bird and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Bird + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# Bird$unlock() +# +## Below is an example to define the print function +# Bird$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# Bird$lock() + diff --git a/samples/client/echo_api/r/R/body_api.R b/samples/client/echo_api/r/R/body_api.R new file mode 100644 index 00000000000..7a22b2939cb --- /dev/null +++ b/samples/client/echo_api/r/R/body_api.R @@ -0,0 +1,1155 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Body operations +#' @description BodyApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestBinaryGif } \emph{ Test binary (gif) response body } +#' Test binary (gif) response body +#' +#' \itemize{ +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : data.frame +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestBodyApplicationOctetstreamBinary } \emph{ Test body parameter(s) } +#' Test body parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } body data.frame +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestBodyMultipartFormdataArrayOfBinary } \emph{ Test array of binary in multipart mime } +#' Test array of binary in multipart mime +#' +#' \itemize{ +#' \item \emph{ @param } files list( data.frame ) +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestBodyMultipartFormdataSingleBinary } \emph{ Test single binary in multipart mime } +#' Test single binary in multipart mime +#' +#' \itemize{ +#' \item \emph{ @param } my_file data.frame +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestEchoBodyAllOfPet } \emph{ Test body parameter(s) } +#' Test body parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } pet \link{Pet} +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestEchoBodyFreeFormObjectResponseString } \emph{ Test free form object } +#' Test free form object +#' +#' \itemize{ +#' \item \emph{ @param } body object +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestEchoBodyPet } \emph{ Test body parameter(s) } +#' Test body parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } pet \link{Pet} +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestEchoBodyPetResponseString } \emph{ Test empty response body } +#' Test empty response body +#' +#' \itemize{ +#' \item \emph{ @param } pet \link{Pet} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestEchoBodyTagResponseString } \emph{ Test empty json (request body) } +#' Test empty json (request body) +#' +#' \itemize{ +#' \item \emph{ @param } tag \link{Tag} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestBinaryGif #################### +#' +#' library(openapi) +#' +#' #Test binary (gif) response body +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestBinaryGif(data_file = "result.txt") +#' result <- api_instance$TestBinaryGif() +#' dput(result) +#' +#' +#' #################### TestBodyApplicationOctetstreamBinary #################### +#' +#' library(openapi) +#' var_body <- File.new('/path/to/file') # data.frame | (Optional) +#' +#' #Test body parameter(s) +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestBodyApplicationOctetstreamBinary(body = var_bodydata_file = "result.txt") +#' result <- api_instance$TestBodyApplicationOctetstreamBinary(body = var_body) +#' dput(result) +#' +#' +#' #################### TestBodyMultipartFormdataArrayOfBinary #################### +#' +#' library(openapi) +#' var_files <- c(123) # array[data.frame] | +#' +#' #Test array of binary in multipart mime +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestBodyMultipartFormdataArrayOfBinary(var_filesdata_file = "result.txt") +#' result <- api_instance$TestBodyMultipartFormdataArrayOfBinary(var_files) +#' dput(result) +#' +#' +#' #################### TestBodyMultipartFormdataSingleBinary #################### +#' +#' library(openapi) +#' var_my_file <- File.new('/path/to/file') # data.frame | (Optional) +#' +#' #Test single binary in multipart mime +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestBodyMultipartFormdataSingleBinary(my_file = var_my_filedata_file = "result.txt") +#' result <- api_instance$TestBodyMultipartFormdataSingleBinary(my_file = var_my_file) +#' dput(result) +#' +#' +#' #################### TestEchoBodyAllOfPet #################### +#' +#' library(openapi) +#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) +#' +#' #Test body parameter(s) +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEchoBodyAllOfPet(pet = var_petdata_file = "result.txt") +#' result <- api_instance$TestEchoBodyAllOfPet(pet = var_pet) +#' dput(result) +#' +#' +#' #################### TestEchoBodyFreeFormObjectResponseString #################### +#' +#' library(openapi) +#' var_body <- c(key = TODO) # object | Free form object (Optional) +#' +#' #Test free form object +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEchoBodyFreeFormObjectResponseString(body = var_bodydata_file = "result.txt") +#' result <- api_instance$TestEchoBodyFreeFormObjectResponseString(body = var_body) +#' dput(result) +#' +#' +#' #################### TestEchoBodyPet #################### +#' +#' library(openapi) +#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) +#' +#' #Test body parameter(s) +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEchoBodyPet(pet = var_petdata_file = "result.txt") +#' result <- api_instance$TestEchoBodyPet(pet = var_pet) +#' dput(result) +#' +#' +#' #################### TestEchoBodyPetResponseString #################### +#' +#' library(openapi) +#' var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) +#' +#' #Test empty response body +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEchoBodyPetResponseString(pet = var_petdata_file = "result.txt") +#' result <- api_instance$TestEchoBodyPetResponseString(pet = var_pet) +#' dput(result) +#' +#' +#' #################### TestEchoBodyTagResponseString #################### +#' +#' library(openapi) +#' var_tag <- Tag$new(123, "name_example") # Tag | Tag object (Optional) +#' +#' #Test empty json (request body) +#' api_instance <- BodyApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEchoBodyTagResponseString(tag = var_tagdata_file = "result.txt") +#' result <- api_instance$TestEchoBodyTagResponseString(tag = var_tag) +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +BodyApi <- R6::R6Class( + "BodyApi", + public = list( + api_client = NULL, + #' Initialize a new BodyApi. + #' + #' @description + #' Initialize a new BodyApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' Test binary (gif) response body + #' + #' @description + #' Test binary (gif) response body + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return data.frame + #' @export + TestBinaryGif = function(data_file = NULL, ...) { + local_var_response <- self$TestBinaryGifWithHttpInfo(data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test binary (gif) response body + #' + #' @description + #' Test binary (gif) response body + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (data.frame) with additional information such as HTTP status code, headers + #' @export + TestBinaryGifWithHttpInfo = function(data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + local_var_url_path <- "/binary/gif" + + # The Accept request HTTP header + local_var_accepts <- list("image/gif") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "data.frame", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param body (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestBodyApplicationOctetstreamBinary = function(body = NULL, data_file = NULL, ...) { + local_var_response <- self$TestBodyApplicationOctetstreamBinaryWithHttpInfo(body, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param body (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestBodyApplicationOctetstreamBinaryWithHttpInfo = function(body = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`body`)) { + local_var_body <- `body`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/body/application/octetstream/binary" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/octet-stream") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test array of binary in multipart mime + #' + #' @description + #' Test array of binary in multipart mime + #' + #' @param files + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestBodyMultipartFormdataArrayOfBinary = function(files, data_file = NULL, ...) { + local_var_response <- self$TestBodyMultipartFormdataArrayOfBinaryWithHttpInfo(files, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test array of binary in multipart mime + #' + #' @description + #' Test array of binary in multipart mime + #' + #' @param files + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestBodyMultipartFormdataArrayOfBinaryWithHttpInfo = function(files, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + if (missing(`files`)) { + stop("Missing required parameter `files`.") + } + + + file_params["files"] <- httr::upload_file(`files`) + local_var_url_path <- "/body/application/octetstream/array_of_binary" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("multipart/form-data") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test single binary in multipart mime + #' + #' @description + #' Test single binary in multipart mime + #' + #' @param my_file (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestBodyMultipartFormdataSingleBinary = function(my_file = NULL, data_file = NULL, ...) { + local_var_response <- self$TestBodyMultipartFormdataSingleBinaryWithHttpInfo(my_file, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test single binary in multipart mime + #' + #' @description + #' Test single binary in multipart mime + #' + #' @param my_file (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestBodyMultipartFormdataSingleBinaryWithHttpInfo = function(my_file = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + file_params["my-file"] <- httr::upload_file(`my_file`) + local_var_url_path <- "/body/application/octetstream/single_binary" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("multipart/form-data") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Pet + #' @export + TestEchoBodyAllOfPet = function(pet = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEchoBodyAllOfPetWithHttpInfo(pet, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (Pet) with additional information such as HTTP status code, headers + #' @export + TestEchoBodyAllOfPetWithHttpInfo = function(pet = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`pet`)) { + local_var_body <- `pet`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/echo/body/allOf/Pet" + + # The Accept request HTTP header + local_var_accepts <- list("application/json") + + # The Content-Type representation header + local_var_content_types <- list("application/json") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test free form object + #' + #' @description + #' Test free form object + #' + #' @param body (optional) Free form object + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestEchoBodyFreeFormObjectResponseString = function(body = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEchoBodyFreeFormObjectResponseStringWithHttpInfo(body, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test free form object + #' + #' @description + #' Test free form object + #' + #' @param body (optional) Free form object + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestEchoBodyFreeFormObjectResponseStringWithHttpInfo = function(body = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`body`)) { + local_var_body <- `body`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/echo/body/FreeFormObject/response_string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/json") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Pet + #' @export + TestEchoBodyPet = function(pet = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEchoBodyPetWithHttpInfo(pet, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test body parameter(s) + #' + #' @description + #' Test body parameter(s) + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (Pet) with additional information such as HTTP status code, headers + #' @export + TestEchoBodyPetWithHttpInfo = function(pet = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`pet`)) { + local_var_body <- `pet`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/echo/body/Pet" + + # The Accept request HTTP header + local_var_accepts <- list("application/json") + + # The Content-Type representation header + local_var_content_types <- list("application/json") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test empty response body + #' + #' @description + #' Test empty response body + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestEchoBodyPetResponseString = function(pet = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEchoBodyPetResponseStringWithHttpInfo(pet, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test empty response body + #' + #' @description + #' Test empty response body + #' + #' @param pet (optional) Pet object that needs to be added to the store + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestEchoBodyPetResponseStringWithHttpInfo = function(pet = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`pet`)) { + local_var_body <- `pet`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/echo/body/Pet/response_string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/json") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test empty json (request body) + #' + #' @description + #' Test empty json (request body) + #' + #' @param tag (optional) Tag object + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestEchoBodyTagResponseString = function(tag = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEchoBodyTagResponseStringWithHttpInfo(tag, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test empty json (request body) + #' + #' @description + #' Test empty json (request body) + #' + #' @param tag (optional) Tag object + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestEchoBodyTagResponseStringWithHttpInfo = function(tag = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + if (!is.null(`tag`)) { + local_var_body <- `tag`$toJSONString() + } else { + body <- NULL + } + + local_var_url_path <- "/echo/body/Tag/response_string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/json") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/category.R b/samples/client/echo_api/r/R/category.R new file mode 100644 index 00000000000..3213851b9e9 --- /dev/null +++ b/samples/client/echo_api/r/R/category.R @@ -0,0 +1,188 @@ +#' Create a new Category +#' +#' @description +#' Category Class +#' +#' @docType class +#' @title Category +#' @description Category Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field name character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Category <- R6::R6Class( + "Category", + public = list( + `id` = NULL, + `name` = NULL, + #' Initialize a new Category class. + #' + #' @description + #' Initialize a new Category class. + #' + #' @param id id + #' @param name name + #' @param ... Other optional arguments. + #' @export + initialize = function(`id` = NULL, `name` = NULL, ...) { + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`name`)) { + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } + self$`name` <- `name` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Category in JSON format + #' @export + toJSON = function() { + CategoryObject <- list() + if (!is.null(self$`id`)) { + CategoryObject[["id"]] <- + self$`id` + } + if (!is.null(self$`name`)) { + CategoryObject[["name"]] <- + self$`name` + } + CategoryObject + }, + #' Deserialize JSON string into an instance of Category + #' + #' @description + #' Deserialize JSON string into an instance of Category + #' + #' @param input_json the JSON input + #' @return the instance of Category + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`name`)) { + self$`name` <- this_object$`name` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Category in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`name`)) { + sprintf( + '"name": + "%s" + ', + self$`name` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Category + #' + #' @description + #' Deserialize JSON string into an instance of Category + #' + #' @param input_json the JSON input + #' @return the instance of Category + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`name` <- this_object$`name` + self + }, + #' Validate JSON input with respect to Category + #' + #' @description + #' Validate JSON input with respect to Category and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Category + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# Category$unlock() +# +## Below is an example to define the print function +# Category$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# Category$lock() + diff --git a/samples/client/echo_api/r/R/data_query.R b/samples/client/echo_api/r/R/data_query.R new file mode 100644 index 00000000000..0a749f98d6e --- /dev/null +++ b/samples/client/echo_api/r/R/data_query.R @@ -0,0 +1,263 @@ +#' Create a new DataQuery +#' +#' @description +#' DataQuery Class +#' +#' @docType class +#' @title DataQuery +#' @description DataQuery Class +#' @format An \code{R6Class} generator object +#' @field id Query integer [optional] +#' @field outcomes list(character) [optional] +#' @field suffix test suffix character [optional] +#' @field text Some text containing white spaces character [optional] +#' @field date A date character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +DataQuery <- R6::R6Class( + "DataQuery", + inherit = Query, + public = list( + `id` = NULL, + `outcomes` = NULL, + `suffix` = NULL, + `text` = NULL, + `date` = NULL, + #' Initialize a new DataQuery class. + #' + #' @description + #' Initialize a new DataQuery class. + #' + #' @param id Query + #' @param outcomes outcomes. Default to [SUCCESS, FAILURE]. + #' @param suffix test suffix + #' @param text Some text containing white spaces + #' @param date A date + #' @param ... Other optional arguments. + #' @export + initialize = function(`id` = NULL, `outcomes` = [SUCCESS, FAILURE], `suffix` = NULL, `text` = NULL, `date` = NULL, ...) { + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`outcomes`)) { + stopifnot(is.vector(`outcomes`), length(`outcomes`) != 0) + sapply(`outcomes`, function(x) stopifnot(is.character(x))) + self$`outcomes` <- `outcomes` + } + if (!is.null(`suffix`)) { + if (!(is.character(`suffix`) && length(`suffix`) == 1)) { + stop(paste("Error! Invalid data for `suffix`. Must be a string:", `suffix`)) + } + self$`suffix` <- `suffix` + } + if (!is.null(`text`)) { + if (!(is.character(`text`) && length(`text`) == 1)) { + stop(paste("Error! Invalid data for `text`. Must be a string:", `text`)) + } + self$`text` <- `text` + } + if (!is.null(`date`)) { + if (!is.character(`date`)) { + stop(paste("Error! Invalid data for `date`. Must be a string:", `date`)) + } + self$`date` <- `date` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DataQuery in JSON format + #' @export + toJSON = function() { + DataQueryObject <- list() + if (!is.null(self$`id`)) { + DataQueryObject[["id"]] <- + self$`id` + } + if (!is.null(self$`outcomes`)) { + DataQueryObject[["outcomes"]] <- + self$`outcomes` + } + if (!is.null(self$`suffix`)) { + DataQueryObject[["suffix"]] <- + self$`suffix` + } + if (!is.null(self$`text`)) { + DataQueryObject[["text"]] <- + self$`text` + } + if (!is.null(self$`date`)) { + DataQueryObject[["date"]] <- + self$`date` + } + DataQueryObject + }, + #' Deserialize JSON string into an instance of DataQuery + #' + #' @description + #' Deserialize JSON string into an instance of DataQuery + #' + #' @param input_json the JSON input + #' @return the instance of DataQuery + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`outcomes`)) { + self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`suffix`)) { + self$`suffix` <- this_object$`suffix` + } + if (!is.null(this_object$`text`)) { + self$`text` <- this_object$`text` + } + if (!is.null(this_object$`date`)) { + self$`date` <- this_object$`date` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DataQuery in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`outcomes`)) { + sprintf( + '"outcomes": + [%s] + ', + paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`suffix`)) { + sprintf( + '"suffix": + "%s" + ', + self$`suffix` + ) + }, + if (!is.null(self$`text`)) { + sprintf( + '"text": + "%s" + ', + self$`text` + ) + }, + if (!is.null(self$`date`)) { + sprintf( + '"date": + "%s" + ', + self$`date` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of DataQuery + #' + #' @description + #' Deserialize JSON string into an instance of DataQuery + #' + #' @param input_json the JSON input + #' @return the instance of DataQuery + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi")) + self$`suffix` <- this_object$`suffix` + self$`text` <- this_object$`text` + self$`date` <- this_object$`date` + self + }, + #' Validate JSON input with respect to DataQuery + #' + #' @description + #' Validate JSON input with respect to DataQuery and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of DataQuery + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# DataQuery$unlock() +# +## Below is an example to define the print function +# DataQuery$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# DataQuery$lock() + diff --git a/samples/client/echo_api/r/R/default_value.R b/samples/client/echo_api/r/R/default_value.R new file mode 100644 index 00000000000..6f051e08903 --- /dev/null +++ b/samples/client/echo_api/r/R/default_value.R @@ -0,0 +1,331 @@ +#' Create a new DefaultValue +#' +#' @description +#' to test the default value of properties +#' +#' @docType class +#' @title DefaultValue +#' @description DefaultValue Class +#' @format An \code{R6Class} generator object +#' @field array_string_enum_ref_default list(\link{StringEnumRef}) [optional] +#' @field array_string_enum_default list(character) [optional] +#' @field array_string_default list(character) [optional] +#' @field array_integer_default list(integer) [optional] +#' @field array_string list(character) [optional] +#' @field array_string_nullable list(character) [optional] +#' @field array_string_extension_nullable list(character) [optional] +#' @field string_nullable character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +DefaultValue <- R6::R6Class( + "DefaultValue", + public = list( + `array_string_enum_ref_default` = NULL, + `array_string_enum_default` = NULL, + `array_string_default` = NULL, + `array_integer_default` = NULL, + `array_string` = NULL, + `array_string_nullable` = NULL, + `array_string_extension_nullable` = NULL, + `string_nullable` = NULL, + #' Initialize a new DefaultValue class. + #' + #' @description + #' Initialize a new DefaultValue class. + #' + #' @param array_string_enum_ref_default array_string_enum_ref_default. Default to ["success","failure"]. + #' @param array_string_enum_default array_string_enum_default. Default to ["success","failure"]. + #' @param array_string_default array_string_default. Default to ["failure","skipped"]. + #' @param array_integer_default array_integer_default. Default to [1,3]. + #' @param array_string array_string + #' @param array_string_nullable array_string_nullable + #' @param array_string_extension_nullable array_string_extension_nullable + #' @param string_nullable string_nullable + #' @param ... Other optional arguments. + #' @export + initialize = function(`array_string_enum_ref_default` = ["success","failure"], `array_string_enum_default` = ["success","failure"], `array_string_default` = ["failure","skipped"], `array_integer_default` = [1,3], `array_string` = NULL, `array_string_nullable` = NULL, `array_string_extension_nullable` = NULL, `string_nullable` = NULL, ...) { + if (!is.null(`array_string_enum_ref_default`)) { + stopifnot(is.vector(`array_string_enum_ref_default`), length(`array_string_enum_ref_default`) != 0) + sapply(`array_string_enum_ref_default`, function(x) stopifnot(R6::is.R6(x))) + self$`array_string_enum_ref_default` <- `array_string_enum_ref_default` + } + if (!is.null(`array_string_enum_default`)) { + stopifnot(is.vector(`array_string_enum_default`), length(`array_string_enum_default`) != 0) + sapply(`array_string_enum_default`, function(x) stopifnot(is.character(x))) + self$`array_string_enum_default` <- `array_string_enum_default` + } + if (!is.null(`array_string_default`)) { + stopifnot(is.vector(`array_string_default`), length(`array_string_default`) != 0) + sapply(`array_string_default`, function(x) stopifnot(is.character(x))) + self$`array_string_default` <- `array_string_default` + } + if (!is.null(`array_integer_default`)) { + stopifnot(is.vector(`array_integer_default`), length(`array_integer_default`) != 0) + sapply(`array_integer_default`, function(x) stopifnot(is.character(x))) + self$`array_integer_default` <- `array_integer_default` + } + if (!is.null(`array_string`)) { + stopifnot(is.vector(`array_string`), length(`array_string`) != 0) + sapply(`array_string`, function(x) stopifnot(is.character(x))) + self$`array_string` <- `array_string` + } + if (!is.null(`array_string_nullable`)) { + stopifnot(is.vector(`array_string_nullable`), length(`array_string_nullable`) != 0) + sapply(`array_string_nullable`, function(x) stopifnot(is.character(x))) + self$`array_string_nullable` <- `array_string_nullable` + } + if (!is.null(`array_string_extension_nullable`)) { + stopifnot(is.vector(`array_string_extension_nullable`), length(`array_string_extension_nullable`) != 0) + sapply(`array_string_extension_nullable`, function(x) stopifnot(is.character(x))) + self$`array_string_extension_nullable` <- `array_string_extension_nullable` + } + if (!is.null(`string_nullable`)) { + if (!(is.character(`string_nullable`) && length(`string_nullable`) == 1)) { + stop(paste("Error! Invalid data for `string_nullable`. Must be a string:", `string_nullable`)) + } + self$`string_nullable` <- `string_nullable` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DefaultValue in JSON format + #' @export + toJSON = function() { + DefaultValueObject <- list() + if (!is.null(self$`array_string_enum_ref_default`)) { + DefaultValueObject[["array_string_enum_ref_default"]] <- + lapply(self$`array_string_enum_ref_default`, function(x) x$toJSON()) + } + if (!is.null(self$`array_string_enum_default`)) { + DefaultValueObject[["array_string_enum_default"]] <- + self$`array_string_enum_default` + } + if (!is.null(self$`array_string_default`)) { + DefaultValueObject[["array_string_default"]] <- + self$`array_string_default` + } + if (!is.null(self$`array_integer_default`)) { + DefaultValueObject[["array_integer_default"]] <- + self$`array_integer_default` + } + if (!is.null(self$`array_string`)) { + DefaultValueObject[["array_string"]] <- + self$`array_string` + } + if (!is.null(self$`array_string_nullable`)) { + DefaultValueObject[["array_string_nullable"]] <- + self$`array_string_nullable` + } + if (!is.null(self$`array_string_extension_nullable`)) { + DefaultValueObject[["array_string_extension_nullable"]] <- + self$`array_string_extension_nullable` + } + if (!is.null(self$`string_nullable`)) { + DefaultValueObject[["string_nullable"]] <- + self$`string_nullable` + } + DefaultValueObject + }, + #' Deserialize JSON string into an instance of DefaultValue + #' + #' @description + #' Deserialize JSON string into an instance of DefaultValue + #' + #' @param input_json the JSON input + #' @return the instance of DefaultValue + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`array_string_enum_ref_default`)) { + self$`array_string_enum_ref_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_ref_default`, "array[StringEnumRef]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_string_enum_default`)) { + self$`array_string_enum_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_default`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_string_default`)) { + self$`array_string_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_default`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_integer_default`)) { + self$`array_integer_default` <- ApiClient$new()$deserializeObj(this_object$`array_integer_default`, "array[integer]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_string`)) { + self$`array_string` <- ApiClient$new()$deserializeObj(this_object$`array_string`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_string_nullable`)) { + self$`array_string_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_nullable`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`array_string_extension_nullable`)) { + self$`array_string_extension_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_extension_nullable`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`string_nullable`)) { + self$`string_nullable` <- this_object$`string_nullable` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DefaultValue in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`array_string_enum_ref_default`)) { + sprintf( + '"array_string_enum_ref_default": + [%s] +', + paste(sapply(self$`array_string_enum_ref_default`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",") + ) + }, + if (!is.null(self$`array_string_enum_default`)) { + sprintf( + '"array_string_enum_default": + [%s] + ', + paste(unlist(lapply(self$`array_string_enum_default`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`array_string_default`)) { + sprintf( + '"array_string_default": + [%s] + ', + paste(unlist(lapply(self$`array_string_default`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`array_integer_default`)) { + sprintf( + '"array_integer_default": + [%s] + ', + paste(unlist(lapply(self$`array_integer_default`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`array_string`)) { + sprintf( + '"array_string": + [%s] + ', + paste(unlist(lapply(self$`array_string`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`array_string_nullable`)) { + sprintf( + '"array_string_nullable": + [%s] + ', + paste(unlist(lapply(self$`array_string_nullable`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`array_string_extension_nullable`)) { + sprintf( + '"array_string_extension_nullable": + [%s] + ', + paste(unlist(lapply(self$`array_string_extension_nullable`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`string_nullable`)) { + sprintf( + '"string_nullable": + "%s" + ', + self$`string_nullable` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of DefaultValue + #' + #' @description + #' Deserialize JSON string into an instance of DefaultValue + #' + #' @param input_json the JSON input + #' @return the instance of DefaultValue + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`array_string_enum_ref_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_ref_default`, "array[StringEnumRef]", loadNamespace("openapi")) + self$`array_string_enum_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_enum_default`, "array[character]", loadNamespace("openapi")) + self$`array_string_default` <- ApiClient$new()$deserializeObj(this_object$`array_string_default`, "array[character]", loadNamespace("openapi")) + self$`array_integer_default` <- ApiClient$new()$deserializeObj(this_object$`array_integer_default`, "array[integer]", loadNamespace("openapi")) + self$`array_string` <- ApiClient$new()$deserializeObj(this_object$`array_string`, "array[character]", loadNamespace("openapi")) + self$`array_string_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_nullable`, "array[character]", loadNamespace("openapi")) + self$`array_string_extension_nullable` <- ApiClient$new()$deserializeObj(this_object$`array_string_extension_nullable`, "array[character]", loadNamespace("openapi")) + self$`string_nullable` <- this_object$`string_nullable` + self + }, + #' Validate JSON input with respect to DefaultValue + #' + #' @description + #' Validate JSON input with respect to DefaultValue and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of DefaultValue + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# DefaultValue$unlock() +# +## Below is an example to define the print function +# DefaultValue$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# DefaultValue$lock() + diff --git a/samples/client/echo_api/r/R/form_api.R b/samples/client/echo_api/r/R/form_api.R new file mode 100644 index 00000000000..188c5a29db2 --- /dev/null +++ b/samples/client/echo_api/r/R/form_api.R @@ -0,0 +1,327 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Form operations +#' @description FormApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestFormIntegerBooleanString } \emph{ Test form parameter(s) } +#' Test form parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } integer_form integer +#' \item \emph{ @param } boolean_form character +#' \item \emph{ @param } string_form character +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestFormOneof } \emph{ Test form parameter(s) for oneOf schema } +#' Test form parameter(s) for oneOf schema +#' +#' \itemize{ +#' \item \emph{ @param } form1 character +#' \item \emph{ @param } form2 integer +#' \item \emph{ @param } form3 character +#' \item \emph{ @param } form4 character +#' \item \emph{ @param } id integer +#' \item \emph{ @param } name character +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestFormIntegerBooleanString #################### +#' +#' library(openapi) +#' var_integer_form <- 56 # integer | (Optional) +#' var_boolean_form <- "boolean_form_example" # character | (Optional) +#' var_string_form <- "string_form_example" # character | (Optional) +#' +#' #Test form parameter(s) +#' api_instance <- FormApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_formdata_file = "result.txt") +#' result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_form) +#' dput(result) +#' +#' +#' #################### TestFormOneof #################### +#' +#' library(openapi) +#' var_form1 <- "form1_example" # character | (Optional) +#' var_form2 <- 56 # integer | (Optional) +#' var_form3 <- "form3_example" # character | (Optional) +#' var_form4 <- "form4_example" # character | (Optional) +#' var_id <- 56 # integer | (Optional) +#' var_name <- "name_example" # character | (Optional) +#' +#' #Test form parameter(s) for oneOf schema +#' api_instance <- FormApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_namedata_file = "result.txt") +#' result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_name) +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +FormApi <- R6::R6Class( + "FormApi", + public = list( + api_client = NULL, + #' Initialize a new FormApi. + #' + #' @description + #' Initialize a new FormApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' Test form parameter(s) + #' + #' @description + #' Test form parameter(s) + #' + #' @param integer_form (optional) No description + #' @param boolean_form (optional) No description + #' @param string_form (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestFormIntegerBooleanString = function(integer_form = NULL, boolean_form = NULL, string_form = NULL, data_file = NULL, ...) { + local_var_response <- self$TestFormIntegerBooleanStringWithHttpInfo(integer_form, boolean_form, string_form, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test form parameter(s) + #' + #' @description + #' Test form parameter(s) + #' + #' @param integer_form (optional) No description + #' @param boolean_form (optional) No description + #' @param string_form (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestFormIntegerBooleanStringWithHttpInfo = function(integer_form = NULL, boolean_form = NULL, string_form = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + + form_params["integer_form"] <- `integer_form` + form_params["boolean_form"] <- `boolean_form` + form_params["string_form"] <- `string_form` + local_var_url_path <- "/form/integer/boolean/string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/x-www-form-urlencoded") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test form parameter(s) for oneOf schema + #' + #' @description + #' Test form parameter(s) for oneOf schema + #' + #' @param form1 (optional) No description + #' @param form2 (optional) No description + #' @param form3 (optional) No description + #' @param form4 (optional) No description + #' @param id (optional) No description + #' @param name (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestFormOneof = function(form1 = NULL, form2 = NULL, form3 = NULL, form4 = NULL, id = NULL, name = NULL, data_file = NULL, ...) { + local_var_response <- self$TestFormOneofWithHttpInfo(form1, form2, form3, form4, id, name, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test form parameter(s) for oneOf schema + #' + #' @description + #' Test form parameter(s) for oneOf schema + #' + #' @param form1 (optional) No description + #' @param form2 (optional) No description + #' @param form3 (optional) No description + #' @param form4 (optional) No description + #' @param id (optional) No description + #' @param name (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestFormOneofWithHttpInfo = function(form1 = NULL, form2 = NULL, form3 = NULL, form4 = NULL, id = NULL, name = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + + + + + form_params["form1"] <- `form1` + form_params["form2"] <- `form2` + form_params["form3"] <- `form3` + form_params["form4"] <- `form4` + form_params["id"] <- `id` + form_params["name"] <- `name` + local_var_url_path <- "/form/oneof" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list("application/x-www-form-urlencoded") + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/header_api.R b/samples/client/echo_api/r/R/header_api.R new file mode 100644 index 00000000000..e561a35c304 --- /dev/null +++ b/samples/client/echo_api/r/R/header_api.R @@ -0,0 +1,194 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Header operations +#' @description HeaderApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestHeaderIntegerBooleanStringEnums } \emph{ Test header parameter(s) } +#' Test header parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } integer_header integer +#' \item \emph{ @param } boolean_header character +#' \item \emph{ @param } string_header character +#' \item \emph{ @param } enum_nonref_string_header Enum < [success, failure, unclassified] > +#' \item \emph{ @param } enum_ref_string_header \link{StringEnumRef} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestHeaderIntegerBooleanStringEnums #################### +#' +#' library(openapi) +#' var_integer_header <- 56 # integer | (Optional) +#' var_boolean_header <- "boolean_header_example" # character | (Optional) +#' var_string_header <- "string_header_example" # character | (Optional) +#' var_enum_nonref_string_header <- "enum_nonref_string_header_example" # character | (Optional) +#' var_enum_ref_string_header <- StringEnumRef$new() # StringEnumRef | (Optional) +#' +#' #Test header parameter(s) +#' api_instance <- HeaderApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_headerdata_file = "result.txt") +#' result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_header) +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +HeaderApi <- R6::R6Class( + "HeaderApi", + public = list( + api_client = NULL, + #' Initialize a new HeaderApi. + #' + #' @description + #' Initialize a new HeaderApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' Test header parameter(s) + #' + #' @description + #' Test header parameter(s) + #' + #' @param integer_header (optional) No description + #' @param boolean_header (optional) No description + #' @param string_header (optional) No description + #' @param enum_nonref_string_header (optional) No description + #' @param enum_ref_string_header (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestHeaderIntegerBooleanStringEnums = function(integer_header = NULL, boolean_header = NULL, string_header = NULL, enum_nonref_string_header = NULL, enum_ref_string_header = NULL, data_file = NULL, ...) { + local_var_response <- self$TestHeaderIntegerBooleanStringEnumsWithHttpInfo(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test header parameter(s) + #' + #' @description + #' Test header parameter(s) + #' + #' @param integer_header (optional) No description + #' @param boolean_header (optional) No description + #' @param string_header (optional) No description + #' @param enum_nonref_string_header (optional) No description + #' @param enum_ref_string_header (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestHeaderIntegerBooleanStringEnumsWithHttpInfo = function(integer_header = NULL, boolean_header = NULL, string_header = NULL, enum_nonref_string_header = NULL, enum_ref_string_header = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + + + + header_params["integer_header"] <- `integer_header` + + header_params["boolean_header"] <- `boolean_header` + + header_params["string_header"] <- `string_header` + + header_params["enum_nonref_string_header"] <- `enum_nonref_string_header` + + header_params["enum_ref_string_header"] <- `enum_ref_string_header` + + local_var_url_path <- "/header/integer/boolean/string/enums" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/number_properties_only.R b/samples/client/echo_api/r/R/number_properties_only.R new file mode 100644 index 00000000000..a025def4e58 --- /dev/null +++ b/samples/client/echo_api/r/R/number_properties_only.R @@ -0,0 +1,224 @@ +#' Create a new NumberPropertiesOnly +#' +#' @description +#' NumberPropertiesOnly Class +#' +#' @docType class +#' @title NumberPropertiesOnly +#' @description NumberPropertiesOnly Class +#' @format An \code{R6Class} generator object +#' @field number numeric [optional] +#' @field float numeric [optional] +#' @field double numeric [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +NumberPropertiesOnly <- R6::R6Class( + "NumberPropertiesOnly", + public = list( + `number` = NULL, + `float` = NULL, + `double` = NULL, + #' Initialize a new NumberPropertiesOnly class. + #' + #' @description + #' Initialize a new NumberPropertiesOnly class. + #' + #' @param number number + #' @param float float + #' @param double double + #' @param ... Other optional arguments. + #' @export + initialize = function(`number` = NULL, `float` = NULL, `double` = NULL, ...) { + if (!is.null(`number`)) { + self$`number` <- `number` + } + if (!is.null(`float`)) { + if (!(is.numeric(`float`) && length(`float`) == 1)) { + stop(paste("Error! Invalid data for `float`. Must be a number:", `float`)) + } + self$`float` <- `float` + } + if (!is.null(`double`)) { + if (!(is.numeric(`double`) && length(`double`) == 1)) { + stop(paste("Error! Invalid data for `double`. Must be a number:", `double`)) + } + self$`double` <- `double` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return NumberPropertiesOnly in JSON format + #' @export + toJSON = function() { + NumberPropertiesOnlyObject <- list() + if (!is.null(self$`number`)) { + NumberPropertiesOnlyObject[["number"]] <- + self$`number` + } + if (!is.null(self$`float`)) { + NumberPropertiesOnlyObject[["float"]] <- + self$`float` + } + if (!is.null(self$`double`)) { + NumberPropertiesOnlyObject[["double"]] <- + self$`double` + } + NumberPropertiesOnlyObject + }, + #' Deserialize JSON string into an instance of NumberPropertiesOnly + #' + #' @description + #' Deserialize JSON string into an instance of NumberPropertiesOnly + #' + #' @param input_json the JSON input + #' @return the instance of NumberPropertiesOnly + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`number`)) { + self$`number` <- this_object$`number` + } + if (!is.null(this_object$`float`)) { + self$`float` <- this_object$`float` + } + if (!is.null(this_object$`double`)) { + self$`double` <- this_object$`double` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return NumberPropertiesOnly in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`number`)) { + sprintf( + '"number": + %d + ', + self$`number` + ) + }, + if (!is.null(self$`float`)) { + sprintf( + '"float": + %d + ', + self$`float` + ) + }, + if (!is.null(self$`double`)) { + sprintf( + '"double": + %d + ', + self$`double` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of NumberPropertiesOnly + #' + #' @description + #' Deserialize JSON string into an instance of NumberPropertiesOnly + #' + #' @param input_json the JSON input + #' @return the instance of NumberPropertiesOnly + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`number` <- this_object$`number` + self$`float` <- this_object$`float` + self$`double` <- this_object$`double` + self + }, + #' Validate JSON input with respect to NumberPropertiesOnly + #' + #' @description + #' Validate JSON input with respect to NumberPropertiesOnly and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of NumberPropertiesOnly + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + if (self$`double` > 50.2) { + return(FALSE) + } + if (self$`double` < 0.8) { + return(FALSE) + } + + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + if (self$`double` > 50.2) { + invalid_fields["double"] <- "Invalid value for `double`, must be smaller than or equal to 50.2." + } + if (self$`double` < 0.8) { + invalid_fields["double"] <- "Invalid value for `double`, must be bigger than or equal to 0.8." + } + + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# NumberPropertiesOnly$unlock() +# +## Below is an example to define the print function +# NumberPropertiesOnly$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# NumberPropertiesOnly$lock() + diff --git a/samples/client/echo_api/r/R/path_api.R b/samples/client/echo_api/r/R/path_api.R new file mode 100644 index 00000000000..7d0b9ba2e37 --- /dev/null +++ b/samples/client/echo_api/r/R/path_api.R @@ -0,0 +1,211 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Path operations +#' @description PathApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath } \emph{ Test path parameter(s) } +#' Test path parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } path_string character +#' \item \emph{ @param } path_integer integer +#' \item \emph{ @param } enum_nonref_string_path Enum < [success, failure, unclassified] > +#' \item \emph{ @param } enum_ref_string_path \link{StringEnumRef} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath #################### +#' +#' library(openapi) +#' var_path_string <- "path_string_example" # character | +#' var_path_integer <- 56 # integer | +#' var_enum_nonref_string_path <- "enum_nonref_string_path_example" # character | +#' var_enum_ref_string_path <- StringEnumRef$new() # StringEnumRef | +#' +#' #Test path parameter(s) +#' api_instance <- PathApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_pathdata_file = "result.txt") +#' result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_path) +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +PathApi <- R6::R6Class( + "PathApi", + public = list( + api_client = NULL, + #' Initialize a new PathApi. + #' + #' @description + #' Initialize a new PathApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' Test path parameter(s) + #' + #' @description + #' Test path parameter(s) + #' + #' @param path_string + #' @param path_integer + #' @param enum_nonref_string_path + #' @param enum_ref_string_path + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath = function(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = NULL, ...) { + local_var_response <- self$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test path parameter(s) + #' + #' @description + #' Test path parameter(s) + #' + #' @param path_string + #' @param path_integer + #' @param enum_nonref_string_path + #' @param enum_ref_string_path + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo = function(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + if (missing(`path_string`)) { + stop("Missing required parameter `path_string`.") + } + + if (missing(`path_integer`)) { + stop("Missing required parameter `path_integer`.") + } + + if (missing(`enum_nonref_string_path`)) { + stop("Missing required parameter `enum_nonref_string_path`.") + } + + if (missing(`enum_ref_string_path`)) { + stop("Missing required parameter `enum_ref_string_path`.") + } + + + + + + local_var_url_path <- "/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}" + if (!missing(`path_string`)) { + local_var_url_path <- gsub("\\{path_string\\}", URLencode(as.character(`path_string`), reserved = TRUE), local_var_url_path) + } + + if (!missing(`path_integer`)) { + local_var_url_path <- gsub("\\{path_integer\\}", URLencode(as.character(`path_integer`), reserved = TRUE), local_var_url_path) + } + + if (!missing(`enum_nonref_string_path`)) { + local_var_url_path <- gsub("\\{enum_nonref_string_path\\}", URLencode(as.character(`enum_nonref_string_path`), reserved = TRUE), local_var_url_path) + } + + if (!missing(`enum_ref_string_path`)) { + local_var_url_path <- gsub("\\{enum_ref_string_path\\}", URLencode(as.character(`enum_ref_string_path`), reserved = TRUE), local_var_url_path) + } + + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/pet.R b/samples/client/echo_api/r/R/pet.R new file mode 100644 index 00000000000..9d2e80b3bb2 --- /dev/null +++ b/samples/client/echo_api/r/R/pet.R @@ -0,0 +1,330 @@ +#' Create a new Pet +#' +#' @description +#' Pet Class +#' +#' @docType class +#' @title Pet +#' @description Pet Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field name character +#' @field category \link{Category} [optional] +#' @field photoUrls list(character) +#' @field tags list(\link{Tag}) [optional] +#' @field status pet status in the store character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Pet <- R6::R6Class( + "Pet", + public = list( + `id` = NULL, + `name` = NULL, + `category` = NULL, + `photoUrls` = NULL, + `tags` = NULL, + `status` = NULL, + #' Initialize a new Pet class. + #' + #' @description + #' Initialize a new Pet class. + #' + #' @param name name + #' @param photoUrls photoUrls + #' @param id id + #' @param category category + #' @param tags tags + #' @param status pet status in the store + #' @param ... Other optional arguments. + #' @export + initialize = function(`name`, `photoUrls`, `id` = NULL, `category` = NULL, `tags` = NULL, `status` = NULL, ...) { + if (!missing(`name`)) { + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } + self$`name` <- `name` + } + if (!missing(`photoUrls`)) { + stopifnot(is.vector(`photoUrls`), length(`photoUrls`) != 0) + sapply(`photoUrls`, function(x) stopifnot(is.character(x))) + self$`photoUrls` <- `photoUrls` + } + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`category`)) { + stopifnot(R6::is.R6(`category`)) + self$`category` <- `category` + } + if (!is.null(`tags`)) { + stopifnot(is.vector(`tags`), length(`tags`) != 0) + sapply(`tags`, function(x) stopifnot(R6::is.R6(x))) + self$`tags` <- `tags` + } + if (!is.null(`status`)) { + if (!(`status` %in% c("available", "pending", "sold"))) { + stop(paste("Error! \"", `status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) + } + if (!(is.character(`status`) && length(`status`) == 1)) { + stop(paste("Error! Invalid data for `status`. Must be a string:", `status`)) + } + self$`status` <- `status` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Pet in JSON format + #' @export + toJSON = function() { + PetObject <- list() + if (!is.null(self$`id`)) { + PetObject[["id"]] <- + self$`id` + } + if (!is.null(self$`name`)) { + PetObject[["name"]] <- + self$`name` + } + if (!is.null(self$`category`)) { + PetObject[["category"]] <- + self$`category`$toJSON() + } + if (!is.null(self$`photoUrls`)) { + PetObject[["photoUrls"]] <- + self$`photoUrls` + } + if (!is.null(self$`tags`)) { + PetObject[["tags"]] <- + lapply(self$`tags`, function(x) x$toJSON()) + } + if (!is.null(self$`status`)) { + PetObject[["status"]] <- + self$`status` + } + PetObject + }, + #' Deserialize JSON string into an instance of Pet + #' + #' @description + #' Deserialize JSON string into an instance of Pet + #' + #' @param input_json the JSON input + #' @return the instance of Pet + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`name`)) { + self$`name` <- this_object$`name` + } + if (!is.null(this_object$`category`)) { + `category_object` <- Category$new() + `category_object`$fromJSON(jsonlite::toJSON(this_object$`category`, auto_unbox = TRUE, digits = NA)) + self$`category` <- `category_object` + } + if (!is.null(this_object$`photoUrls`)) { + self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("openapi")) + } + if (!is.null(this_object$`tags`)) { + self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("openapi")) + } + if (!is.null(this_object$`status`)) { + if (!is.null(this_object$`status`) && !(this_object$`status` %in% c("available", "pending", "sold"))) { + stop(paste("Error! \"", this_object$`status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) + } + self$`status` <- this_object$`status` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Pet in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`name`)) { + sprintf( + '"name": + "%s" + ', + self$`name` + ) + }, + if (!is.null(self$`category`)) { + sprintf( + '"category": + %s + ', + jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA) + ) + }, + if (!is.null(self$`photoUrls`)) { + sprintf( + '"photoUrls": + [%s] + ', + paste(unlist(lapply(self$`photoUrls`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + }, + if (!is.null(self$`tags`)) { + sprintf( + '"tags": + [%s] +', + paste(sapply(self$`tags`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox = TRUE, digits = NA)), collapse = ",") + ) + }, + if (!is.null(self$`status`)) { + sprintf( + '"status": + "%s" + ', + self$`status` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Pet + #' + #' @description + #' Deserialize JSON string into an instance of Pet + #' + #' @param input_json the JSON input + #' @return the instance of Pet + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`name` <- this_object$`name` + self$`category` <- Category$new()$fromJSON(jsonlite::toJSON(this_object$`category`, auto_unbox = TRUE, digits = NA)) + self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("openapi")) + self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("openapi")) + if (!is.null(this_object$`status`) && !(this_object$`status` %in% c("available", "pending", "sold"))) { + stop(paste("Error! \"", this_object$`status`, "\" cannot be assigned to `status`. Must be \"available\", \"pending\", \"sold\".", sep = "")) + } + self$`status` <- this_object$`status` + self + }, + #' Validate JSON input with respect to Pet + #' + #' @description + #' Validate JSON input with respect to Pet and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `name` + if (!is.null(input_json$`name`)) { + if (!(is.character(input_json$`name`) && length(input_json$`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", input_json$`name`)) + } + } else { + stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `name` is missing.")) + } + # check the required field `photoUrls` + if (!is.null(input_json$`photoUrls`)) { + stopifnot(is.vector(input_json$`photoUrls`), length(input_json$`photoUrls`) != 0) + tmp <- sapply(input_json$`photoUrls`, function(x) stopifnot(is.character(x))) + } else { + stop(paste("The JSON input `", input, "` is invalid for Pet: the required field `photoUrls` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Pet + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + # check if the required `name` is null + if (is.null(self$`name`)) { + return(FALSE) + } + + # check if the required `photoUrls` is null + if (is.null(self$`photoUrls`)) { + return(FALSE) + } + + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + # check if the required `name` is null + if (is.null(self$`name`)) { + invalid_fields["name"] <- "Non-nullable required field `name` cannot be null." + } + + # check if the required `photoUrls` is null + if (is.null(self$`photoUrls`)) { + invalid_fields["photoUrls"] <- "Non-nullable required field `photoUrls` cannot be null." + } + + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# Pet$unlock() +# +## Below is an example to define the print function +# Pet$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# Pet$lock() + diff --git a/samples/client/echo_api/r/R/query.R b/samples/client/echo_api/r/R/query.R new file mode 100644 index 00000000000..4dcf16ddaf2 --- /dev/null +++ b/samples/client/echo_api/r/R/query.R @@ -0,0 +1,187 @@ +#' Create a new Query +#' +#' @description +#' Query Class +#' +#' @docType class +#' @title Query +#' @description Query Class +#' @format An \code{R6Class} generator object +#' @field id Query integer [optional] +#' @field outcomes list(character) [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Query <- R6::R6Class( + "Query", + public = list( + `id` = NULL, + `outcomes` = NULL, + #' Initialize a new Query class. + #' + #' @description + #' Initialize a new Query class. + #' + #' @param id Query + #' @param outcomes outcomes. Default to ["SUCCESS","FAILURE"]. + #' @param ... Other optional arguments. + #' @export + initialize = function(`id` = NULL, `outcomes` = ["SUCCESS","FAILURE"], ...) { + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`outcomes`)) { + stopifnot(is.vector(`outcomes`), length(`outcomes`) != 0) + sapply(`outcomes`, function(x) stopifnot(is.character(x))) + self$`outcomes` <- `outcomes` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Query in JSON format + #' @export + toJSON = function() { + QueryObject <- list() + if (!is.null(self$`id`)) { + QueryObject[["id"]] <- + self$`id` + } + if (!is.null(self$`outcomes`)) { + QueryObject[["outcomes"]] <- + self$`outcomes` + } + QueryObject + }, + #' Deserialize JSON string into an instance of Query + #' + #' @description + #' Deserialize JSON string into an instance of Query + #' + #' @param input_json the JSON input + #' @return the instance of Query + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`outcomes`)) { + self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi")) + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Query in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`outcomes`)) { + sprintf( + '"outcomes": + [%s] + ', + paste(unlist(lapply(self$`outcomes`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Query + #' + #' @description + #' Deserialize JSON string into an instance of Query + #' + #' @param input_json the JSON input + #' @return the instance of Query + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`outcomes` <- ApiClient$new()$deserializeObj(this_object$`outcomes`, "array[character]", loadNamespace("openapi")) + self + }, + #' Validate JSON input with respect to Query + #' + #' @description + #' Validate JSON input with respect to Query and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Query + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# Query$unlock() +# +## Below is an example to define the print function +# Query$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# Query$lock() + diff --git a/samples/client/echo_api/r/R/query_api.R b/samples/client/echo_api/r/R/query_api.R new file mode 100644 index 00000000000..c9a97540cc5 --- /dev/null +++ b/samples/client/echo_api/r/R/query_api.R @@ -0,0 +1,1051 @@ +#' Echo Server API +#' +#' Echo Server API +#' +#' The version of the OpenAPI document: 0.1.0 +#' Contact: team@openapitools.org +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Query operations +#' @description QueryApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ TestEnumRefString } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } enum_nonref_string_query Enum < [success, failure, unclassified] > +#' \item \emph{ @param } enum_ref_string_query \link{StringEnumRef} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryDatetimeDateString } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } datetime_query character +#' \item \emph{ @param } date_query character +#' \item \emph{ @param } string_query character +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryIntegerBooleanString } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } integer_query integer +#' \item \emph{ @param } boolean_query character +#' \item \emph{ @param } string_query character +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryStyleDeepObjectExplodeTrueObject } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } query_object \link{Pet} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryStyleDeepObjectExplodeTrueObjectAllOf } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } query_object \link{TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryStyleFormExplodeTrueArrayString } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } query_object \link{TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryStyleFormExplodeTrueObject } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } query_object \link{Pet} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ TestQueryStyleFormExplodeTrueObjectAllOf } \emph{ Test query parameter(s) } +#' Test query parameter(s) +#' +#' \itemize{ +#' \item \emph{ @param } query_object \link{DataQuery} +#' +#' +#' \item status code : 200 | Successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### TestEnumRefString #################### +#' +#' library(openapi) +#' var_enum_nonref_string_query <- "enum_nonref_string_query_example" # character | (Optional) +#' var_enum_ref_string_query <- StringEnumRef$new() # StringEnumRef | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestEnumRefString(enum_nonref_string_query = var_enum_nonref_string_query, enum_ref_string_query = var_enum_ref_string_querydata_file = "result.txt") +#' result <- api_instance$TestEnumRefString(enum_nonref_string_query = var_enum_nonref_string_query, enum_ref_string_query = var_enum_ref_string_query) +#' dput(result) +#' +#' +#' #################### TestQueryDatetimeDateString #################### +#' +#' library(openapi) +#' var_datetime_query <- "datetime_query_example" # character | (Optional) +#' var_date_query <- "date_query_example" # character | (Optional) +#' var_string_query <- "string_query_example" # character | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryDatetimeDateString(datetime_query = var_datetime_query, date_query = var_date_query, string_query = var_string_querydata_file = "result.txt") +#' result <- api_instance$TestQueryDatetimeDateString(datetime_query = var_datetime_query, date_query = var_date_query, string_query = var_string_query) +#' dput(result) +#' +#' +#' #################### TestQueryIntegerBooleanString #################### +#' +#' library(openapi) +#' var_integer_query <- 56 # integer | (Optional) +#' var_boolean_query <- "boolean_query_example" # character | (Optional) +#' var_string_query <- "string_query_example" # character | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryIntegerBooleanString(integer_query = var_integer_query, boolean_query = var_boolean_query, string_query = var_string_querydata_file = "result.txt") +#' result <- api_instance$TestQueryIntegerBooleanString(integer_query = var_integer_query, boolean_query = var_boolean_query, string_query = var_string_query) +#' dput(result) +#' +#' +#' #################### TestQueryStyleDeepObjectExplodeTrueObject #################### +#' +#' library(openapi) +#' var_query_object <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObject(query_object = var_query_objectdata_file = "result.txt") +#' result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObject(query_object = var_query_object) +#' dput(result) +#' +#' +#' #################### TestQueryStyleDeepObjectExplodeTrueObjectAllOf #################### +#' +#' library(openapi) +#' var_query_object <- test_query_style_deepObject_explode_true_object_allOf_query_object_parameter$new("size_example", "color_example", 123, "name_example") # TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObjectAllOf(query_object = var_query_objectdata_file = "result.txt") +#' result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObjectAllOf(query_object = var_query_object) +#' dput(result) +#' +#' +#' #################### TestQueryStyleFormExplodeTrueArrayString #################### +#' +#' library(openapi) +#' var_query_object <- test_query_style_form_explode_true_array_string_query_object_parameter$new(c("values_example")) # TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryStyleFormExplodeTrueArrayString(query_object = var_query_objectdata_file = "result.txt") +#' result <- api_instance$TestQueryStyleFormExplodeTrueArrayString(query_object = var_query_object) +#' dput(result) +#' +#' +#' #################### TestQueryStyleFormExplodeTrueObject #################### +#' +#' library(openapi) +#' var_query_object <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryStyleFormExplodeTrueObject(query_object = var_query_objectdata_file = "result.txt") +#' result <- api_instance$TestQueryStyleFormExplodeTrueObject(query_object = var_query_object) +#' dput(result) +#' +#' +#' #################### TestQueryStyleFormExplodeTrueObjectAllOf #################### +#' +#' library(openapi) +#' var_query_object <- DataQuery$new(123, c("SUCCESS"), "suffix_example", "text_example", "date_example") # DataQuery | (Optional) +#' +#' #Test query parameter(s) +#' api_instance <- QueryApi$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$TestQueryStyleFormExplodeTrueObjectAllOf(query_object = var_query_objectdata_file = "result.txt") +#' result <- api_instance$TestQueryStyleFormExplodeTrueObjectAllOf(query_object = var_query_object) +#' dput(result) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +QueryApi <- R6::R6Class( + "QueryApi", + public = list( + api_client = NULL, + #' Initialize a new QueryApi. + #' + #' @description + #' Initialize a new QueryApi. + #' + #' @param api_client An instance of API client. + #' @export + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param enum_nonref_string_query (optional) No description + #' @param enum_ref_string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestEnumRefString = function(enum_nonref_string_query = NULL, enum_ref_string_query = NULL, data_file = NULL, ...) { + local_var_response <- self$TestEnumRefStringWithHttpInfo(enum_nonref_string_query, enum_ref_string_query, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param enum_nonref_string_query (optional) No description + #' @param enum_ref_string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestEnumRefStringWithHttpInfo = function(enum_nonref_string_query = NULL, enum_ref_string_query = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + if (!(`enum_nonref_string_query` %in% c("success", "failure", "unclassified"))) { + stop("Invalid value for enum_nonref_string_query when calling QueryApi$TestEnumRefString. Must be [success, failure, unclassified].") + } + query_params[["enum_nonref_string_query"]] <- `enum_nonref_string_query` + + query_params[["enum_ref_string_query"]] <- `enum_ref_string_query` + + local_var_url_path <- "/query/enum_ref_string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param datetime_query (optional) No description + #' @param date_query (optional) No description + #' @param string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryDatetimeDateString = function(datetime_query = NULL, date_query = NULL, string_query = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryDatetimeDateStringWithHttpInfo(datetime_query, date_query, string_query, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param datetime_query (optional) No description + #' @param date_query (optional) No description + #' @param string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryDatetimeDateStringWithHttpInfo = function(datetime_query = NULL, date_query = NULL, string_query = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + + query_params[["datetime_query"]] <- `datetime_query` + + query_params[["date_query"]] <- `date_query` + + query_params[["string_query"]] <- `string_query` + + local_var_url_path <- "/query/datetime/date/string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param integer_query (optional) No description + #' @param boolean_query (optional) No description + #' @param string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryIntegerBooleanString = function(integer_query = NULL, boolean_query = NULL, string_query = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryIntegerBooleanStringWithHttpInfo(integer_query, boolean_query, string_query, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param integer_query (optional) No description + #' @param boolean_query (optional) No description + #' @param string_query (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryIntegerBooleanStringWithHttpInfo = function(integer_query = NULL, boolean_query = NULL, string_query = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + + + query_params[["integer_query"]] <- `integer_query` + + query_params[["boolean_query"]] <- `boolean_query` + + query_params[["string_query"]] <- `string_query` + + local_var_url_path <- "/query/integer/boolean/string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryStyleDeepObjectExplodeTrueObject = function(query_object = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo(query_object, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryStyleDeepObjectExplodeTrueObjectWithHttpInfo = function(query_object = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + query_params[["query_object"]] <- `query_object` + + local_var_url_path <- "/query/style_deepObject/explode_true/object" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryStyleDeepObjectExplodeTrueObjectAllOf = function(query_object = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo(query_object, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryStyleDeepObjectExplodeTrueObjectAllOfWithHttpInfo = function(query_object = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + query_params[["query_object"]] <- `query_object` + + local_var_url_path <- "/query/style_deepObject/explode_true/object/allOf" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryStyleFormExplodeTrueArrayString = function(query_object = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryStyleFormExplodeTrueArrayStringWithHttpInfo(query_object, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryStyleFormExplodeTrueArrayStringWithHttpInfo = function(query_object = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + query_params[["query_object"]] <- `query_object` + + local_var_url_path <- "/query/style_form/explode_true/array_string" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryStyleFormExplodeTrueObject = function(query_object = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryStyleFormExplodeTrueObjectWithHttpInfo(query_object, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryStyleFormExplodeTrueObjectWithHttpInfo = function(query_object = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + query_params[["query_object"]] <- `query_object` + + local_var_url_path <- "/query/style_form/explode_true/object" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + TestQueryStyleFormExplodeTrueObjectAllOf = function(query_object = NULL, data_file = NULL, ...) { + local_var_response <- self$TestQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(query_object, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + #' Test query parameter(s) + #' + #' @description + #' Test query parameter(s) + #' + #' @param query_object (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (character) with additional information such as HTTP status code, headers + #' @export + TestQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo = function(query_object = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + + query_params[["query_object"]] <- `query_object` + + local_var_url_path <- "/query/style_form/explode_true/object/allOf" + + # The Accept request HTTP header + local_var_accepts <- list("text/plain") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("openapi")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/samples/client/echo_api/r/R/string_enum_ref.R b/samples/client/echo_api/r/R/string_enum_ref.R new file mode 100644 index 00000000000..d13f7fbf67a --- /dev/null +++ b/samples/client/echo_api/r/R/string_enum_ref.R @@ -0,0 +1,88 @@ +#' @docType class +#' @title StringEnumRef +#' @description StringEnumRef Class +#' @format An \code{R6Class} generator object +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +StringEnumRef <- R6::R6Class( + "StringEnumRef", + public = list( + #' Initialize a new StringEnumRef class. + #' + #' @description + #' Initialize a new StringEnumRef class. + #' + #' @param ... Optional arguments. + #' @export + initialize = function(...) { + local.optional.var <- list(...) + val <- unlist(local.optional.var) + enumvec <- .parse_StringEnumRef() + + stopifnot(length(val) == 1L) + + if (!val %in% enumvec) + stop("Use one of the valid values: ", + paste0(enumvec, collapse = ", ")) + private$value <- val + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return StringEnumRef in JSON format + #' @export + toJSON = function() { + jsonlite::toJSON(private$value, auto_unbox = TRUE) + }, + #' Deserialize JSON string into an instance of StringEnumRef + #' + #' @description + #' Deserialize JSON string into an instance of StringEnumRef + #' + #' @param input_json the JSON input + #' @return the instance of StringEnumRef + #' @export + fromJSON = function(input_json) { + private$value <- jsonlite::fromJSON(input_json, + simplifyVector = FALSE) + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return StringEnumRef in JSON format + #' @export + toJSONString = function() { + as.character(jsonlite::toJSON(private$value, + auto_unbox = TRUE)) + }, + #' Deserialize JSON string into an instance of StringEnumRef + #' + #' @description + #' Deserialize JSON string into an instance of StringEnumRef + #' + #' @param input_json the JSON input + #' @return the instance of StringEnumRef + #' @export + fromJSONString = function(input_json) { + private$value <- jsonlite::fromJSON(input_json, + simplifyVector = FALSE) + self + } + ), + private = list( + value = NULL + ) +) + +# add to utils.R +.parse_StringEnumRef <- function(vals) { + res <- gsub("^\\[|\\]$", "", "[success, failure, unclassified]") + unlist(strsplit(res, ", ")) +} + diff --git a/samples/client/echo_api/r/R/tag.R b/samples/client/echo_api/r/R/tag.R new file mode 100644 index 00000000000..829aa0d8206 --- /dev/null +++ b/samples/client/echo_api/r/R/tag.R @@ -0,0 +1,188 @@ +#' Create a new Tag +#' +#' @description +#' Tag Class +#' +#' @docType class +#' @title Tag +#' @description Tag Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field name character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Tag <- R6::R6Class( + "Tag", + public = list( + `id` = NULL, + `name` = NULL, + #' Initialize a new Tag class. + #' + #' @description + #' Initialize a new Tag class. + #' + #' @param id id + #' @param name name + #' @param ... Other optional arguments. + #' @export + initialize = function(`id` = NULL, `name` = NULL, ...) { + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`name`)) { + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } + self$`name` <- `name` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Tag in JSON format + #' @export + toJSON = function() { + TagObject <- list() + if (!is.null(self$`id`)) { + TagObject[["id"]] <- + self$`id` + } + if (!is.null(self$`name`)) { + TagObject[["name"]] <- + self$`name` + } + TagObject + }, + #' Deserialize JSON string into an instance of Tag + #' + #' @description + #' Deserialize JSON string into an instance of Tag + #' + #' @param input_json the JSON input + #' @return the instance of Tag + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`name`)) { + self$`name` <- this_object$`name` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Tag in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`name`)) { + sprintf( + '"name": + "%s" + ', + self$`name` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Tag + #' + #' @description + #' Deserialize JSON string into an instance of Tag + #' + #' @param input_json the JSON input + #' @return the instance of Tag + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`name` <- this_object$`name` + self + }, + #' Validate JSON input with respect to Tag + #' + #' @description + #' Validate JSON input with respect to Tag and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Tag + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# Tag$unlock() +# +## Below is an example to define the print function +# Tag$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# Tag$lock() + diff --git a/samples/client/echo_api/r/R/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R b/samples/client/echo_api/r/R/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R new file mode 100644 index 00000000000..0dc284be8a9 --- /dev/null +++ b/samples/client/echo_api/r/R/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R @@ -0,0 +1,238 @@ +#' Create a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter +#' +#' @description +#' TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter Class +#' +#' @docType class +#' @title TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter +#' @description TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter Class +#' @format An \code{R6Class} generator object +#' @field size character [optional] +#' @field color character [optional] +#' @field id integer [optional] +#' @field name character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter <- R6::R6Class( + "TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter", + public = list( + `size` = NULL, + `color` = NULL, + `id` = NULL, + `name` = NULL, + #' Initialize a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter class. + #' + #' @description + #' Initialize a new TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter class. + #' + #' @param size size + #' @param color color + #' @param id id + #' @param name name + #' @param ... Other optional arguments. + #' @export + initialize = function(`size` = NULL, `color` = NULL, `id` = NULL, `name` = NULL, ...) { + if (!is.null(`size`)) { + if (!(is.character(`size`) && length(`size`) == 1)) { + stop(paste("Error! Invalid data for `size`. Must be a string:", `size`)) + } + self$`size` <- `size` + } + if (!is.null(`color`)) { + if (!(is.character(`color`) && length(`color`) == 1)) { + stop(paste("Error! Invalid data for `color`. Must be a string:", `color`)) + } + self$`color` <- `color` + } + if (!is.null(`id`)) { + if (!(is.numeric(`id`) && length(`id`) == 1)) { + stop(paste("Error! Invalid data for `id`. Must be an integer:", `id`)) + } + self$`id` <- `id` + } + if (!is.null(`name`)) { + if (!(is.character(`name`) && length(`name`) == 1)) { + stop(paste("Error! Invalid data for `name`. Must be a string:", `name`)) + } + self$`name` <- `name` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format + #' @export + toJSON = function() { + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject <- list() + if (!is.null(self$`size`)) { + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["size"]] <- + self$`size` + } + if (!is.null(self$`color`)) { + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["color"]] <- + self$`color` + } + if (!is.null(self$`id`)) { + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["id"]] <- + self$`id` + } + if (!is.null(self$`name`)) { + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject[["name"]] <- + self$`name` + } + TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameterObject + }, + #' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' + #' @description + #' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' + #' @param input_json the JSON input + #' @return the instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`size`)) { + self$`size` <- this_object$`size` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + if (!is.null(this_object$`id`)) { + self$`id` <- this_object$`id` + } + if (!is.null(this_object$`name`)) { + self$`name` <- this_object$`name` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`size`)) { + sprintf( + '"size": + "%s" + ', + self$`size` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + }, + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`name`)) { + sprintf( + '"name": + "%s" + ', + self$`name` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' + #' @description + #' Deserialize JSON string into an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' + #' @param input_json the JSON input + #' @return the instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`size` <- this_object$`size` + self$`color` <- this_object$`color` + self$`id` <- this_object$`id` + self$`name` <- this_object$`name` + self + }, + #' Validate JSON input with respect to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' + #' @description + #' Validate JSON input with respect to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$unlock() +# +## Below is an example to define the print function +# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$lock() + diff --git a/samples/client/echo_api/r/R/test_query_style_form_explode_true_array_string_query_object_parameter.R b/samples/client/echo_api/r/R/test_query_style_form_explode_true_array_string_query_object_parameter.R new file mode 100644 index 00000000000..8bd1bc7c273 --- /dev/null +++ b/samples/client/echo_api/r/R/test_query_style_form_explode_true_array_string_query_object_parameter.R @@ -0,0 +1,162 @@ +#' Create a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter +#' +#' @description +#' TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter Class +#' +#' @docType class +#' @title TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter +#' @description TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter Class +#' @format An \code{R6Class} generator object +#' @field values list(character) [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter <- R6::R6Class( + "TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter", + public = list( + `values` = NULL, + #' Initialize a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter class. + #' + #' @description + #' Initialize a new TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter class. + #' + #' @param values values + #' @param ... Other optional arguments. + #' @export + initialize = function(`values` = NULL, ...) { + if (!is.null(`values`)) { + stopifnot(is.vector(`values`), length(`values`) != 0) + sapply(`values`, function(x) stopifnot(is.character(x))) + self$`values` <- `values` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format + #' @export + toJSON = function() { + TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject <- list() + if (!is.null(self$`values`)) { + TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject[["values"]] <- + self$`values` + } + TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameterObject + }, + #' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' + #' @description + #' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' + #' @param input_json the JSON input + #' @return the instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`values`)) { + self$`values` <- ApiClient$new()$deserializeObj(this_object$`values`, "array[character]", loadNamespace("openapi")) + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`values`)) { + sprintf( + '"values": + [%s] + ', + paste(unlist(lapply(self$`values`, function(x) paste0('"', x, '"'))), collapse = ",") + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' + #' @description + #' Deserialize JSON string into an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' + #' @param input_json the JSON input + #' @return the instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`values` <- ApiClient$new()$deserializeObj(this_object$`values`, "array[character]", loadNamespace("openapi")) + self + }, + #' Validate JSON input with respect to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' + #' @description + #' Validate JSON input with respect to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #' @export + toString = function() { + self$toJSONString() + }, + #' Return true if the values in all fields are valid. + #' + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + #' @export + isValid = function() { + TRUE + }, + #' Return a list of invalid fields (if any). + #' + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + #' @export + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + #' Print the object + #' + #' @description + #' Print the object + #' + #' @export + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$unlock() +# +## Below is an example to define the print function +# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$lock() + diff --git a/samples/client/echo_api/r/README.md b/samples/client/echo_api/r/README.md new file mode 100644 index 00000000000..19e750a47e5 --- /dev/null +++ b/samples/client/echo_api/r/README.md @@ -0,0 +1,130 @@ +# R API client for openapi + +Echo Server API + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 0.1.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.RClientCodegen + +## Installation + +### Prerequisites + +Install the dependencies + +```R +install.packages("jsonlite") +install.packages("httr") +install.packages("base64enc") +``` + +### Build the package + +```sh +git clone https://github.com/GIT_USER_ID/GIT_REPO_ID +cd GIT_REPO_ID +R CMD build . +R CMD check openapi_1.0.0.tar.gz --no-manual +R CMD INSTALL --preclean openapi_1.0.0.tar.gz +``` + +### Install the package + +```R +install.packages("openapi") +``` + +To install directly from Github, use `devtools`: +```R +install.packages("devtools") +library(devtools) +install_github("GIT_USER_ID/GIT_REPO_ID") +``` + +To install the package from a local file: +```R +install.packages("openapi_1.0.0.tar.gz", repos = NULL, type = "source") +``` + +### Usage + +```R +library(openapi) +``` + +### Reformat code + +To reformat code using [styler](https://styler.r-lib.org/index.html), please run the following in the R console: + +```R +install.packages("remotes") +remotes::install_github("r-lib/styler@v1.7.0.9003") +library("styler") +style_dir() +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:3000* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AuthApi* | [**TestAuthHttpBasic**](docs/AuthApi.md#TestAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication +*AuthApi* | [**TestAuthHttpBearer**](docs/AuthApi.md#TestAuthHttpBearer) | **POST** /auth/http/bearer | To test HTTP bearer authentication +*BodyApi* | [**TestBinaryGif**](docs/BodyApi.md#TestBinaryGif) | **POST** /binary/gif | Test binary (gif) response body +*BodyApi* | [**TestBodyApplicationOctetstreamBinary**](docs/BodyApi.md#TestBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) +*BodyApi* | [**TestBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#TestBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**TestBodyMultipartFormdataSingleBinary**](docs/BodyApi.md#TestBodyMultipartFormdataSingleBinary) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime +*BodyApi* | [**TestEchoBodyAllOfPet**](docs/BodyApi.md#TestEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) +*BodyApi* | [**TestEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#TestEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object +*BodyApi* | [**TestEchoBodyPet**](docs/BodyApi.md#TestEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) +*BodyApi* | [**TestEchoBodyPetResponseString**](docs/BodyApi.md#TestEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body +*BodyApi* | [**TestEchoBodyTagResponseString**](docs/BodyApi.md#TestEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) +*FormApi* | [**TestFormIntegerBooleanString**](docs/FormApi.md#TestFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**TestFormOneof**](docs/FormApi.md#TestFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema +*HeaderApi* | [**TestHeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#TestHeaderIntegerBooleanStringEnums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) +*PathApi* | [**TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](docs/PathApi.md#TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) +*QueryApi* | [**TestEnumRefString**](docs/QueryApi.md#TestEnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) +*QueryApi* | [**TestQueryDatetimeDateString**](docs/QueryApi.md#TestQueryDatetimeDateString) | **GET** /query/datetime/date/string | Test query parameter(s) +*QueryApi* | [**TestQueryIntegerBooleanString**](docs/QueryApi.md#TestQueryIntegerBooleanString) | **GET** /query/integer/boolean/string | Test query parameter(s) +*QueryApi* | [**TestQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#TestQueryStyleDeepObjectExplodeTrueObject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s) +*QueryApi* | [**TestQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#TestQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) +*QueryApi* | [**TestQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#TestQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) +*QueryApi* | [**TestQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#TestQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +*QueryApi* | [**TestQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#TestQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) + + +## Documentation for Models + + - [Bird](docs/Bird.md) + - [Category](docs/Category.md) + - [DataQuery](docs/DataQuery.md) + - [DefaultValue](docs/DefaultValue.md) + - [NumberPropertiesOnly](docs/NumberPropertiesOnly.md) + - [Pet](docs/Pet.md) + - [Query](docs/Query.md) + - [StringEnumRef](docs/StringEnumRef.md) + - [Tag](docs/Tag.md) + - [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md) + - [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) + + +## Documentation for Authorization + + +Authentication schemes defined for the API: +### http_auth + +- **Type**: HTTP basic authentication + +### http_bearer_auth + +- **Type**: Bearer authentication + + +## Author + +team@openapitools.org diff --git a/samples/client/echo_api/r/build_and_test.bash b/samples/client/echo_api/r/build_and_test.bash new file mode 100644 index 00000000000..730dd53024a --- /dev/null +++ b/samples/client/echo_api/r/build_and_test.bash @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +REPO=https://cloud.r-project.org + +export R_LIBS_USER=$HOME/R + +echo "R lib directory: $R_LIBS_USER" + +mkdir $R_LIBS_USER || true + +#Rscript -e "install.packages('jsonlite', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('httr', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('testthat', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('R6', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('base64enc', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('rlang', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('rjson', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('devtools', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('stringr', repos='$REPO', lib='$R_LIBS_USER')" +#Rscript -e "install.packages('lifecycle', repos='$REPO', lib='$R_LIBS_USER')" +# +R CMD build . +R CMD check *tar.gz --no-manual +R CMD install --preclean *tar.gz diff --git a/samples/client/echo_api/r/docs/AuthApi.md b/samples/client/echo_api/r/docs/AuthApi.md new file mode 100644 index 00000000000..cdc718d0148 --- /dev/null +++ b/samples/client/echo_api/r/docs/AuthApi.md @@ -0,0 +1,99 @@ +# AuthApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestAuthHttpBasic**](AuthApi.md#TestAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication +[**TestAuthHttpBearer**](AuthApi.md#TestAuthHttpBearer) | **POST** /auth/http/bearer | To test HTTP bearer authentication + + +# **TestAuthHttpBasic** +> character TestAuthHttpBasic() + +To test HTTP basic authentication + +To test HTTP basic authentication + +### Example +```R +library(openapi) + +# To test HTTP basic authentication +# + +api_instance <- AuthApi$new() +# Configure HTTP basic authorization: http_auth +api_instance$api_client$username <- Sys.getenv("USERNAME") +api_instance$api_client$password <- Sys.getenv("PASSWORD") +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestAuthHttpBasic(data_file = "result.txt") +result <- api_instance$TestAuthHttpBasic() +dput(result) +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**character** + +### Authorization + +[http_auth](../README.md#http_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestAuthHttpBearer** +> character TestAuthHttpBearer() + +To test HTTP bearer authentication + +To test HTTP bearer authentication + +### Example +```R +library(openapi) + +# To test HTTP bearer authentication +# + +api_instance <- AuthApi$new() +# Configure HTTP bearer authorization: http_bearer_auth +api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN") +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestAuthHttpBearer(data_file = "result.txt") +result <- api_instance$TestAuthHttpBearer() +dput(result) +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**character** + +### Authorization + +[http_bearer_auth](../README.md#http_bearer_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/Bird.md b/samples/client/echo_api/r/docs/Bird.md new file mode 100644 index 00000000000..9375f8d80e2 --- /dev/null +++ b/samples/client/echo_api/r/docs/Bird.md @@ -0,0 +1,10 @@ +# openapi::Bird + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **character** | | [optional] +**color** | **character** | | [optional] + + diff --git a/samples/client/echo_api/r/docs/BodyApi.md b/samples/client/echo_api/r/docs/BodyApi.md new file mode 100644 index 00000000000..9d631b65ce8 --- /dev/null +++ b/samples/client/echo_api/r/docs/BodyApi.md @@ -0,0 +1,435 @@ +# BodyApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestBinaryGif**](BodyApi.md#TestBinaryGif) | **POST** /binary/gif | Test binary (gif) response body +[**TestBodyApplicationOctetstreamBinary**](BodyApi.md#TestBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) +[**TestBodyMultipartFormdataArrayOfBinary**](BodyApi.md#TestBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**TestBodyMultipartFormdataSingleBinary**](BodyApi.md#TestBodyMultipartFormdataSingleBinary) | **POST** /body/application/octetstream/single_binary | Test single binary in multipart mime +[**TestEchoBodyAllOfPet**](BodyApi.md#TestEchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) +[**TestEchoBodyFreeFormObjectResponseString**](BodyApi.md#TestEchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object +[**TestEchoBodyPet**](BodyApi.md#TestEchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) +[**TestEchoBodyPetResponseString**](BodyApi.md#TestEchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body +[**TestEchoBodyTagResponseString**](BodyApi.md#TestEchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) + + +# **TestBinaryGif** +> data.frame TestBinaryGif() + +Test binary (gif) response body + +Test binary (gif) response body + +### Example +```R +library(openapi) + +# Test binary (gif) response body +# + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestBinaryGif(data_file = "result.txt") +result <- api_instance$TestBinaryGif() +dput(result) +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**data.frame** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: image/gif + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestBodyApplicationOctetstreamBinary** +> character TestBodyApplicationOctetstreamBinary(body = var.body) + +Test body parameter(s) + +Test body parameter(s) + +### Example +```R +library(openapi) + +# Test body parameter(s) +# +# prepare function argument(s) +var_body <- File.new('/path/to/file') # data.frame | (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestBodyApplicationOctetstreamBinary(body = var_bodydata_file = "result.txt") +result <- api_instance$TestBodyApplicationOctetstreamBinary(body = var_body) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **data.frame**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/octet-stream + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestBodyMultipartFormdataArrayOfBinary** +> character TestBodyMultipartFormdataArrayOfBinary(files) + +Test array of binary in multipart mime + +Test array of binary in multipart mime + +### Example +```R +library(openapi) + +# Test array of binary in multipart mime +# +# prepare function argument(s) +var_files <- c(123) # array[data.frame] | + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestBodyMultipartFormdataArrayOfBinary(var_filesdata_file = "result.txt") +result <- api_instance$TestBodyMultipartFormdataArrayOfBinary(var_files) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **files** | list( **data.frame** )| | + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestBodyMultipartFormdataSingleBinary** +> character TestBodyMultipartFormdataSingleBinary(my_file = var.my_file) + +Test single binary in multipart mime + +Test single binary in multipart mime + +### Example +```R +library(openapi) + +# Test single binary in multipart mime +# +# prepare function argument(s) +var_my_file <- File.new('/path/to/file') # data.frame | (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestBodyMultipartFormdataSingleBinary(my_file = var_my_filedata_file = "result.txt") +result <- api_instance$TestBodyMultipartFormdataSingleBinary(my_file = var_my_file) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **my_file** | **data.frame**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestEchoBodyAllOfPet** +> Pet TestEchoBodyAllOfPet(pet = var.pet) + +Test body parameter(s) + +Test body parameter(s) + +### Example +```R +library(openapi) + +# Test body parameter(s) +# +# prepare function argument(s) +var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEchoBodyAllOfPet(pet = var_petdata_file = "result.txt") +result <- api_instance$TestEchoBodyAllOfPet(pet = var_pet) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestEchoBodyFreeFormObjectResponseString** +> character TestEchoBodyFreeFormObjectResponseString(body = var.body) + +Test free form object + +Test free form object + +### Example +```R +library(openapi) + +# Test free form object +# +# prepare function argument(s) +var_body <- c(key = TODO) # object | Free form object (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEchoBodyFreeFormObjectResponseString(body = var_bodydata_file = "result.txt") +result <- api_instance$TestEchoBodyFreeFormObjectResponseString(body = var_body) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **object**| Free form object | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestEchoBodyPet** +> Pet TestEchoBodyPet(pet = var.pet) + +Test body parameter(s) + +Test body parameter(s) + +### Example +```R +library(openapi) + +# Test body parameter(s) +# +# prepare function argument(s) +var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEchoBodyPet(pet = var_petdata_file = "result.txt") +result <- api_instance$TestEchoBodyPet(pet = var_pet) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestEchoBodyPetResponseString** +> character TestEchoBodyPetResponseString(pet = var.pet) + +Test empty response body + +Test empty response body + +### Example +```R +library(openapi) + +# Test empty response body +# +# prepare function argument(s) +var_pet <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEchoBodyPetResponseString(pet = var_petdata_file = "result.txt") +result <- api_instance$TestEchoBodyPetResponseString(pet = var_pet) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestEchoBodyTagResponseString** +> character TestEchoBodyTagResponseString(tag = var.tag) + +Test empty json (request body) + +Test empty json (request body) + +### Example +```R +library(openapi) + +# Test empty json (request body) +# +# prepare function argument(s) +var_tag <- Tag$new(123, "name_example") # Tag | Tag object (Optional) + +api_instance <- BodyApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEchoBodyTagResponseString(tag = var_tagdata_file = "result.txt") +result <- api_instance$TestEchoBodyTagResponseString(tag = var_tag) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tag** | [**Tag**](Tag.md)| Tag object | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/Category.md b/samples/client/echo_api/r/docs/Category.md new file mode 100644 index 00000000000..d28e076fe64 --- /dev/null +++ b/samples/client/echo_api/r/docs/Category.md @@ -0,0 +1,10 @@ +# openapi::Category + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] + + diff --git a/samples/client/echo_api/r/docs/DataQuery.md b/samples/client/echo_api/r/docs/DataQuery.md new file mode 100644 index 00000000000..097f1885fe5 --- /dev/null +++ b/samples/client/echo_api/r/docs/DataQuery.md @@ -0,0 +1,13 @@ +# openapi::DataQuery + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | Query | [optional] +**outcomes** | **array[character]** | | [optional] [default to [SUCCESS, FAILURE]] [Enum: ] +**suffix** | **character** | test suffix | [optional] +**text** | **character** | Some text containing white spaces | [optional] +**date** | **character** | A date | [optional] + + diff --git a/samples/client/echo_api/r/docs/DefaultValue.md b/samples/client/echo_api/r/docs/DefaultValue.md new file mode 100644 index 00000000000..74b381be8db --- /dev/null +++ b/samples/client/echo_api/r/docs/DefaultValue.md @@ -0,0 +1,17 @@ +# openapi::DefaultValue + +to test the default value of properties + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_string_enum_ref_default** | [**array[StringEnumRef]**](StringEnumRef.md) | | [optional] [default to ["success","failure"]] +**array_string_enum_default** | **array[character]** | | [optional] [default to ["success","failure"]] [Enum: ] +**array_string_default** | **array[character]** | | [optional] [default to ["failure","skipped"]] +**array_integer_default** | **array[integer]** | | [optional] [default to [1,3]] +**array_string** | **array[character]** | | [optional] +**array_string_nullable** | **array[character]** | | [optional] +**array_string_extension_nullable** | **array[character]** | | [optional] +**string_nullable** | **character** | | [optional] + + diff --git a/samples/client/echo_api/r/docs/FormApi.md b/samples/client/echo_api/r/docs/FormApi.md new file mode 100644 index 00000000000..b444d98794f --- /dev/null +++ b/samples/client/echo_api/r/docs/FormApi.md @@ -0,0 +1,118 @@ +# FormApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestFormIntegerBooleanString**](FormApi.md#TestFormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +[**TestFormOneof**](FormApi.md#TestFormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema + + +# **TestFormIntegerBooleanString** +> character TestFormIntegerBooleanString(integer_form = var.integer_form, boolean_form = var.boolean_form, string_form = var.string_form) + +Test form parameter(s) + +Test form parameter(s) + +### Example +```R +library(openapi) + +# Test form parameter(s) +# +# prepare function argument(s) +var_integer_form <- 56 # integer | (Optional) +var_boolean_form <- "boolean_form_example" # character | (Optional) +var_string_form <- "string_form_example" # character | (Optional) + +api_instance <- FormApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_formdata_file = "result.txt") +result <- api_instance$TestFormIntegerBooleanString(integer_form = var_integer_form, boolean_form = var_boolean_form, string_form = var_string_form) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integer_form** | **integer**| | [optional] + **boolean_form** | **character**| | [optional] + **string_form** | **character**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestFormOneof** +> character TestFormOneof(form1 = var.form1, form2 = var.form2, form3 = var.form3, form4 = var.form4, id = var.id, name = var.name) + +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### Example +```R +library(openapi) + +# Test form parameter(s) for oneOf schema +# +# prepare function argument(s) +var_form1 <- "form1_example" # character | (Optional) +var_form2 <- 56 # integer | (Optional) +var_form3 <- "form3_example" # character | (Optional) +var_form4 <- "form4_example" # character | (Optional) +var_id <- 56 # integer | (Optional) +var_name <- "name_example" # character | (Optional) + +api_instance <- FormApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_namedata_file = "result.txt") +result <- api_instance$TestFormOneof(form1 = var_form1, form2 = var_form2, form3 = var_form3, form4 = var_form4, id = var_id, name = var_name) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **form1** | **character**| | [optional] + **form2** | **integer**| | [optional] + **form3** | **character**| | [optional] + **form4** | **character**| | [optional] + **id** | **integer**| | [optional] + **name** | **character**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/HeaderApi.md b/samples/client/echo_api/r/docs/HeaderApi.md new file mode 100644 index 00000000000..c776aeb0722 --- /dev/null +++ b/samples/client/echo_api/r/docs/HeaderApi.md @@ -0,0 +1,64 @@ +# HeaderApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestHeaderIntegerBooleanStringEnums**](HeaderApi.md#TestHeaderIntegerBooleanStringEnums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) + + +# **TestHeaderIntegerBooleanStringEnums** +> character TestHeaderIntegerBooleanStringEnums(integer_header = var.integer_header, boolean_header = var.boolean_header, string_header = var.string_header, enum_nonref_string_header = var.enum_nonref_string_header, enum_ref_string_header = var.enum_ref_string_header) + +Test header parameter(s) + +Test header parameter(s) + +### Example +```R +library(openapi) + +# Test header parameter(s) +# +# prepare function argument(s) +var_integer_header <- 56 # integer | (Optional) +var_boolean_header <- "boolean_header_example" # character | (Optional) +var_string_header <- "string_header_example" # character | (Optional) +var_enum_nonref_string_header <- "enum_nonref_string_header_example" # character | (Optional) +var_enum_ref_string_header <- StringEnumRef$new() # StringEnumRef | (Optional) + +api_instance <- HeaderApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_headerdata_file = "result.txt") +result <- api_instance$TestHeaderIntegerBooleanStringEnums(integer_header = var_integer_header, boolean_header = var_boolean_header, string_header = var_string_header, enum_nonref_string_header = var_enum_nonref_string_header, enum_ref_string_header = var_enum_ref_string_header) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integer_header** | **integer**| | [optional] + **boolean_header** | **character**| | [optional] + **string_header** | **character**| | [optional] + **enum_nonref_string_header** | Enum [success, failure, unclassified] | | [optional] + **enum_ref_string_header** | [**StringEnumRef**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/NumberPropertiesOnly.md b/samples/client/echo_api/r/docs/NumberPropertiesOnly.md new file mode 100644 index 00000000000..5491ac6bee1 --- /dev/null +++ b/samples/client/echo_api/r/docs/NumberPropertiesOnly.md @@ -0,0 +1,11 @@ +# openapi::NumberPropertiesOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**number** | **numeric** | | [optional] +**float** | **numeric** | | [optional] +**double** | **numeric** | | [optional] [Max: 50.2] [Min: 0.8] + + diff --git a/samples/client/echo_api/r/docs/PathApi.md b/samples/client/echo_api/r/docs/PathApi.md new file mode 100644 index 00000000000..ee464705629 --- /dev/null +++ b/samples/client/echo_api/r/docs/PathApi.md @@ -0,0 +1,62 @@ +# PathApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](PathApi.md#TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) + + +# **TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath** +> character TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path) + +Test path parameter(s) + +Test path parameter(s) + +### Example +```R +library(openapi) + +# Test path parameter(s) +# +# prepare function argument(s) +var_path_string <- "path_string_example" # character | +var_path_integer <- 56 # integer | +var_enum_nonref_string_path <- "enum_nonref_string_path_example" # character | +var_enum_ref_string_path <- StringEnumRef$new() # StringEnumRef | + +api_instance <- PathApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_pathdata_file = "result.txt") +result <- api_instance$TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(var_path_string, var_path_integer, var_enum_nonref_string_path, var_enum_ref_string_path) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **path_string** | **character**| | + **path_integer** | **integer**| | + **enum_nonref_string_path** | Enum [success, failure, unclassified] | | + **enum_ref_string_path** | [**StringEnumRef**](.md)| | + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/Pet.md b/samples/client/echo_api/r/docs/Pet.md new file mode 100644 index 00000000000..72ff45a9558 --- /dev/null +++ b/samples/client/echo_api/r/docs/Pet.md @@ -0,0 +1,14 @@ +# openapi::Pet + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | +**category** | [**Category**](Category.md) | | [optional] +**photoUrls** | **array[character]** | | +**tags** | [**array[Tag]**](Tag.md) | | [optional] +**status** | **character** | pet status in the store | [optional] [Enum: [available, pending, sold]] + + diff --git a/samples/client/echo_api/r/docs/Query.md b/samples/client/echo_api/r/docs/Query.md new file mode 100644 index 00000000000..6775cd084b8 --- /dev/null +++ b/samples/client/echo_api/r/docs/Query.md @@ -0,0 +1,10 @@ +# openapi::Query + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | Query | [optional] +**outcomes** | **array[character]** | | [optional] [default to ["SUCCESS","FAILURE"]] [Enum: ] + + diff --git a/samples/client/echo_api/r/docs/QueryApi.md b/samples/client/echo_api/r/docs/QueryApi.md new file mode 100644 index 00000000000..fda052d2b81 --- /dev/null +++ b/samples/client/echo_api/r/docs/QueryApi.md @@ -0,0 +1,402 @@ +# QueryApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**TestEnumRefString**](QueryApi.md#TestEnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) +[**TestQueryDatetimeDateString**](QueryApi.md#TestQueryDatetimeDateString) | **GET** /query/datetime/date/string | Test query parameter(s) +[**TestQueryIntegerBooleanString**](QueryApi.md#TestQueryIntegerBooleanString) | **GET** /query/integer/boolean/string | Test query parameter(s) +[**TestQueryStyleDeepObjectExplodeTrueObject**](QueryApi.md#TestQueryStyleDeepObjectExplodeTrueObject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s) +[**TestQueryStyleDeepObjectExplodeTrueObjectAllOf**](QueryApi.md#TestQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) +[**TestQueryStyleFormExplodeTrueArrayString**](QueryApi.md#TestQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) +[**TestQueryStyleFormExplodeTrueObject**](QueryApi.md#TestQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +[**TestQueryStyleFormExplodeTrueObjectAllOf**](QueryApi.md#TestQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) + + +# **TestEnumRefString** +> character TestEnumRefString(enum_nonref_string_query = var.enum_nonref_string_query, enum_ref_string_query = var.enum_ref_string_query) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_enum_nonref_string_query <- "enum_nonref_string_query_example" # character | (Optional) +var_enum_ref_string_query <- StringEnumRef$new() # StringEnumRef | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestEnumRefString(enum_nonref_string_query = var_enum_nonref_string_query, enum_ref_string_query = var_enum_ref_string_querydata_file = "result.txt") +result <- api_instance$TestEnumRefString(enum_nonref_string_query = var_enum_nonref_string_query, enum_ref_string_query = var_enum_ref_string_query) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_nonref_string_query** | Enum [success, failure, unclassified] | | [optional] + **enum_ref_string_query** | [**StringEnumRef**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryDatetimeDateString** +> character TestQueryDatetimeDateString(datetime_query = var.datetime_query, date_query = var.date_query, string_query = var.string_query) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_datetime_query <- "datetime_query_example" # character | (Optional) +var_date_query <- "date_query_example" # character | (Optional) +var_string_query <- "string_query_example" # character | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryDatetimeDateString(datetime_query = var_datetime_query, date_query = var_date_query, string_query = var_string_querydata_file = "result.txt") +result <- api_instance$TestQueryDatetimeDateString(datetime_query = var_datetime_query, date_query = var_date_query, string_query = var_string_query) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **datetime_query** | **character**| | [optional] + **date_query** | **character**| | [optional] + **string_query** | **character**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryIntegerBooleanString** +> character TestQueryIntegerBooleanString(integer_query = var.integer_query, boolean_query = var.boolean_query, string_query = var.string_query) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_integer_query <- 56 # integer | (Optional) +var_boolean_query <- "boolean_query_example" # character | (Optional) +var_string_query <- "string_query_example" # character | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryIntegerBooleanString(integer_query = var_integer_query, boolean_query = var_boolean_query, string_query = var_string_querydata_file = "result.txt") +result <- api_instance$TestQueryIntegerBooleanString(integer_query = var_integer_query, boolean_query = var_boolean_query, string_query = var_string_query) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **integer_query** | **integer**| | [optional] + **boolean_query** | **character**| | [optional] + **string_query** | **character**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryStyleDeepObjectExplodeTrueObject** +> character TestQueryStyleDeepObjectExplodeTrueObject(query_object = var.query_object) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_query_object <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObject(query_object = var_query_objectdata_file = "result.txt") +result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObject(query_object = var_query_object) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_object** | [**Pet**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryStyleDeepObjectExplodeTrueObjectAllOf** +> character TestQueryStyleDeepObjectExplodeTrueObjectAllOf(query_object = var.query_object) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_query_object <- test_query_style_deepObject_explode_true_object_allOf_query_object_parameter$new("size_example", "color_example", 123, "name_example") # TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObjectAllOf(query_object = var_query_objectdata_file = "result.txt") +result <- api_instance$TestQueryStyleDeepObjectExplodeTrueObjectAllOf(query_object = var_query_object) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_object** | [**TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryStyleFormExplodeTrueArrayString** +> character TestQueryStyleFormExplodeTrueArrayString(query_object = var.query_object) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_query_object <- test_query_style_form_explode_true_array_string_query_object_parameter$new(c("values_example")) # TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryStyleFormExplodeTrueArrayString(query_object = var_query_objectdata_file = "result.txt") +result <- api_instance$TestQueryStyleFormExplodeTrueArrayString(query_object = var_query_object) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_object** | [**TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryStyleFormExplodeTrueObject** +> character TestQueryStyleFormExplodeTrueObject(query_object = var.query_object) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_query_object <- Pet$new("name_example", c("photoUrls_example"), 123, Category$new(123, "name_example"), c(Tag$new(123, "name_example")), "available") # Pet | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryStyleFormExplodeTrueObject(query_object = var_query_objectdata_file = "result.txt") +result <- api_instance$TestQueryStyleFormExplodeTrueObject(query_object = var_query_object) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_object** | [**Pet**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +# **TestQueryStyleFormExplodeTrueObjectAllOf** +> character TestQueryStyleFormExplodeTrueObjectAllOf(query_object = var.query_object) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```R +library(openapi) + +# Test query parameter(s) +# +# prepare function argument(s) +var_query_object <- DataQuery$new(123, c("SUCCESS"), "suffix_example", "text_example", "date_example") # DataQuery | (Optional) + +api_instance <- QueryApi$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$TestQueryStyleFormExplodeTrueObjectAllOf(query_object = var_query_objectdata_file = "result.txt") +result <- api_instance$TestQueryStyleFormExplodeTrueObjectAllOf(query_object = var_query_object) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query_object** | [**DataQuery**](.md)| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/r/docs/StringEnumRef.md b/samples/client/echo_api/r/docs/StringEnumRef.md new file mode 100644 index 00000000000..fe51f973312 --- /dev/null +++ b/samples/client/echo_api/r/docs/StringEnumRef.md @@ -0,0 +1,8 @@ +# openapi::StringEnumRef + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/client/echo_api/r/docs/Tag.md b/samples/client/echo_api/r/docs/Tag.md new file mode 100644 index 00000000000..85e1b2b9cdb --- /dev/null +++ b/samples/client/echo_api/r/docs/Tag.md @@ -0,0 +1,10 @@ +# openapi::Tag + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] + + diff --git a/samples/client/echo_api/r/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md b/samples/client/echo_api/r/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md new file mode 100644 index 00000000000..32a7afb3630 --- /dev/null +++ b/samples/client/echo_api/r/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -0,0 +1,12 @@ +# openapi::TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **character** | | [optional] +**color** | **character** | | [optional] +**id** | **integer** | | [optional] +**name** | **character** | | [optional] + + diff --git a/samples/client/echo_api/r/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md b/samples/client/echo_api/r/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md new file mode 100644 index 00000000000..80ec524758b --- /dev/null +++ b/samples/client/echo_api/r/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md @@ -0,0 +1,9 @@ +# openapi::TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**values** | **array[character]** | | [optional] + + diff --git a/samples/client/echo_api/r/git_push.sh b/samples/client/echo_api/r/git_push.sh new file mode 100644 index 00000000000..f53a75d4fab --- /dev/null +++ b/samples/client/echo_api/r/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/echo_api/r/tests/testthat.R b/samples/client/echo_api/r/tests/testthat.R new file mode 100644 index 00000000000..b343a743aa8 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(openapi) + +test_check("openapi") diff --git a/samples/client/echo_api/r/tests/testthat/test_auth_api.R b/samples/client/echo_api/r/tests/testthat/test_auth_api.R new file mode 100644 index 00000000000..c46f0a50809 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_auth_api.R @@ -0,0 +1,28 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test AuthApi") + +api_instance <- AuthApi$new() + +test_that("TestAuthHttpBasic", { + # tests for TestAuthHttpBasic + # base path: http://localhost:3000 + # To test HTTP basic authentication + # To test HTTP basic authentication + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestAuthHttpBearer", { + # tests for TestAuthHttpBearer + # base path: http://localhost:3000 + # To test HTTP bearer authentication + # To test HTTP bearer authentication + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_bird.R b/samples/client/echo_api/r/tests/testthat/test_bird.R new file mode 100644 index 00000000000..445fe63a4a7 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_bird.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Bird") + +model_instance <- Bird$new() + +test_that("size", { + # tests for the property `size` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) + +test_that("color", { + # tests for the property `color` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`color`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_body_api.R b/samples/client/echo_api/r/tests/testthat/test_body_api.R new file mode 100644 index 00000000000..ff54935492f --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_body_api.R @@ -0,0 +1,113 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test BodyApi") + +api_instance <- BodyApi$new() + +test_that("TestBinaryGif", { + # tests for TestBinaryGif + # base path: http://localhost:3000 + # Test binary (gif) response body + # Test binary (gif) response body + # @return [data.frame] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestBodyApplicationOctetstreamBinary", { + # tests for TestBodyApplicationOctetstreamBinary + # base path: http://localhost:3000 + # Test body parameter(s) + # Test body parameter(s) + # @param body data.frame (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestBodyMultipartFormdataArrayOfBinary", { + # tests for TestBodyMultipartFormdataArrayOfBinary + # base path: http://localhost:3000 + # Test array of binary in multipart mime + # Test array of binary in multipart mime + # @param files array[data.frame] + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestBodyMultipartFormdataSingleBinary", { + # tests for TestBodyMultipartFormdataSingleBinary + # base path: http://localhost:3000 + # Test single binary in multipart mime + # Test single binary in multipart mime + # @param my_file data.frame (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestEchoBodyAllOfPet", { + # tests for TestEchoBodyAllOfPet + # base path: http://localhost:3000 + # Test body parameter(s) + # Test body parameter(s) + # @param pet Pet Pet object that needs to be added to the store (optional) + # @return [Pet] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestEchoBodyFreeFormObjectResponseString", { + # tests for TestEchoBodyFreeFormObjectResponseString + # base path: http://localhost:3000 + # Test free form object + # Test free form object + # @param body object Free form object (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestEchoBodyPet", { + # tests for TestEchoBodyPet + # base path: http://localhost:3000 + # Test body parameter(s) + # Test body parameter(s) + # @param pet Pet Pet object that needs to be added to the store (optional) + # @return [Pet] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestEchoBodyPetResponseString", { + # tests for TestEchoBodyPetResponseString + # base path: http://localhost:3000 + # Test empty response body + # Test empty response body + # @param pet Pet Pet object that needs to be added to the store (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestEchoBodyTagResponseString", { + # tests for TestEchoBodyTagResponseString + # base path: http://localhost:3000 + # Test empty json (request body) + # Test empty json (request body) + # @param tag Tag Tag object (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_category.R b/samples/client/echo_api/r/tests/testthat/test_category.R new file mode 100644 index 00000000000..df2725e9cef --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_category.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Category") + +model_instance <- Category$new() + +test_that("id", { + # tests for the property `id` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("name", { + # tests for the property `name` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`name`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_data_query.R b/samples/client/echo_api/r/tests/testthat/test_data_query.R new file mode 100644 index 00000000000..402d4fd0aca --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_data_query.R @@ -0,0 +1,45 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test DataQuery") + +model_instance <- DataQuery$new() + +test_that("id", { + # tests for the property `id` (integer) + # Query + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("outcomes", { + # tests for the property `outcomes` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`outcomes`, "EXPECTED_RESULT") +}) + +test_that("suffix", { + # tests for the property `suffix` (character) + # test suffix + + # uncomment below to test the property + #expect_equal(model.instance$`suffix`, "EXPECTED_RESULT") +}) + +test_that("text", { + # tests for the property `text` (character) + # Some text containing white spaces + + # uncomment below to test the property + #expect_equal(model.instance$`text`, "EXPECTED_RESULT") +}) + +test_that("date", { + # tests for the property `date` (character) + # A date + + # uncomment below to test the property + #expect_equal(model.instance$`date`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_default_value.R b/samples/client/echo_api/r/tests/testthat/test_default_value.R new file mode 100644 index 00000000000..93d86ed67f9 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_default_value.R @@ -0,0 +1,62 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test DefaultValue") + +model_instance <- DefaultValue$new() + +test_that("array_string_enum_ref_default", { + # tests for the property `array_string_enum_ref_default` (array[StringEnumRef]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string_enum_ref_default`, "EXPECTED_RESULT") +}) + +test_that("array_string_enum_default", { + # tests for the property `array_string_enum_default` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string_enum_default`, "EXPECTED_RESULT") +}) + +test_that("array_string_default", { + # tests for the property `array_string_default` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string_default`, "EXPECTED_RESULT") +}) + +test_that("array_integer_default", { + # tests for the property `array_integer_default` (array[integer]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_integer_default`, "EXPECTED_RESULT") +}) + +test_that("array_string", { + # tests for the property `array_string` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string`, "EXPECTED_RESULT") +}) + +test_that("array_string_nullable", { + # tests for the property `array_string_nullable` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string_nullable`, "EXPECTED_RESULT") +}) + +test_that("array_string_extension_nullable", { + # tests for the property `array_string_extension_nullable` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`array_string_extension_nullable`, "EXPECTED_RESULT") +}) + +test_that("string_nullable", { + # tests for the property `string_nullable` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`string_nullable`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_form_api.R b/samples/client/echo_api/r/tests/testthat/test_form_api.R new file mode 100644 index 00000000000..a2b306f2d8d --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_form_api.R @@ -0,0 +1,37 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test FormApi") + +api_instance <- FormApi$new() + +test_that("TestFormIntegerBooleanString", { + # tests for TestFormIntegerBooleanString + # base path: http://localhost:3000 + # Test form parameter(s) + # Test form parameter(s) + # @param integer_form integer (optional) + # @param boolean_form character (optional) + # @param string_form character (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestFormOneof", { + # tests for TestFormOneof + # base path: http://localhost:3000 + # Test form parameter(s) for oneOf schema + # Test form parameter(s) for oneOf schema + # @param form1 character (optional) + # @param form2 integer (optional) + # @param form3 character (optional) + # @param form4 character (optional) + # @param id integer (optional) + # @param name character (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_header_api.R b/samples/client/echo_api/r/tests/testthat/test_header_api.R new file mode 100644 index 00000000000..a74f92ef09c --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_header_api.R @@ -0,0 +1,22 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test HeaderApi") + +api_instance <- HeaderApi$new() + +test_that("TestHeaderIntegerBooleanStringEnums", { + # tests for TestHeaderIntegerBooleanStringEnums + # base path: http://localhost:3000 + # Test header parameter(s) + # Test header parameter(s) + # @param integer_header integer (optional) + # @param boolean_header character (optional) + # @param string_header character (optional) + # @param enum_nonref_string_header character (optional) + # @param enum_ref_string_header StringEnumRef (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_number_properties_only.R b/samples/client/echo_api/r/tests/testthat/test_number_properties_only.R new file mode 100644 index 00000000000..fa81dfd408a --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_number_properties_only.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test NumberPropertiesOnly") + +model_instance <- NumberPropertiesOnly$new() + +test_that("number", { + # tests for the property `number` (numeric) + + # uncomment below to test the property + #expect_equal(model.instance$`number`, "EXPECTED_RESULT") +}) + +test_that("float", { + # tests for the property `float` (numeric) + + # uncomment below to test the property + #expect_equal(model.instance$`float`, "EXPECTED_RESULT") +}) + +test_that("double", { + # tests for the property `double` (numeric) + + # uncomment below to test the property + #expect_equal(model.instance$`double`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_path_api.R b/samples/client/echo_api/r/tests/testthat/test_path_api.R new file mode 100644 index 00000000000..25b9c2499e9 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_path_api.R @@ -0,0 +1,21 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test PathApi") + +api_instance <- PathApi$new() + +test_that("TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath", { + # tests for TestsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath + # base path: http://localhost:3000 + # Test path parameter(s) + # Test path parameter(s) + # @param path_string character + # @param path_integer integer + # @param enum_nonref_string_path character + # @param enum_ref_string_path StringEnumRef + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_pet.R b/samples/client/echo_api/r/tests/testthat/test_pet.R new file mode 100644 index 00000000000..46ac351df85 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_pet.R @@ -0,0 +1,49 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Pet") + +model_instance <- Pet$new() + +test_that("id", { + # tests for the property `id` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("name", { + # tests for the property `name` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`name`, "EXPECTED_RESULT") +}) + +test_that("category", { + # tests for the property `category` (Category) + + # uncomment below to test the property + #expect_equal(model.instance$`category`, "EXPECTED_RESULT") +}) + +test_that("photoUrls", { + # tests for the property `photoUrls` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`photoUrls`, "EXPECTED_RESULT") +}) + +test_that("tags", { + # tests for the property `tags` (array[Tag]) + + # uncomment below to test the property + #expect_equal(model.instance$`tags`, "EXPECTED_RESULT") +}) + +test_that("status", { + # tests for the property `status` (character) + # pet status in the store + + # uncomment below to test the property + #expect_equal(model.instance$`status`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_query.R b/samples/client/echo_api/r/tests/testthat/test_query.R new file mode 100644 index 00000000000..ab164dbbf41 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_query.R @@ -0,0 +1,21 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Query") + +model_instance <- Query$new() + +test_that("id", { + # tests for the property `id` (integer) + # Query + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("outcomes", { + # tests for the property `outcomes` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`outcomes`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_query_api.R b/samples/client/echo_api/r/tests/testthat/test_query_api.R new file mode 100644 index 00000000000..202460c859a --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_query_api.R @@ -0,0 +1,107 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test QueryApi") + +api_instance <- QueryApi$new() + +test_that("TestEnumRefString", { + # tests for TestEnumRefString + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param enum_nonref_string_query character (optional) + # @param enum_ref_string_query StringEnumRef (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryDatetimeDateString", { + # tests for TestQueryDatetimeDateString + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param datetime_query character (optional) + # @param date_query character (optional) + # @param string_query character (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryIntegerBooleanString", { + # tests for TestQueryIntegerBooleanString + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param integer_query integer (optional) + # @param boolean_query character (optional) + # @param string_query character (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryStyleDeepObjectExplodeTrueObject", { + # tests for TestQueryStyleDeepObjectExplodeTrueObject + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param query_object Pet (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryStyleDeepObjectExplodeTrueObjectAllOf", { + # tests for TestQueryStyleDeepObjectExplodeTrueObjectAllOf + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param query_object TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryStyleFormExplodeTrueArrayString", { + # tests for TestQueryStyleFormExplodeTrueArrayString + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param query_object TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryStyleFormExplodeTrueObject", { + # tests for TestQueryStyleFormExplodeTrueObject + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param query_object Pet (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("TestQueryStyleFormExplodeTrueObjectAllOf", { + # tests for TestQueryStyleFormExplodeTrueObjectAllOf + # base path: http://localhost:3000 + # Test query parameter(s) + # Test query parameter(s) + # @param query_object DataQuery (optional) + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_string_enum_ref.R b/samples/client/echo_api/r/tests/testthat/test_string_enum_ref.R new file mode 100644 index 00000000000..69606755c1b --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_string_enum_ref.R @@ -0,0 +1,4 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test StringEnumRef") diff --git a/samples/client/echo_api/r/tests/testthat/test_tag.R b/samples/client/echo_api/r/tests/testthat/test_tag.R new file mode 100644 index 00000000000..af8af7062cd --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_tag.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Tag") + +model_instance <- Tag$new() + +test_that("id", { + # tests for the property `id` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("name", { + # tests for the property `name` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`name`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R b/samples/client/echo_api/r/tests/testthat/test_test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R new file mode 100644 index 00000000000..cd240ba8163 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R @@ -0,0 +1,34 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter") + +model_instance <- TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter$new() + +test_that("size", { + # tests for the property `size` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) + +test_that("color", { + # tests for the property `color` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`color`, "EXPECTED_RESULT") +}) + +test_that("id", { + # tests for the property `id` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`id`, "EXPECTED_RESULT") +}) + +test_that("name", { + # tests for the property `name` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`name`, "EXPECTED_RESULT") +}) diff --git a/samples/client/echo_api/r/tests/testthat/test_test_query_style_form_explode_true_array_string_query_object_parameter.R b/samples/client/echo_api/r/tests/testthat/test_test_query_style_form_explode_true_array_string_query_object_parameter.R new file mode 100644 index 00000000000..d6abe2299d6 --- /dev/null +++ b/samples/client/echo_api/r/tests/testthat/test_test_query_style_form_explode_true_array_string_query_object_parameter.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter") + +model_instance <- TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter$new() + +test_that("values", { + # tests for the property `values` (array[character]) + + # uncomment below to test the property + #expect_equal(model.instance$`values`, "EXPECTED_RESULT") +})