From 17d9552bf1edd61373994c301a538056b7b9e966 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 25 Jul 2022 00:39:15 +0800 Subject: [PATCH 1/9] add httr2 support to r client gen --- bin/configs/r-httr2-client.yaml | 13 + docs/generators/r.md | 1 + .../codegen/languages/RClientCodegen.java | 23 + .../src/main/resources/r/NAMESPACE.mustache | 5 + .../src/main/resources/r/api.mustache | 2 +- .../src/main/resources/r/description.mustache | 2 +- .../r/libraries/httr2/api_client.mustache | 369 +++++ samples/client/petstore/R-httr2/.Rbuildignore | 20 + .../R-httr2/.github/workflows/r-client.yaml | 33 + samples/client/petstore/R-httr2/.gitignore | 35 + samples/client/petstore/R-httr2/.lintr | 7 + .../R-httr2/.openapi-generator-ignore | 23 + .../petstore/R-httr2/.openapi-generator/FILES | 59 + .../R-httr2/.openapi-generator/VERSION | 1 + samples/client/petstore/R-httr2/.travis.yml | 18 + samples/client/petstore/R-httr2/DESCRIPTION | 15 + samples/client/petstore/R-httr2/NAMESPACE | 39 + samples/client/petstore/R-httr2/R.Rproj | 18 + .../R-httr2/R/allof_tag_api_response.R | 215 +++ samples/client/petstore/R-httr2/R/animal.R | 152 ++ .../client/petstore/R-httr2/R/any_of_pig.R | 157 ++ .../client/petstore/R-httr2/R/api_client.R | 371 +++++ .../client/petstore/R-httr2/R/api_exception.R | 83 + .../client/petstore/R-httr2/R/api_response.R | 34 + .../client/petstore/R-httr2/R/basque_pig.R | 158 ++ samples/client/petstore/R-httr2/R/cat.R | 176 ++ .../client/petstore/R-httr2/R/cat_all_of.R | 123 ++ samples/client/petstore/R-httr2/R/category.R | 146 ++ .../client/petstore/R-httr2/R/danish_pig.R | 158 ++ samples/client/petstore/R-httr2/R/dog.R | 176 ++ .../client/petstore/R-httr2/R/dog_all_of.R | 123 ++ samples/client/petstore/R-httr2/R/fake_api.R | 189 +++ .../petstore/R-httr2/R/model_api_response.R | 169 ++ .../client/petstore/R-httr2/R/nested_one_of.R | 148 ++ samples/client/petstore/R-httr2/R/order.R | 238 +++ samples/client/petstore/R-httr2/R/pet.R | 255 +++ samples/client/petstore/R-httr2/R/pet_api.R | 1449 +++++++++++++++++ samples/client/petstore/R-httr2/R/pig.R | 173 ++ samples/client/petstore/R-httr2/R/special.R | 238 +++ samples/client/petstore/R-httr2/R/store_api.R | 620 +++++++ samples/client/petstore/R-httr2/R/tag.R | 146 ++ .../petstore/R-httr2/R/update_pet_request.R | 147 ++ samples/client/petstore/R-httr2/R/user.R | 284 ++++ samples/client/petstore/R-httr2/R/user_api.R | 1178 ++++++++++++++ samples/client/petstore/R-httr2/README.md | 142 ++ .../petstore/R-httr2/build_and_test.bash | 26 + .../R-httr2/docs/AllofTagApiResponse.md | 13 + .../client/petstore/R-httr2/docs/Animal.md | 10 + .../client/petstore/R-httr2/docs/AnyOfPig.md | 11 + .../petstore/R-httr2/docs/ApiResponse.md | 10 + .../client/petstore/R-httr2/docs/BasquePig.md | 10 + samples/client/petstore/R-httr2/docs/Cat.md | 11 + .../client/petstore/R-httr2/docs/CatAllOf.md | 9 + .../client/petstore/R-httr2/docs/Category.md | 11 + .../client/petstore/R-httr2/docs/DanishPig.md | 10 + samples/client/petstore/R-httr2/docs/Dog.md | 11 + .../client/petstore/R-httr2/docs/DogAllOf.md | 9 + .../client/petstore/R-httr2/docs/FakeApi.md | 69 + .../petstore/R-httr2/docs/ModelApiResponse.md | 12 + .../petstore/R-httr2/docs/NestedOneOf.md | 10 + samples/client/petstore/R-httr2/docs/Order.md | 15 + samples/client/petstore/R-httr2/docs/Pet.md | 15 + .../client/petstore/R-httr2/docs/PetApi.md | 572 +++++++ samples/client/petstore/R-httr2/docs/Pig.md | 11 + .../client/petstore/R-httr2/docs/Special.md | 15 + .../client/petstore/R-httr2/docs/StoreApi.md | 242 +++ samples/client/petstore/R-httr2/docs/Tag.md | 11 + .../petstore/R-httr2/docs/UpdatePetRequest.md | 10 + samples/client/petstore/R-httr2/docs/User.md | 17 + .../client/petstore/R-httr2/docs/UserApi.md | 473 ++++++ samples/client/petstore/R-httr2/git_push.sh | 57 + .../R-httr2/man/AllofTagApiResponse.Rd | 196 +++ samples/client/petstore/R-httr2/man/Animal.Rd | 177 ++ .../client/petstore/R-httr2/man/AnyOfPig.Rd | 156 ++ .../client/petstore/R-httr2/man/ApiClient.Rd | 260 +++ .../petstore/R-httr2/man/ApiException.Rd | 95 ++ .../petstore/R-httr2/man/ApiResponse.Rd | 73 + .../client/petstore/R-httr2/man/BasquePig.Rd | 177 ++ samples/client/petstore/R-httr2/man/Cat.Rd | 190 +++ .../client/petstore/R-httr2/man/CatAllOf.Rd | 173 ++ .../client/petstore/R-httr2/man/Category.Rd | 177 ++ .../client/petstore/R-httr2/man/DanishPig.Rd | 177 ++ samples/client/petstore/R-httr2/man/Dog.Rd | 190 +++ .../client/petstore/R-httr2/man/DogAllOf.Rd | 173 ++ .../client/petstore/R-httr2/man/FakeApi.Rd | 183 +++ .../petstore/R-httr2/man/ModelApiResponse.Rd | 181 ++ .../petstore/R-httr2/man/NestedOneOf.Rd | 177 ++ samples/client/petstore/R-httr2/man/Order.Rd | 201 +++ samples/client/petstore/R-httr2/man/Pet.Rd | 201 +++ samples/client/petstore/R-httr2/man/PetApi.Rd | 1055 ++++++++++++ samples/client/petstore/R-httr2/man/Pig.Rd | 156 ++ .../client/petstore/R-httr2/man/Special.Rd | 201 +++ .../client/petstore/R-httr2/man/StoreApi.Rd | 468 ++++++ samples/client/petstore/R-httr2/man/Tag.Rd | 177 ++ .../petstore/R-httr2/man/UpdatePetRequest.Rd | 177 ++ samples/client/petstore/R-httr2/man/User.Rd | 211 +++ .../client/petstore/R-httr2/man/UserApi.Rd | 842 ++++++++++ samples/client/petstore/R-httr2/pom.xml | 46 + .../client/petstore/R-httr2/test_petstore.R | 141 ++ .../client/petstore/R-httr2/tests/testthat.R | 4 + .../testthat/test_allof_tag_api_response.R | 41 + .../R-httr2/tests/testthat/test_animal.R | 20 + .../R-httr2/tests/testthat/test_any_of_pig.R | 27 + .../R-httr2/tests/testthat/test_basque_pig.R | 20 + .../R-httr2/tests/testthat/test_cat.R | 27 + .../R-httr2/tests/testthat/test_cat_all_of.R | 13 + .../R-httr2/tests/testthat/test_category.R | 21 + .../R-httr2/tests/testthat/test_danish_pig.R | 20 + .../R-httr2/tests/testthat/test_dog.R | 27 + .../R-httr2/tests/testthat/test_dog_all_of.R | 13 + .../R-httr2/tests/testthat/test_fake_api.R | 20 + .../tests/testthat/test_model_api_response.R | 28 + .../tests/testthat/test_nested_one_of.R | 20 + .../R-httr2/tests/testthat/test_order.R | 50 + .../R-httr2/tests/testthat/test_pet.R | 50 + .../R-httr2/tests/testthat/test_pet_api.R | 103 ++ .../R-httr2/tests/testthat/test_petstore.R | 321 ++++ .../R-httr2/tests/testthat/test_pig.R | 27 + .../R-httr2/tests/testthat/test_special.R | 27 + .../R-httr2/tests/testthat/test_store_api.R | 53 + .../R-httr2/tests/testthat/test_tag.R | 21 + .../tests/testthat/test_update_pet_request.R | 20 + .../R-httr2/tests/testthat/test_user.R | 64 + .../R-httr2/tests/testthat/test_user_api.R | 99 ++ samples/client/petstore/R/R/fake_api.R | 2 +- samples/client/petstore/R/R/pet_api.R | 18 +- samples/client/petstore/R/R/store_api.R | 8 +- samples/client/petstore/R/R/user_api.R | 16 +- 128 files changed, 17588 insertions(+), 24 deletions(-) create mode 100644 bin/configs/r-httr2-client.yaml create mode 100644 modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache create mode 100644 samples/client/petstore/R-httr2/.Rbuildignore create mode 100644 samples/client/petstore/R-httr2/.github/workflows/r-client.yaml create mode 100644 samples/client/petstore/R-httr2/.gitignore create mode 100644 samples/client/petstore/R-httr2/.lintr create mode 100644 samples/client/petstore/R-httr2/.openapi-generator-ignore create mode 100644 samples/client/petstore/R-httr2/.openapi-generator/FILES create mode 100644 samples/client/petstore/R-httr2/.openapi-generator/VERSION create mode 100644 samples/client/petstore/R-httr2/.travis.yml create mode 100644 samples/client/petstore/R-httr2/DESCRIPTION create mode 100644 samples/client/petstore/R-httr2/NAMESPACE create mode 100644 samples/client/petstore/R-httr2/R.Rproj create mode 100644 samples/client/petstore/R-httr2/R/allof_tag_api_response.R create mode 100644 samples/client/petstore/R-httr2/R/animal.R create mode 100644 samples/client/petstore/R-httr2/R/any_of_pig.R create mode 100644 samples/client/petstore/R-httr2/R/api_client.R create mode 100644 samples/client/petstore/R-httr2/R/api_exception.R create mode 100644 samples/client/petstore/R-httr2/R/api_response.R create mode 100644 samples/client/petstore/R-httr2/R/basque_pig.R create mode 100644 samples/client/petstore/R-httr2/R/cat.R create mode 100644 samples/client/petstore/R-httr2/R/cat_all_of.R create mode 100644 samples/client/petstore/R-httr2/R/category.R create mode 100644 samples/client/petstore/R-httr2/R/danish_pig.R create mode 100644 samples/client/petstore/R-httr2/R/dog.R create mode 100644 samples/client/petstore/R-httr2/R/dog_all_of.R create mode 100644 samples/client/petstore/R-httr2/R/fake_api.R create mode 100644 samples/client/petstore/R-httr2/R/model_api_response.R create mode 100644 samples/client/petstore/R-httr2/R/nested_one_of.R create mode 100644 samples/client/petstore/R-httr2/R/order.R create mode 100644 samples/client/petstore/R-httr2/R/pet.R create mode 100644 samples/client/petstore/R-httr2/R/pet_api.R create mode 100644 samples/client/petstore/R-httr2/R/pig.R create mode 100644 samples/client/petstore/R-httr2/R/special.R create mode 100644 samples/client/petstore/R-httr2/R/store_api.R create mode 100644 samples/client/petstore/R-httr2/R/tag.R create mode 100644 samples/client/petstore/R-httr2/R/update_pet_request.R create mode 100644 samples/client/petstore/R-httr2/R/user.R create mode 100644 samples/client/petstore/R-httr2/R/user_api.R create mode 100644 samples/client/petstore/R-httr2/README.md create mode 100644 samples/client/petstore/R-httr2/build_and_test.bash create mode 100644 samples/client/petstore/R-httr2/docs/AllofTagApiResponse.md create mode 100644 samples/client/petstore/R-httr2/docs/Animal.md create mode 100644 samples/client/petstore/R-httr2/docs/AnyOfPig.md create mode 100644 samples/client/petstore/R-httr2/docs/ApiResponse.md create mode 100644 samples/client/petstore/R-httr2/docs/BasquePig.md create mode 100644 samples/client/petstore/R-httr2/docs/Cat.md create mode 100644 samples/client/petstore/R-httr2/docs/CatAllOf.md create mode 100644 samples/client/petstore/R-httr2/docs/Category.md create mode 100644 samples/client/petstore/R-httr2/docs/DanishPig.md create mode 100644 samples/client/petstore/R-httr2/docs/Dog.md create mode 100644 samples/client/petstore/R-httr2/docs/DogAllOf.md create mode 100644 samples/client/petstore/R-httr2/docs/FakeApi.md create mode 100644 samples/client/petstore/R-httr2/docs/ModelApiResponse.md create mode 100644 samples/client/petstore/R-httr2/docs/NestedOneOf.md create mode 100644 samples/client/petstore/R-httr2/docs/Order.md create mode 100644 samples/client/petstore/R-httr2/docs/Pet.md create mode 100644 samples/client/petstore/R-httr2/docs/PetApi.md create mode 100644 samples/client/petstore/R-httr2/docs/Pig.md create mode 100644 samples/client/petstore/R-httr2/docs/Special.md create mode 100644 samples/client/petstore/R-httr2/docs/StoreApi.md create mode 100644 samples/client/petstore/R-httr2/docs/Tag.md create mode 100644 samples/client/petstore/R-httr2/docs/UpdatePetRequest.md create mode 100644 samples/client/petstore/R-httr2/docs/User.md create mode 100644 samples/client/petstore/R-httr2/docs/UserApi.md create mode 100644 samples/client/petstore/R-httr2/git_push.sh create mode 100644 samples/client/petstore/R-httr2/man/AllofTagApiResponse.Rd create mode 100644 samples/client/petstore/R-httr2/man/Animal.Rd create mode 100644 samples/client/petstore/R-httr2/man/AnyOfPig.Rd create mode 100644 samples/client/petstore/R-httr2/man/ApiClient.Rd create mode 100644 samples/client/petstore/R-httr2/man/ApiException.Rd create mode 100644 samples/client/petstore/R-httr2/man/ApiResponse.Rd create mode 100644 samples/client/petstore/R-httr2/man/BasquePig.Rd create mode 100644 samples/client/petstore/R-httr2/man/Cat.Rd create mode 100644 samples/client/petstore/R-httr2/man/CatAllOf.Rd create mode 100644 samples/client/petstore/R-httr2/man/Category.Rd create mode 100644 samples/client/petstore/R-httr2/man/DanishPig.Rd create mode 100644 samples/client/petstore/R-httr2/man/Dog.Rd create mode 100644 samples/client/petstore/R-httr2/man/DogAllOf.Rd create mode 100644 samples/client/petstore/R-httr2/man/FakeApi.Rd create mode 100644 samples/client/petstore/R-httr2/man/ModelApiResponse.Rd create mode 100644 samples/client/petstore/R-httr2/man/NestedOneOf.Rd create mode 100644 samples/client/petstore/R-httr2/man/Order.Rd create mode 100644 samples/client/petstore/R-httr2/man/Pet.Rd create mode 100644 samples/client/petstore/R-httr2/man/PetApi.Rd create mode 100644 samples/client/petstore/R-httr2/man/Pig.Rd create mode 100644 samples/client/petstore/R-httr2/man/Special.Rd create mode 100644 samples/client/petstore/R-httr2/man/StoreApi.Rd create mode 100644 samples/client/petstore/R-httr2/man/Tag.Rd create mode 100644 samples/client/petstore/R-httr2/man/UpdatePetRequest.Rd create mode 100644 samples/client/petstore/R-httr2/man/User.Rd create mode 100644 samples/client/petstore/R-httr2/man/UserApi.Rd create mode 100644 samples/client/petstore/R-httr2/pom.xml create mode 100644 samples/client/petstore/R-httr2/test_petstore.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_allof_tag_api_response.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_animal.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_any_of_pig.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_basque_pig.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_cat.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_cat_all_of.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_category.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_danish_pig.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_dog.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_dog_all_of.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_fake_api.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_model_api_response.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_nested_one_of.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_order.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_pet.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_pet_api.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_petstore.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_pig.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_special.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_store_api.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_tag.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_update_pet_request.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_user.R create mode 100644 samples/client/petstore/R-httr2/tests/testthat/test_user_api.R diff --git a/bin/configs/r-httr2-client.yaml b/bin/configs/r-httr2-client.yaml new file mode 100644 index 000000000000..15779e26d36c --- /dev/null +++ b/bin/configs/r-httr2-client.yaml @@ -0,0 +1,13 @@ +generatorName: r +outputDir: samples/client/petstore/R-httr2 +inputSpec: modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/r +httpUserAgent: PetstoreAgent +library: httr2 +additionalProperties: + packageName: petstore + exceptionPackage: rlang + useRlangExceptionHandling: true + returnExceptionOnFailure: true + errorObjectType: "ModelApiResponse" + operationIdNaming: snake_case diff --git a/docs/generators/r.md b/docs/generators/r.md index df0b57f42e30..d88ee05f407a 100644 --- a/docs/generators/r.md +++ b/docs/generators/r.md @@ -21,6 +21,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |errorObjectType|Error object type.| |null| |exceptionPackage|Specify the exception handling package|
**default**
Use stop() for raising exceptions.
**rlang**
Use rlang package for exceptions.
|default| |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| +|library|HTTP library template (sub-template) to use|
**httr2**
httr2 (https://httr2.r-lib.org/)
**httr**
httr (https://cran.r-project.org/web/packages/httr/index.html)
|httr| |operationIdNaming|Naming convention for operationId (function name in the API)|
**PascalCase**
Pascal case (default)
**snake_case**
Snake case
**camelCase**
Camel case
|null| |packageName|R package name (convention: lowercase).| |openapi| |packageVersion|R package version.| |1.0.0| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java index 8a465971e6d0..034b722f874f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java @@ -64,6 +64,8 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig { public static final String USE_RLANG_EXCEPTION = "useRlangExceptionHandling"; public static final String DEFAULT = "default"; public static final String RLANG = "rlang"; + public static final String HTTR = "httr"; + public static final String HTTR2 = "httr2"; // naming convention for operationId (function names in the API) public static final String OPERATIONID_NAMING = "operationIdNaming"; @@ -199,6 +201,16 @@ public RClientCodegen() { cliOptions.add(exceptionPackage); cliOptions.add(CliOption.newString(CodegenConstants.ERROR_OBJECT_TYPE, "Error object type.")); + + supportedLibraries.put(HTTR2, "httr2 (https://httr2.r-lib.org/)"); + supportedLibraries.put(HTTR, "httr (https://cran.r-project.org/web/packages/httr/index.html)"); + + CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "HTTP library template (sub-template) to use"); + libraryOption.setEnum(supportedLibraries); + // set httr as the default + libraryOption.setDefault(HTTR); + cliOptions.add(libraryOption); + setLibrary(HTTR); } @Override @@ -274,6 +286,17 @@ public void processOpts() { supportingFiles.add(new SupportingFile("r-client.mustache", File.separator + ".github" + File.separator + "workflows", "r-client.yaml")); supportingFiles.add(new SupportingFile("lintr.mustache", "", ".lintr")); + if (HTTR.equals(getLibrary())) { + // for httr + setLibrary(HTTR); + } else if (HTTR2.equals(getLibrary())) { + // for httr2 + setLibrary(HTTR2); + additionalProperties.put("isHttr2", Boolean.TRUE); + } else { + throw new IllegalArgumentException("Invalid HTTP library " + getLibrary() + ". Only httr, httr2 are supported."); + } + // add lambda for mustache templates to fix license field additionalProperties.put("lambdaLicense", new Mustache.Lambda() { @Override diff --git a/modules/openapi-generator/src/main/resources/r/NAMESPACE.mustache b/modules/openapi-generator/src/main/resources/r/NAMESPACE.mustache index b040f5adc442..4f73f6577cff 100644 --- a/modules/openapi-generator/src/main/resources/r/NAMESPACE.mustache +++ b/modules/openapi-generator/src/main/resources/r/NAMESPACE.mustache @@ -3,7 +3,12 @@ import(R6) import(jsonlite) +{{^isHttr2}} import(httr) +{{/isHttr2}} +{{#isHttr2}} +import(httr2) +{{/isHttr2}} import(base64enc) # Core diff --git a/modules/openapi-generator/src/main/resources/r/api.mustache b/modules/openapi-generator/src/main/resources/r/api.mustache index 54fa845382e4..fb6d627c1f0a 100644 --- a/modules/openapi-generator/src/main/resources/r/api.mustache +++ b/modules/openapi-generator/src/main/resources/r/api.mustache @@ -234,7 +234,7 @@ #' @export {{{operationId}}}{{WithHttpInfo}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}} = {{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#vendorExtensions.x-streaming}}stream_callback = NULL, {{/vendorExtensions.x-streaming}}{{#returnType}}data_file = NULL, {{/returnType}}...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() {{#requiredParams}} diff --git a/modules/openapi-generator/src/main/resources/r/description.mustache b/modules/openapi-generator/src/main/resources/r/description.mustache index 2a16f842bf10..fe558e285696 100644 --- a/modules/openapi-generator/src/main/resources/r/description.mustache +++ b/modules/openapi-generator/src/main/resources/r/description.mustache @@ -11,5 +11,5 @@ Encoding: UTF-8 License: {{#lambdaLicense}}{{licenseInfo}}{{/lambdaLicense}}{{^licenseInfo}}Unlicense{{/licenseInfo}} LazyData: true Suggests: testthat -Imports: jsonlite, httr, R6, base64enc +Imports: jsonlite, httr{{#isHttr2}}2{{/isHttr2}}, R6, base64enc RoxygenNote: 7.2.0 diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache new file mode 100644 index 000000000000..05e633839527 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -0,0 +1,369 @@ +{{>partial_header}} +#' 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 access_token Access token +#' @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 +{{#useRlangExceptionHandling}} +#' @importFrom rlang abort +{{/useRlangExceptionHandling}} +#' @export +ApiClient <- R6::R6Class( + "ApiClient", + public = list( + # base path of all requests + base_path = "{{{basePath}}}", + # user agent in the HTTP request + user_agent = "{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}", + # 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, + # Access token + access_token = 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 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, body, stream_callback = NULL, ...) { + + resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...) + #status_code <- httr::status_code(resp) + + #if (is.null(self$max_retry_attempts)) { + # self$req_retry(max_tries <- max_retry_attempts) + #} + + #if (!is.null(self$retry_status_codes)) { + + # for (i in 1 : self$max_retry_attempts) { + # if (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, body, stream_callback = stream_callback, ...) + # status_code <- httr::status_code(resp) + # } 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 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, body, stream_callback = NULL, ...) { + req <- request(url) + + ## add headers and default headers + if (!is.null(header_params) && length(header_params) != 0) { + req %>% req_headers(header_params) + } + if (length(self$default_headers) != 0) { + req %>% req_headers(self$default_headers) + } + + ## add query parameters + if (length(query_params) != 0) { + req %>% req_url_query(query_params) + } + + # add body parameters + if (!is.null(body)) { + req %>% req_body_raw(body) + } + + # set timeout + {{! Adding timeout that can be set at the apiClient object level}} + if (!is.null(self$timeout)) { + req %>% req_timeout(self$timeout) + } + + # set retry + if (!is.null(self$max_retry_attempts)) { + req %>% retry_max_tries(self$timeout) + req %>% retry_max_seconds(self$timeout) + } + + # set user agent + if (!is.null(self$user_agent)) { + req %>% req_user_agent(self$user_agent) + } + + # set HTTP verb + req %>% req_method(method) + + # stream data + if (typeof(stream_callback) == "closure") { + req %>% req_stream(stream_callback) + } + + # perform the HTTP request + req_perform(req) + + #if (method == "GET") { + # if (typeof(stream_callback) == "closure") { + # httr::GET(url, query = query_params, headers, http_timeout, + # httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # httr::GET(url, query = query_params, headers, http_timeout, + # httr::user_agent(self$`user_agent`), ...) + # } + #} else if (method == "POST") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # httr::HEAD(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # httr::HEAD(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), ...) + # } + #} else if (method == "DELETE") { + # if (typeof(stream_callback) == "closure") { + # httr::DELETE(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # 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`." + # {{#useDefaultExceptionHandling}} + # stop(err_msg) + # {{/useDefaultExceptionHandling}} + # {{#useRlangExceptionHandling}} + # rlang::abort(message = err_msg, + # .subclass = "ApiException", + # ApiException = ApiException$new(status = 0, reason = err_msg)) + # {{/useRlangExceptionHandling}} + #} + }, + #' Deserialize the content of api response to the given type. + #' + #' @description + #' Deserialize the content of api response to the given type. + #' + #' @param resp Response object. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserialize = function(resp, return_type, pkg_env) { + resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) + 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() + return_obj$fromJSON( + jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE) + ) + } else { + # To handle primitive type + return_obj <- obj + } + return_obj + } + ) +) diff --git a/samples/client/petstore/R-httr2/.Rbuildignore b/samples/client/petstore/R-httr2/.Rbuildignore new file mode 100644 index 000000000000..d982e4aa8842 --- /dev/null +++ b/samples/client/petstore/R-httr2/.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$ +^petstore\.Rcheck$ +^\.\.Rcheck$ diff --git a/samples/client/petstore/R-httr2/.github/workflows/r-client.yaml b/samples/client/petstore/R-httr2/.github/workflows/r-client.yaml new file mode 100644 index 000000000000..216ebe6c0034 --- /dev/null +++ b/samples/client/petstore/R-httr2/.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/petstore/R-httr2/.gitignore b/samples/client/petstore/R-httr2/.gitignore new file mode 100644 index 000000000000..5d21150e0cae --- /dev/null +++ b/samples/client/petstore/R-httr2/.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/petstore/R-httr2/.lintr b/samples/client/petstore/R-httr2/.lintr new file mode 100644 index 000000000000..54ee36a49cd7 --- /dev/null +++ b/samples/client/petstore/R-httr2/.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/petstore/R-httr2/.openapi-generator-ignore b/samples/client/petstore/R-httr2/.openapi-generator-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/client/petstore/R-httr2/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# 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 Swagger Codgen 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/petstore/R-httr2/.openapi-generator/FILES b/samples/client/petstore/R-httr2/.openapi-generator/FILES new file mode 100644 index 000000000000..7a05f5fdda5d --- /dev/null +++ b/samples/client/petstore/R-httr2/.openapi-generator/FILES @@ -0,0 +1,59 @@ +.Rbuildignore +.github/workflows/r-client.yaml +.gitignore +.lintr +.travis.yml +DESCRIPTION +NAMESPACE +R/allof_tag_api_response.R +R/animal.R +R/any_of_pig.R +R/api_client.R +R/api_exception.R +R/api_response.R +R/basque_pig.R +R/cat.R +R/cat_all_of.R +R/category.R +R/danish_pig.R +R/dog.R +R/dog_all_of.R +R/fake_api.R +R/model_api_response.R +R/nested_one_of.R +R/order.R +R/pet.R +R/pet_api.R +R/pig.R +R/special.R +R/store_api.R +R/tag.R +R/update_pet_request.R +R/user.R +R/user_api.R +README.md +docs/AllofTagApiResponse.md +docs/Animal.md +docs/AnyOfPig.md +docs/BasquePig.md +docs/Cat.md +docs/CatAllOf.md +docs/Category.md +docs/DanishPig.md +docs/Dog.md +docs/DogAllOf.md +docs/FakeApi.md +docs/ModelApiResponse.md +docs/NestedOneOf.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/Pig.md +docs/Special.md +docs/StoreApi.md +docs/Tag.md +docs/UpdatePetRequest.md +docs/User.md +docs/UserApi.md +git_push.sh +tests/testthat.R diff --git a/samples/client/petstore/R-httr2/.openapi-generator/VERSION b/samples/client/petstore/R-httr2/.openapi-generator/VERSION new file mode 100644 index 000000000000..66672d4e9d31 --- /dev/null +++ b/samples/client/petstore/R-httr2/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.1.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/R-httr2/.travis.yml b/samples/client/petstore/R-httr2/.travis.yml new file mode 100644 index 000000000000..b96a0ef5a859 --- /dev/null +++ b/samples/client/petstore/R-httr2/.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/petstore/R-httr2/DESCRIPTION b/samples/client/petstore/R-httr2/DESCRIPTION new file mode 100644 index 000000000000..7286eadcfc0f --- /dev/null +++ b/samples/client/petstore/R-httr2/DESCRIPTION @@ -0,0 +1,15 @@ +Package: petstore +Title: R Package Client for OpenAPI Petstore +Version: 1.0.0 +Author: person("OpenAPI Generator community", email = "team@openapitools.org", role = c("aut", "cre")) +Maintainer: OpenAPI Generator community +Description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +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 License 2.0 +LazyData: true +Suggests: testthat +Imports: jsonlite, httr2, R6, base64enc +RoxygenNote: 7.2.0 diff --git a/samples/client/petstore/R-httr2/NAMESPACE b/samples/client/petstore/R-httr2/NAMESPACE new file mode 100644 index 000000000000..eeea6f0cb2ef --- /dev/null +++ b/samples/client/petstore/R-httr2/NAMESPACE @@ -0,0 +1,39 @@ +# Generated by openapi-generator: https://openapi-generator.tech +# Do not edit by hand + +import(R6) +import(jsonlite) +import(httr2) +import(base64enc) + +# Core +export(ApiClient) +export(ApiResponse) +export(ApiException) + +# Models +export(AllofTagApiResponse) +export(Animal) +export(AnyOfPig) +export(BasquePig) +export(Cat) +export(CatAllOf) +export(Category) +export(DanishPig) +export(Dog) +export(DogAllOf) +export(ModelApiResponse) +export(NestedOneOf) +export(Order) +export(Pet) +export(Pig) +export(Special) +export(Tag) +export(UpdatePetRequest) +export(User) + +# APIs +export(FakeApi) +export(PetApi) +export(StoreApi) +export(UserApi) diff --git a/samples/client/petstore/R-httr2/R.Rproj b/samples/client/petstore/R-httr2/R.Rproj new file mode 100644 index 000000000000..eaa6b8186b78 --- /dev/null +++ b/samples/client/petstore/R-httr2/R.Rproj @@ -0,0 +1,18 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/samples/client/petstore/R-httr2/R/allof_tag_api_response.R b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R new file mode 100644 index 000000000000..8cae653d3e6c --- /dev/null +++ b/samples/client/petstore/R-httr2/R/allof_tag_api_response.R @@ -0,0 +1,215 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title AllofTagApiResponse +#' @description AllofTagApiResponse Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field name character [optional] +#' @field code integer [optional] +#' @field type character [optional] +#' @field message character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +AllofTagApiResponse <- R6::R6Class( + "AllofTagApiResponse", + public = list( + `id` = NULL, + `name` = NULL, + `code` = NULL, + `type` = NULL, + `message` = NULL, + #' Initialize a new AllofTagApiResponse class. + #' + #' @description + #' Initialize a new AllofTagApiResponse class. + #' + #' @param id id + #' @param name name + #' @param code code + #' @param type type + #' @param message message + #' @param ... Other optional arguments. + #' @export + initialize = function( + `id` = NULL, `name` = NULL, `code` = NULL, `type` = NULL, `message` = NULL, ... + ) { + if (!is.null(`id`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + self$`id` <- `id` + } + if (!is.null(`name`)) { + stopifnot(is.character(`name`), length(`name`) == 1) + self$`name` <- `name` + } + if (!is.null(`code`)) { + stopifnot(is.numeric(`code`), length(`code`) == 1) + self$`code` <- `code` + } + if (!is.null(`type`)) { + stopifnot(is.character(`type`), length(`type`) == 1) + self$`type` <- `type` + } + if (!is.null(`message`)) { + stopifnot(is.character(`message`), length(`message`) == 1) + self$`message` <- `message` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return AllofTagApiResponse in JSON format + #' @export + toJSON = function() { + AllofTagApiResponseObject <- list() + if (!is.null(self$`id`)) { + AllofTagApiResponseObject[["id"]] <- + self$`id` + } + if (!is.null(self$`name`)) { + AllofTagApiResponseObject[["name"]] <- + self$`name` + } + if (!is.null(self$`code`)) { + AllofTagApiResponseObject[["code"]] <- + self$`code` + } + if (!is.null(self$`type`)) { + AllofTagApiResponseObject[["type"]] <- + self$`type` + } + if (!is.null(self$`message`)) { + AllofTagApiResponseObject[["message"]] <- + self$`message` + } + + AllofTagApiResponseObject + }, + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @param input_json the JSON input + #' @return the instance of AllofTagApiResponse + #' @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$`code`)) { + self$`code` <- this_object$`code` + } + if (!is.null(this_object$`type`)) { + self$`type` <- this_object$`type` + } + if (!is.null(this_object$`message`)) { + self$`message` <- this_object$`message` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return AllofTagApiResponse 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$`code`)) { + sprintf( + '"code": + %d + ', + self$`code` + ) + }, + if (!is.null(self$`type`)) { + sprintf( + '"type": + "%s" + ', + self$`type` + ) + }, + if (!is.null(self$`message`)) { + sprintf( + '"message": + "%s" + ', + self$`message` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of AllofTagApiResponse + #' + #' @param input_json the JSON input + #' @return the instance of AllofTagApiResponse + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`name` <- this_object$`name` + self$`code` <- this_object$`code` + self$`type` <- this_object$`type` + self$`message` <- this_object$`message` + self + }, + #' Validate JSON input with respect to AllofTagApiResponse + #' + #' @description + #' Validate JSON input with respect to AllofTagApiResponse 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 AllofTagApiResponse + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/animal.R b/samples/client/petstore/R-httr2/R/animal.R new file mode 100644 index 000000000000..3640667985a1 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/animal.R @@ -0,0 +1,152 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Animal +#' @description Animal Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field color character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Animal <- R6::R6Class( + "Animal", + public = list( + `className` = NULL, + `color` = NULL, + #' Initialize a new Animal class. + #' + #' @description + #' Initialize a new Animal class. + #' + #' @param className className + #' @param color color. Default to "red". + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, `color` = "red", ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!is.null(`color`)) { + stopifnot(is.character(`color`), length(`color`) == 1) + self$`color` <- `color` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Animal in JSON format + #' @export + toJSON = function() { + AnimalObject <- list() + if (!is.null(self$`className`)) { + AnimalObject[["className"]] <- + self$`className` + } + if (!is.null(self$`color`)) { + AnimalObject[["color"]] <- + self$`color` + } + + AnimalObject + }, + #' Deserialize JSON string into an instance of Animal + #' + #' @description + #' Deserialize JSON string into an instance of Animal + #' + #' @param input_json the JSON input + #' @return the instance of Animal + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Animal in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Animal + #' + #' @description + #' Deserialize JSON string into an instance of Animal + #' + #' @param input_json the JSON input + #' @return the instance of Animal + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self$`color` <- this_object$`color` + self + }, + #' Validate JSON input with respect to Animal + #' + #' @description + #' Validate JSON input with respect to Animal and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `className` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Animal: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Animal + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/any_of_pig.R b/samples/client/petstore/R-httr2/R/any_of_pig.R new file mode 100644 index 000000000000..bd6571869377 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/any_of_pig.R @@ -0,0 +1,157 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title AnyOfPig +#' +#' @description AnyOfPig Class +#' +#' @format An \code{R6Class} generator object +#' +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +AnyOfPig <- R6::R6Class( + "AnyOfPig", + public = list( + #' @field actual_instance the object stored in this instance. + actual_instance = NULL, + #' @field actual_type the type of the object stored in this instance. + actual_type = NULL, + #' @field any_of a list of object types defined in the anyOf schema. + any_of = list("BasquePig", "DanishPig"), + #' Initialize a new AnyOfPig. + #' + #' @description + #' Initialize a new AnyOfPig. + #' + #' @param instance an instance of the object defined in the anyOf schemas: "BasquePig", "DanishPig" + #' @export + initialize = function(instance = NULL) { + if (is.null(instance)) { + # do nothing + } else if (get(class(instance)[[1]], pos = -1)$classname == "BasquePig") { + self$actual_instance <- instance + self$actual_type <- "BasquePig" + } else if (get(class(instance)[[1]], pos = -1)$classname == "DanishPig") { + self$actual_instance <- instance + self$actual_type <- "DanishPig" + } else { + stop(paste("Failed to initialize AnyOfPig with anyOf schemas BasquePig, DanishPig. Provided class name: ", + get(class(instance)[[1]], pos = -1)$classname)) + } + }, + #' Deserialize JSON string into an instance of AnyOfPig. + #' + #' @description + #' Deserialize JSON string into an instance of AnyOfPig. + #' + #' @param input The input JSON. + #' @return An instance of AnyOfPig. + #' @export + fromJSON = function(input) { + error_messages <- list() + + BasquePig_result <- tryCatch({ + BasquePig$public_methods$validateJSON(input) + BasquePig_instance <- BasquePig$new() + self$actual_instance <- BasquePig_instance$fromJSON(input) + self$actual_type <- "BasquePig" + return(self) + }, + error = function(err) err + ) + + if (!is.null(BasquePig_result["error"])) { + error_messages <- append(error_messages, BasquePig_result["message"]) + } + + DanishPig_result <- tryCatch({ + DanishPig$public_methods$validateJSON(input) + DanishPig_instance <- DanishPig$new() + self$actual_instance <- DanishPig_instance$fromJSON(input) + self$actual_type <- "DanishPig" + return(self) + }, + error = function(err) err + ) + + if (!is.null(DanishPig_result["error"])) { + error_messages <- append(error_messages, DanishPig_result["message"]) + } + + # no match + stop(paste("No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: ", + paste(error_messages, collapse = ", "))) + }, + #' Serialize AnyOfPig to JSON string. + #' + #' @description + #' Serialize AnyOfPig to JSON string. + #' + #' @return JSON string representation of the AnyOfPig. + #' @export + toJSONString = function() { + if (!is.null(self$actual_instance)) { + as.character(jsonlite::minify((self$actual_instance$toJSONString()))) + } else { + NULL + } + }, + #' Serialize AnyOfPig to JSON. + #' + #' @description + #' Serialize AnyOfPig to JSON. + #' + #' @return JSON representation of the AnyOfPig. + #' @export + toJSON = function() { + if (!is.null(self$actual_instance)) { + self$actual_instance$toJSON() + } else { + NULL + } + }, + #' Validate the input JSON with respect to AnyOfPig. + #' + #' @description + #' Validate the input JSON with respect to AnyOfPig and + #' throw exception if invalid. + #' + #' @param input The input JSON. + #' @export + validateJSON = function(input) { + # backup current values + actual_instance_bak <- self$actual_instance + actual_type_bak <- self$actual_type + + # if it's not valid, an error will be thrown + self$fromJSON(input) + + # no error thrown, restore old values + self$actual_instance <- actual_instance_bak + self$actual_type <- actual_type_bak + }, + #' Returns the string representation of the instance. + #' + #' @description + #' Returns the string representation of the instance. + #' + #' @return The string representation of the instance. + #' @export + toString = function() { + jsoncontent <- c( + sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()), + sprintf('"actual_type": "%s"', self$actual_type), + sprintf('"any_of": "%s"', paste(unlist(self$any_of), collapse = ", ")) + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = ""))) + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R new file mode 100644 index 000000000000..84c9d620568f --- /dev/null +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -0,0 +1,371 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' 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 access_token Access token +#' @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 +#' @importFrom rlang abort +#' @export +ApiClient <- R6::R6Class( + "ApiClient", + public = list( + # base path of all requests + base_path = "http://petstore.swagger.io/v2", + # user agent in the HTTP request + user_agent = "PetstoreAgent", + # 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, + # Access token + access_token = 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 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, body, stream_callback = NULL, ...) { + + resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...) + #status_code <- httr::status_code(resp) + + #if (is.null(self$max_retry_attempts)) { + # self$req_retry(max_tries <- max_retry_attempts) + #} + + #if (!is.null(self$retry_status_codes)) { + + # for (i in 1 : self$max_retry_attempts) { + # if (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, body, stream_callback = stream_callback, ...) + # status_code <- httr::status_code(resp) + # } 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 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, body, stream_callback = NULL, ...) { + req <- request(url) + + ## add headers and default headers + if (!is.null(header_params) && length(header_params) != 0) { + req %>% req_headers(header_params) + } + if (length(self$default_headers) != 0) { + req %>% req_headers(self$default_headers) + } + + ## add query parameters + if (length(query_params) != 0) { + req %>% req_url_query(query_params) + } + + # add body parameters + if (!is.null(body)) { + req %>% req_body_raw(body) + } + + # set timeout + if (!is.null(self$timeout)) { + req %>% req_timeout(self$timeout) + } + + # set retry + if (!is.null(self$max_retry_attempts)) { + req %>% retry_max_tries(self$timeout) + req %>% retry_max_seconds(self$timeout) + } + + # set user agent + if (!is.null(self$user_agent)) { + req %>% req_user_agent(self$user_agent) + } + + # set HTTP verb + req %>% req_method(method) + + # stream data + if (typeof(stream_callback) == "closure") { + req %>% req_stream(stream_callback) + } + + # perform the HTTP request + req_perform(req) + + #if (method == "GET") { + # if (typeof(stream_callback) == "closure") { + # httr::GET(url, query = query_params, headers, http_timeout, + # httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # httr::GET(url, query = query_params, headers, http_timeout, + # httr::user_agent(self$`user_agent`), ...) + # } + #} else if (method == "POST") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # 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 { + # 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") { + # if (typeof(stream_callback) == "closure") { + # httr::HEAD(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # httr::HEAD(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), ...) + # } + #} else if (method == "DELETE") { + # if (typeof(stream_callback) == "closure") { + # httr::DELETE(url, query = query_params, headers, http_timeout, + # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) + # } else { + # 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`." + # + # + # rlang::abort(message = err_msg, + # .subclass = "ApiException", + # ApiException = ApiException$new(status = 0, reason = err_msg)) + # + #} + }, + #' Deserialize the content of api response to the given type. + #' + #' @description + #' Deserialize the content of api response to the given type. + #' + #' @param resp Response object. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserialize = function(resp, return_type, pkg_env) { + resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) + 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() + return_obj$fromJSON( + jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE) + ) + } else { + # To handle primitive type + return_obj <- obj + } + return_obj + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/api_exception.R b/samples/client/petstore/R-httr2/R/api_exception.R new file mode 100644 index 000000000000..41bee0bb2031 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/api_exception.R @@ -0,0 +1,83 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title ApiException +#' @description ApiException Class +#' @format An \code{R6Class} generator object +#' @field status Status of the ApiException +#' @field reason Reason of the ApiException +#' @field body Body of the http response +#' @field headers Headers of the http response +#' @field errorObject error object type +#' @export +ApiException <- R6::R6Class( + "ApiException", + public = list( + status = NULL, + reason = NULL, + body = NULL, + headers = NULL, + errorObject = NULL, + #' Initialize a new ApiException class. + #' + #' @description + #' Initialize a new ApiExceptino class. + #' + #' @param status HTTP status. + #' @param reason Reason of the ApiException. + #' @param http_response HTTP response object. + #' @export + initialize = function(status = NULL, reason = NULL, http_response = NULL) { + if (!is.null(http_response)) { + self$status <- http_response$status_code + errorMsg <- toString(content(http_response)) + if (errorMsg == "") { + errorMsg <- "Api exception encountered. No details given." + } + self$body <- errorMsg + self$headers <- http_response$headers + self$reason <- httr::http_status(http_response)$reason + self$errorObject <- ModelApiResponse$new()$fromJSONString(content(http_response, "text")) + } else { + self$status <- status + self$reason <- reason + self$body <- NULL + self$headers <- NULL + self$errorObject <- NULL + } + }, + #' Returns the string format of ApiException. + #' + #' @description + #' Returns the string format of ApiException. + #' + #' @return the string format of ApiException. + #' @export + toString = function() { + errorMsg <- "" + errorMsg <- paste("status : ", self$status, "\n", sep = "") + errorMsg <- paste(errorMsg, "Reason : ", self$reason, "\n", sep = "") + if (!is.null(self$headers)) { + errorMsg <- paste(errorMsg, "Headers : ", "\n", sep = "") + for (name in names(self$headers)) { + errorMsg <- paste(errorMsg, name, " : ", self$headers[[name]], "\n", sep = " ") + } + } + if (!is.null(self$body)) { + errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "") + errorMsg <- paste(errorMsg, self$body, "\n") + } + if (!is.null(self$errorObject)) { + errorMsg <- paste(errorMsg, "Error object : ", "\n", sep = "") + errorMsg <- paste(errorMsg, self$errorObject$toJSONString(), "\n") + } + errorMsg + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/api_response.R b/samples/client/petstore/R-httr2/R/api_response.R new file mode 100644 index 000000000000..2362fd4e4662 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/api_response.R @@ -0,0 +1,34 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' 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. +#' @export +ApiResponse <- R6::R6Class( + "ApiResponse", + public = list( + content = NULL, + response = 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. + #' @export + initialize = function(content, response) { + self$content <- content + self$response <- response + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/basque_pig.R b/samples/client/petstore/R-httr2/R/basque_pig.R new file mode 100644 index 000000000000..0324d48c10a2 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/basque_pig.R @@ -0,0 +1,158 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title BasquePig +#' @description BasquePig Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field color character +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +BasquePig <- R6::R6Class( + "BasquePig", + public = list( + `className` = NULL, + `color` = NULL, + #' Initialize a new BasquePig class. + #' + #' @description + #' Initialize a new BasquePig class. + #' + #' @param className className + #' @param color color + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, `color`, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!missing(`color`)) { + stopifnot(is.character(`color`), length(`color`) == 1) + self$`color` <- `color` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return BasquePig in JSON format + #' @export + toJSON = function() { + BasquePigObject <- list() + if (!is.null(self$`className`)) { + BasquePigObject[["className"]] <- + self$`className` + } + if (!is.null(self$`color`)) { + BasquePigObject[["color"]] <- + self$`color` + } + + BasquePigObject + }, + #' Deserialize JSON string into an instance of BasquePig + #' + #' @description + #' Deserialize JSON string into an instance of BasquePig + #' + #' @param input_json the JSON input + #' @return the instance of BasquePig + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return BasquePig in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of BasquePig + #' + #' @description + #' Deserialize JSON string into an instance of BasquePig + #' + #' @param input_json the JSON input + #' @return the instance of BasquePig + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self$`color` <- this_object$`color` + self + }, + #' Validate JSON input with respect to BasquePig + #' + #' @description + #' Validate JSON input with respect to BasquePig and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `className` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `className` is missing.")) + } + # check the required field `color` + if (!is.null(input_json$`color`)) { + stopifnot(is.character(input_json$`color`), length(input_json$`color`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for BasquePig: the required field `color` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of BasquePig + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/cat.R b/samples/client/petstore/R-httr2/R/cat.R new file mode 100644 index 000000000000..1ec34dc4a75e --- /dev/null +++ b/samples/client/petstore/R-httr2/R/cat.R @@ -0,0 +1,176 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Cat +#' @description Cat Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field color character [optional] +#' @field declawed character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Cat <- R6::R6Class( + "Cat", + inherit = Animal, + public = list( + `className` = NULL, + `color` = NULL, + `declawed` = NULL, + #' Initialize a new Cat class. + #' + #' @description + #' Initialize a new Cat class. + #' + #' @param className className + #' @param color color. Default to "red". + #' @param declawed declawed + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, `color` = "red", `declawed` = NULL, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!is.null(`color`)) { + stopifnot(is.character(`color`), length(`color`) == 1) + self$`color` <- `color` + } + if (!is.null(`declawed`)) { + stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + self$`declawed` <- `declawed` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Cat in JSON format + #' @export + toJSON = function() { + CatObject <- list() + if (!is.null(self$`className`)) { + CatObject[["className"]] <- + self$`className` + } + if (!is.null(self$`color`)) { + CatObject[["color"]] <- + self$`color` + } + if (!is.null(self$`declawed`)) { + CatObject[["declawed"]] <- + self$`declawed` + } + + CatObject + }, + #' Deserialize JSON string into an instance of Cat + #' + #' @description + #' Deserialize JSON string into an instance of Cat + #' + #' @param input_json the JSON input + #' @return the instance of Cat + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + if (!is.null(this_object$`declawed`)) { + self$`declawed` <- this_object$`declawed` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Cat in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + }, + if (!is.null(self$`declawed`)) { + sprintf( + '"declawed": + %s + ', + tolower(self$`declawed`) + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Cat + #' + #' @description + #' Deserialize JSON string into an instance of Cat + #' + #' @param input_json the JSON input + #' @return the instance of Cat + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self$`color` <- this_object$`color` + self$`declawed` <- this_object$`declawed` + self + }, + #' Validate JSON input with respect to Cat + #' + #' @description + #' Validate JSON input with respect to Cat and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `className` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Cat: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Cat + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/cat_all_of.R b/samples/client/petstore/R-httr2/R/cat_all_of.R new file mode 100644 index 000000000000..063ece351fd3 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/cat_all_of.R @@ -0,0 +1,123 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title CatAllOf +#' @description CatAllOf Class +#' @format An \code{R6Class} generator object +#' @field declawed character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +CatAllOf <- R6::R6Class( + "CatAllOf", + public = list( + `declawed` = NULL, + #' Initialize a new CatAllOf class. + #' + #' @description + #' Initialize a new CatAllOf class. + #' + #' @param declawed declawed + #' @param ... Other optional arguments. + #' @export + initialize = function( + `declawed` = NULL, ... + ) { + if (!is.null(`declawed`)) { + stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + self$`declawed` <- `declawed` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return CatAllOf in JSON format + #' @export + toJSON = function() { + CatAllOfObject <- list() + if (!is.null(self$`declawed`)) { + CatAllOfObject[["declawed"]] <- + self$`declawed` + } + + CatAllOfObject + }, + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @description + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @param input_json the JSON input + #' @return the instance of CatAllOf + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`declawed`)) { + self$`declawed` <- this_object$`declawed` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return CatAllOf in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`declawed`)) { + sprintf( + '"declawed": + %s + ', + tolower(self$`declawed`) + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @description + #' Deserialize JSON string into an instance of CatAllOf + #' + #' @param input_json the JSON input + #' @return the instance of CatAllOf + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`declawed` <- this_object$`declawed` + self + }, + #' Validate JSON input with respect to CatAllOf + #' + #' @description + #' Validate JSON input with respect to CatAllOf 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 CatAllOf + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/category.R b/samples/client/petstore/R-httr2/R/category.R new file mode 100644 index 000000000000..051506bbc9e8 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/category.R @@ -0,0 +1,146 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @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`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + self$`id` <- `id` + } + if (!is.null(`name`)) { + stopifnot(is.character(`name`), length(`name`) == 1) + 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 = ",") + 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() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/danish_pig.R b/samples/client/petstore/R-httr2/R/danish_pig.R new file mode 100644 index 000000000000..97eef4cda57b --- /dev/null +++ b/samples/client/petstore/R-httr2/R/danish_pig.R @@ -0,0 +1,158 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title DanishPig +#' @description DanishPig Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field size integer +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +DanishPig <- R6::R6Class( + "DanishPig", + public = list( + `className` = NULL, + `size` = NULL, + #' Initialize a new DanishPig class. + #' + #' @description + #' Initialize a new DanishPig class. + #' + #' @param className className + #' @param size size + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, `size`, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!missing(`size`)) { + stopifnot(is.numeric(`size`), length(`size`) == 1) + self$`size` <- `size` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DanishPig in JSON format + #' @export + toJSON = function() { + DanishPigObject <- list() + if (!is.null(self$`className`)) { + DanishPigObject[["className"]] <- + self$`className` + } + if (!is.null(self$`size`)) { + DanishPigObject[["size"]] <- + self$`size` + } + + DanishPigObject + }, + #' Deserialize JSON string into an instance of DanishPig + #' + #' @description + #' Deserialize JSON string into an instance of DanishPig + #' + #' @param input_json the JSON input + #' @return the instance of DanishPig + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + if (!is.null(this_object$`size`)) { + self$`size` <- this_object$`size` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DanishPig in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + }, + if (!is.null(self$`size`)) { + sprintf( + '"size": + %d + ', + self$`size` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of DanishPig + #' + #' @description + #' Deserialize JSON string into an instance of DanishPig + #' + #' @param input_json the JSON input + #' @return the instance of DanishPig + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self$`size` <- this_object$`size` + self + }, + #' Validate JSON input with respect to DanishPig + #' + #' @description + #' Validate JSON input with respect to DanishPig and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `className` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `className` is missing.")) + } + # check the required field `size` + if (!is.null(input_json$`size`)) { + stopifnot(is.numeric(input_json$`size`), length(input_json$`size`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for DanishPig: the required field `size` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of DanishPig + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/dog.R b/samples/client/petstore/R-httr2/R/dog.R new file mode 100644 index 000000000000..b52f75ccbae7 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/dog.R @@ -0,0 +1,176 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Dog +#' @description Dog Class +#' @format An \code{R6Class} generator object +#' @field className character +#' @field color character [optional] +#' @field breed character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Dog <- R6::R6Class( + "Dog", + inherit = Animal, + public = list( + `className` = NULL, + `color` = NULL, + `breed` = NULL, + #' Initialize a new Dog class. + #' + #' @description + #' Initialize a new Dog class. + #' + #' @param className className + #' @param color color. Default to "red". + #' @param breed breed + #' @param ... Other optional arguments. + #' @export + initialize = function( + `className`, `color` = "red", `breed` = NULL, ... + ) { + if (!missing(`className`)) { + stopifnot(is.character(`className`), length(`className`) == 1) + self$`className` <- `className` + } + if (!is.null(`color`)) { + stopifnot(is.character(`color`), length(`color`) == 1) + self$`color` <- `color` + } + if (!is.null(`breed`)) { + stopifnot(is.character(`breed`), length(`breed`) == 1) + self$`breed` <- `breed` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Dog in JSON format + #' @export + toJSON = function() { + DogObject <- list() + if (!is.null(self$`className`)) { + DogObject[["className"]] <- + self$`className` + } + if (!is.null(self$`color`)) { + DogObject[["color"]] <- + self$`color` + } + if (!is.null(self$`breed`)) { + DogObject[["breed"]] <- + self$`breed` + } + + DogObject + }, + #' Deserialize JSON string into an instance of Dog + #' + #' @description + #' Deserialize JSON string into an instance of Dog + #' + #' @param input_json the JSON input + #' @return the instance of Dog + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`className`)) { + self$`className` <- this_object$`className` + } + if (!is.null(this_object$`color`)) { + self$`color` <- this_object$`color` + } + if (!is.null(this_object$`breed`)) { + self$`breed` <- this_object$`breed` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Dog in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`className`)) { + sprintf( + '"className": + "%s" + ', + self$`className` + ) + }, + if (!is.null(self$`color`)) { + sprintf( + '"color": + "%s" + ', + self$`color` + ) + }, + if (!is.null(self$`breed`)) { + sprintf( + '"breed": + "%s" + ', + self$`breed` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Dog + #' + #' @description + #' Deserialize JSON string into an instance of Dog + #' + #' @param input_json the JSON input + #' @return the instance of Dog + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`className` <- this_object$`className` + self$`color` <- this_object$`color` + self$`breed` <- this_object$`breed` + self + }, + #' Validate JSON input with respect to Dog + #' + #' @description + #' Validate JSON input with respect to Dog and throw an exception if invalid + #' + #' @param input the JSON input + #' @export + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + # check the required field `className` + if (!is.null(input_json$`className`)) { + stopifnot(is.character(input_json$`className`), length(input_json$`className`) == 1) + } else { + stop(paste("The JSON input `", input, "` is invalid for Dog: the required field `className` is missing.")) + } + }, + #' To string (JSON format) + #' + #' @description + #' To string (JSON format) + #' + #' @return String representation of Dog + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/dog_all_of.R b/samples/client/petstore/R-httr2/R/dog_all_of.R new file mode 100644 index 000000000000..8f4328feb287 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/dog_all_of.R @@ -0,0 +1,123 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title DogAllOf +#' @description DogAllOf Class +#' @format An \code{R6Class} generator object +#' @field breed character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +DogAllOf <- R6::R6Class( + "DogAllOf", + public = list( + `breed` = NULL, + #' Initialize a new DogAllOf class. + #' + #' @description + #' Initialize a new DogAllOf class. + #' + #' @param breed breed + #' @param ... Other optional arguments. + #' @export + initialize = function( + `breed` = NULL, ... + ) { + if (!is.null(`breed`)) { + stopifnot(is.character(`breed`), length(`breed`) == 1) + self$`breed` <- `breed` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DogAllOf in JSON format + #' @export + toJSON = function() { + DogAllOfObject <- list() + if (!is.null(self$`breed`)) { + DogAllOfObject[["breed"]] <- + self$`breed` + } + + DogAllOfObject + }, + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @description + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @param input_json the JSON input + #' @return the instance of DogAllOf + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`breed`)) { + self$`breed` <- this_object$`breed` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return DogAllOf in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`breed`)) { + sprintf( + '"breed": + "%s" + ', + self$`breed` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @description + #' Deserialize JSON string into an instance of DogAllOf + #' + #' @param input_json the JSON input + #' @return the instance of DogAllOf + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`breed` <- this_object$`breed` + self + }, + #' Validate JSON input with respect to DogAllOf + #' + #' @description + #' Validate JSON input with respect to DogAllOf 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 DogAllOf + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/fake_api.R b/samples/client/petstore/R-httr2/R/fake_api.R new file mode 100644 index 000000000000..cc661d660123 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/fake_api.R @@ -0,0 +1,189 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Fake operations +#' @description petstore.Fake +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ fake_data_file } \emph{ test data_file to ensure it's escaped correctly } +#' +#' +#' \itemize{ +#' \item \emph{ @param } dummy character +#' \item \emph{ @param } var_data_file character +#' \item \emph{ @returnType } \link{User} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : User +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### fake_data_file #################### +#' +#' library(petstore) +#' var.dummy <- "dummy_example" # character | dummy required parameter +#' var.var_data_file <- "var_data_file_example" # character | header data file +#' +#' #test data_file to ensure it's escaped correctly +#' api.instance <- FakeApi$new() +#' +#'result <- tryCatch( +#' api.instance$fake_data_file(var.dummy, var_data_file=var.var_data_file), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @importFrom rlang abort +#' @export +FakeApi <- R6::R6Class( + "FakeApi", + public = list( + api_client = NULL, + #' Initialize a new FakeApi. + #' + #' @description + #' Initialize a new FakeApi. + #' + #' @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 data_file to ensure it's escaped correctly + #' + #' @description + #' test data_file to ensure it's escaped correctly + #' + #' @param dummy dummy required parameter + #' @param var_data_file (optional) header data file + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return User + #' @export + fake_data_file = function(dummy, var_data_file = NULL, data_file = NULL, ...) { + api_response <- self$fake_data_file_with_http_info(dummy, var_data_file, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' test data_file to ensure it's escaped correctly + #' + #' @description + #' test data_file to ensure it's escaped correctly + #' + #' @param dummy dummy required parameter + #' @param var_data_file (optional) header data file + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (User) with additional information such as HTTP status code, headers + #' @export + fake_data_file_with_http_info = function(dummy, var_data_file = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`dummy`)) { + rlang::abort(message = "Missing required parameter `dummy`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `dummy`.")) + } + + body <- NULL + url_path <- "/fake/data_file" + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "User", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/model_api_response.R b/samples/client/petstore/R-httr2/R/model_api_response.R new file mode 100644 index 000000000000..a5b39c53444b --- /dev/null +++ b/samples/client/petstore/R-httr2/R/model_api_response.R @@ -0,0 +1,169 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title ModelApiResponse +#' @description ModelApiResponse Class +#' @format An \code{R6Class} generator object +#' @field code integer [optional] +#' @field type character [optional] +#' @field message character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +ModelApiResponse <- R6::R6Class( + "ModelApiResponse", + public = list( + `code` = NULL, + `type` = NULL, + `message` = NULL, + #' Initialize a new ModelApiResponse class. + #' + #' @description + #' Initialize a new ModelApiResponse class. + #' + #' @param code code + #' @param type type + #' @param message message + #' @param ... Other optional arguments. + #' @export + initialize = function( + `code` = NULL, `type` = NULL, `message` = NULL, ... + ) { + if (!is.null(`code`)) { + stopifnot(is.numeric(`code`), length(`code`) == 1) + self$`code` <- `code` + } + if (!is.null(`type`)) { + stopifnot(is.character(`type`), length(`type`) == 1) + self$`type` <- `type` + } + if (!is.null(`message`)) { + stopifnot(is.character(`message`), length(`message`) == 1) + self$`message` <- `message` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return ModelApiResponse in JSON format + #' @export + toJSON = function() { + ModelApiResponseObject <- list() + if (!is.null(self$`code`)) { + ModelApiResponseObject[["code"]] <- + self$`code` + } + if (!is.null(self$`type`)) { + ModelApiResponseObject[["type"]] <- + self$`type` + } + if (!is.null(self$`message`)) { + ModelApiResponseObject[["message"]] <- + self$`message` + } + + ModelApiResponseObject + }, + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @param input_json the JSON input + #' @return the instance of ModelApiResponse + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`code`)) { + self$`code` <- this_object$`code` + } + if (!is.null(this_object$`type`)) { + self$`type` <- this_object$`type` + } + if (!is.null(this_object$`message`)) { + self$`message` <- this_object$`message` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return ModelApiResponse in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`code`)) { + sprintf( + '"code": + %d + ', + self$`code` + ) + }, + if (!is.null(self$`type`)) { + sprintf( + '"type": + "%s" + ', + self$`type` + ) + }, + if (!is.null(self$`message`)) { + sprintf( + '"message": + "%s" + ', + self$`message` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @description + #' Deserialize JSON string into an instance of ModelApiResponse + #' + #' @param input_json the JSON input + #' @return the instance of ModelApiResponse + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`code` <- this_object$`code` + self$`type` <- this_object$`type` + self$`message` <- this_object$`message` + self + }, + #' Validate JSON input with respect to ModelApiResponse + #' + #' @description + #' Validate JSON input with respect to ModelApiResponse 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 ModelApiResponse + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/nested_one_of.R b/samples/client/petstore/R-httr2/R/nested_one_of.R new file mode 100644 index 000000000000..0c86dbd7075f --- /dev/null +++ b/samples/client/petstore/R-httr2/R/nested_one_of.R @@ -0,0 +1,148 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title NestedOneOf +#' @description NestedOneOf Class +#' @format An \code{R6Class} generator object +#' @field size integer [optional] +#' @field nested_pig \link{Pig} [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +NestedOneOf <- R6::R6Class( + "NestedOneOf", + public = list( + `size` = NULL, + `nested_pig` = NULL, + #' Initialize a new NestedOneOf class. + #' + #' @description + #' Initialize a new NestedOneOf class. + #' + #' @param size size + #' @param nested_pig nested_pig + #' @param ... Other optional arguments. + #' @export + initialize = function( + `size` = NULL, `nested_pig` = NULL, ... + ) { + if (!is.null(`size`)) { + stopifnot(is.numeric(`size`), length(`size`) == 1) + self$`size` <- `size` + } + if (!is.null(`nested_pig`)) { + stopifnot(R6::is.R6(`nested_pig`)) + self$`nested_pig` <- `nested_pig` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return NestedOneOf in JSON format + #' @export + toJSON = function() { + NestedOneOfObject <- list() + if (!is.null(self$`size`)) { + NestedOneOfObject[["size"]] <- + self$`size` + } + if (!is.null(self$`nested_pig`)) { + NestedOneOfObject[["nested_pig"]] <- + self$`nested_pig`$toJSON() + } + + NestedOneOfObject + }, + #' Deserialize JSON string into an instance of NestedOneOf + #' + #' @description + #' Deserialize JSON string into an instance of NestedOneOf + #' + #' @param input_json the JSON input + #' @return the instance of NestedOneOf + #' @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$`nested_pig`)) { + nested_pig_object <- Pig$new() + nested_pig_object$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) + self$`nested_pig` <- nested_pig_object + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return NestedOneOf in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`size`)) { + sprintf( + '"size": + %d + ', + self$`size` + ) + }, + if (!is.null(self$`nested_pig`)) { + sprintf( + '"nested_pig": + %s + ', + jsonlite::toJSON(self$`nested_pig`$toJSON(), auto_unbox = TRUE, digits = NA) + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of NestedOneOf + #' + #' @description + #' Deserialize JSON string into an instance of NestedOneOf + #' + #' @param input_json the JSON input + #' @return the instance of NestedOneOf + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`size` <- this_object$`size` + self$`nested_pig` <- Pig$new()$fromJSON(jsonlite::toJSON(this_object$nested_pig, auto_unbox = TRUE, digits = NA)) + self + }, + #' Validate JSON input with respect to NestedOneOf + #' + #' @description + #' Validate JSON input with respect to NestedOneOf 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 NestedOneOf + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/order.R b/samples/client/petstore/R-httr2/R/order.R new file mode 100644 index 000000000000..3d342c3a4f7d --- /dev/null +++ b/samples/client/petstore/R-httr2/R/order.R @@ -0,0 +1,238 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Order +#' @description Order Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field petId integer [optional] +#' @field quantity integer [optional] +#' @field shipDate character [optional] +#' @field status character [optional] +#' @field complete character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Order <- R6::R6Class( + "Order", + public = list( + `id` = NULL, + `petId` = NULL, + `quantity` = NULL, + `shipDate` = NULL, + `status` = NULL, + `complete` = NULL, + #' Initialize a new Order class. + #' + #' @description + #' Initialize a new Order class. + #' + #' @param id id + #' @param petId petId + #' @param quantity quantity + #' @param shipDate shipDate + #' @param status Order Status + #' @param complete complete. Default to FALSE. + #' @param ... Other optional arguments. + #' @export + initialize = function( + `id` = NULL, `petId` = NULL, `quantity` = NULL, `shipDate` = NULL, `status` = NULL, `complete` = FALSE, ... + ) { + if (!is.null(`id`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + self$`id` <- `id` + } + if (!is.null(`petId`)) { + stopifnot(is.numeric(`petId`), length(`petId`) == 1) + self$`petId` <- `petId` + } + if (!is.null(`quantity`)) { + stopifnot(is.numeric(`quantity`), length(`quantity`) == 1) + self$`quantity` <- `quantity` + } + if (!is.null(`shipDate`)) { + stopifnot(is.character(`shipDate`), length(`shipDate`) == 1) + self$`shipDate` <- `shipDate` + } + if (!is.null(`status`)) { + stopifnot(is.character(`status`), length(`status`) == 1) + self$`status` <- `status` + } + if (!is.null(`complete`)) { + stopifnot(is.logical(`complete`), length(`complete`) == 1) + self$`complete` <- `complete` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Order in JSON format + #' @export + toJSON = function() { + OrderObject <- list() + if (!is.null(self$`id`)) { + OrderObject[["id"]] <- + self$`id` + } + if (!is.null(self$`petId`)) { + OrderObject[["petId"]] <- + self$`petId` + } + if (!is.null(self$`quantity`)) { + OrderObject[["quantity"]] <- + self$`quantity` + } + if (!is.null(self$`shipDate`)) { + OrderObject[["shipDate"]] <- + self$`shipDate` + } + if (!is.null(self$`status`)) { + OrderObject[["status"]] <- + self$`status` + } + if (!is.null(self$`complete`)) { + OrderObject[["complete"]] <- + self$`complete` + } + + OrderObject + }, + #' Deserialize JSON string into an instance of Order + #' + #' @description + #' Deserialize JSON string into an instance of Order + #' + #' @param input_json the JSON input + #' @return the instance of Order + #' @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$`petId`)) { + self$`petId` <- this_object$`petId` + } + if (!is.null(this_object$`quantity`)) { + self$`quantity` <- this_object$`quantity` + } + if (!is.null(this_object$`shipDate`)) { + self$`shipDate` <- this_object$`shipDate` + } + if (!is.null(this_object$`status`)) { + self$`status` <- this_object$`status` + } + if (!is.null(this_object$`complete`)) { + self$`complete` <- this_object$`complete` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Order in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`petId`)) { + sprintf( + '"petId": + %d + ', + self$`petId` + ) + }, + if (!is.null(self$`quantity`)) { + sprintf( + '"quantity": + %d + ', + self$`quantity` + ) + }, + if (!is.null(self$`shipDate`)) { + sprintf( + '"shipDate": + "%s" + ', + self$`shipDate` + ) + }, + if (!is.null(self$`status`)) { + sprintf( + '"status": + "%s" + ', + self$`status` + ) + }, + if (!is.null(self$`complete`)) { + sprintf( + '"complete": + %s + ', + tolower(self$`complete`) + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Order + #' + #' @description + #' Deserialize JSON string into an instance of Order + #' + #' @param input_json the JSON input + #' @return the instance of Order + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`petId` <- this_object$`petId` + self$`quantity` <- this_object$`quantity` + self$`shipDate` <- this_object$`shipDate` + self$`status` <- this_object$`status` + self$`complete` <- this_object$`complete` + self + }, + #' Validate JSON input with respect to Order + #' + #' @description + #' Validate JSON input with respect to Order 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 Order + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/pet.R b/samples/client/petstore/R-httr2/R/pet.R new file mode 100644 index 000000000000..08a0dd66ac57 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/pet.R @@ -0,0 +1,255 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Pet +#' @description Pet Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field category \link{Category} [optional] +#' @field name character +#' @field photoUrls list( character ) +#' @field tags list( \link{Tag} ) [optional] +#' @field status character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Pet <- R6::R6Class( + "Pet", + public = list( + `id` = NULL, + `category` = NULL, + `name` = 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`)) { + stopifnot(is.character(`name`), length(`name`) == 1) + 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`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + 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`)) { + stopifnot(is.character(`status`), length(`status`) == 1) + 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$`category`)) { + PetObject[["category"]] <- + self$`category`$toJSON() + } + if (!is.null(self$`name`)) { + PetObject[["name"]] <- + self$`name` + } + 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$`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$`name`)) { + self$`name` <- this_object$`name` + } + if (!is.null(this_object$`photoUrls`)) { + self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("petstore")) + } + if (!is.null(this_object$`tags`)) { + self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("petstore")) + } + if (!is.null(this_object$`status`)) { + 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$`category`)) { + sprintf( + '"category": + %s + ', + jsonlite::toJSON(self$`category`$toJSON(), auto_unbox = TRUE, digits = NA) + ) + }, + if (!is.null(self$`name`)) { + sprintf( + '"name": + "%s" + ', + self$`name` + ) + }, + 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 = ",") + 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$`category` <- Category$new()$fromJSON(jsonlite::toJSON(this_object$category, auto_unbox = TRUE, digits = NA)) + self$`name` <- this_object$`name` + self$`photoUrls` <- ApiClient$new()$deserializeObj(this_object$`photoUrls`, "array[character]", loadNamespace("petstore")) + self$`tags` <- ApiClient$new()$deserializeObj(this_object$`tags`, "array[Tag]", loadNamespace("petstore")) + 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`)) { + stopifnot(is.character(input_json$`name`), length(input_json$`name`) == 1) + } 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() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R new file mode 100644 index 000000000000..9e146e1fd834 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/pet_api.R @@ -0,0 +1,1449 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Pet operations +#' @description petstore.Pet +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ add_pet } \emph{ Add a new pet to the store } +#' +#' +#' \itemize{ +#' \item \emph{ @param } pet \link{Pet} +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 405 | Invalid input +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ delete_pet } \emph{ Deletes a pet } +#' +#' +#' \itemize{ +#' \item \emph{ @param } pet_id integer +#' \item \emph{ @param } api_key character +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 400 | Invalid pet value +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ find_pets_by_status } \emph{ Finds Pets by status } +#' Multiple status values can be provided with comma separated strings +#' +#' \itemize{ +#' \item \emph{ @param } status Enum < [available, pending, sold] > +#' \item \emph{ @returnType } list( \link{Pet} ) \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : array[Pet] +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid status value +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ find_pets_by_tags } \emph{ Finds Pets by tags } +#' Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +#' +#' \itemize{ +#' \item \emph{ @param } tags list( character ) +#' \item \emph{ @returnType } list( \link{Pet} ) \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : array[Pet] +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid tag value +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ get_pet_by_id } \emph{ Find pet by ID } +#' Returns a single pet +#' +#' \itemize{ +#' \item \emph{ @param } pet_id integer +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid ID supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | Pet not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ get_pet_by_id_streaming } \emph{ Find pet by ID (streaming) } +#' Returns a single pet +#' +#' \itemize{ +#' \item \emph{ @param } pet_id integer +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid ID supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | Pet not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ update_pet } \emph{ Update an existing pet } +#' +#' +#' \itemize{ +#' \item \emph{ @param } pet \link{Pet} +#' \item \emph{ @returnType } \link{Pet} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Pet +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid ID supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | Pet not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 405 | Validation exception +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ update_pet_with_form } \emph{ Updates a pet in the store with form data } +#' +#' +#' \itemize{ +#' \item \emph{ @param } pet_id integer +#' \item \emph{ @param } name character +#' \item \emph{ @param } status character +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 405 | Invalid input +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ upload_file } \emph{ uploads an image } +#' +#' +#' \itemize{ +#' \item \emph{ @param } pet_id integer +#' \item \emph{ @param } additional_metadata character +#' \item \emph{ @param } file data.frame +#' \item \emph{ @returnType } \link{ModelApiResponse} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : ModelApiResponse +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### add_pet #################### +#' +#' library(petstore) +#' var.pet <- Pet$new() # Pet | Pet object that needs to be added to the store +#' +#' #Add a new pet to the store +#' api.instance <- PetApi$new() +#' +#' #Configure HTTP basic authorization: http_auth +#' # provide the username +#' api.instance$api_client$username <- 'TODO_YOUR_USERNAME'; +#' # provide the password +#' api.instance$api_client$password <- 'TODO_YOUR_PASSWORD'; +#' +#'result <- tryCatch( +#' api.instance$add_pet(var.pet), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### delete_pet #################### +#' +#' library(petstore) +#' var.pet_id <- 56 # integer | Pet id to delete +#' var.api_key <- "api_key_example" # character | +#' +#' #Deletes a pet +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$delete_pet(var.pet_id, api_key=var.api_key), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### find_pets_by_status #################### +#' +#' library(petstore) +#' var.status <- ["status_example"] # array[character] | Status values that need to be considered for filter +#' +#' #Finds Pets by status +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$find_pets_by_status(var.status), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### find_pets_by_tags #################### +#' +#' library(petstore) +#' var.tags <- ["tags_example"] # array[character] | Tags to filter by +#' +#' #Finds Pets by tags +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$find_pets_by_tags(var.tags), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### get_pet_by_id #################### +#' +#' library(petstore) +#' var.pet_id <- 56 # integer | ID of pet to return +#' +#' #Find pet by ID +#' api.instance <- PetApi$new() +#' +#' #Configure HTTP bearer authorization: BearerToken +#' api.instance$api_client$bearer_token <- 'TODO_YOUR_BEARER_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$get_pet_by_id(var.pet_id), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### get_pet_by_id_streaming #################### +#' +#' library(petstore) +#' var.pet_id <- 56 # integer | ID of pet to return +#' +#' #Find pet by ID (streaming) +#' api.instance <- PetApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$get_pet_by_id_streaming(var.pet_id), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### update_pet #################### +#' +#' library(petstore) +#' var.pet <- Pet$new() # Pet | Pet object that needs to be added to the store +#' +#' #Update an existing pet +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$update_pet(var.pet), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### update_pet_with_form #################### +#' +#' library(petstore) +#' var.pet_id <- 56 # integer | ID of pet that needs to be updated +#' var.name <- "name_example" # character | Updated name of the pet +#' var.status <- "status_example" # character | Updated status of the pet +#' +#' #Updates a pet in the store with form data +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$update_pet_with_form(var.pet_id, name=var.name, status=var.status), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### upload_file #################### +#' +#' library(petstore) +#' var.pet_id <- 56 # integer | ID of pet to update +#' var.additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server +#' var.file <- File.new('/path/to/file') # data.frame | file to upload +#' +#' #uploads an image +#' api.instance <- PetApi$new() +#' +#' # Configure OAuth2 access token for authorization: petstore_auth +#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +#' +#'result <- tryCatch( +#' api.instance$upload_file(var.pet_id, additional_metadata=var.additional_metadata, file=var.file), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @importFrom rlang abort +#' @export +PetApi <- R6::R6Class( + "PetApi", + public = list( + api_client = NULL, + #' Initialize a new PetApi. + #' + #' @description + #' Initialize a new PetApi. + #' + #' @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() + } + }, + #' Add a new pet to the store + #' + #' @description + #' Add a new pet to the store + #' + #' @param pet 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 + add_pet = function(pet, data_file = NULL, ...) { + api_response <- self$add_pet_with_http_info(pet, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Add a new pet to the store + #' + #' @description + #' Add a new pet to the store + #' + #' @param pet 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 + add_pet_with_http_info = function(pet, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet`)) { + rlang::abort(message = "Missing required parameter `pet`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet`.")) + } + + if (!missing(`pet`)) { + body <- `pet`$toJSONString() + } else { + body <- NULL + } + + url_path <- "/pet" + # HTTP basic auth + header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":")))) + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Deletes a pet + #' + #' @description + #' Deletes a pet + #' + #' @param pet_id Pet id to delete + #' @param api_key (optional) No description + #' @param ... Other optional arguments + #' @return void + #' @export + delete_pet = function(pet_id, api_key = NULL, ...) { + api_response <- self$delete_pet_with_http_info(pet_id, api_key, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Deletes a pet + #' + #' @description + #' Deletes a pet + #' + #' @param pet_id Pet id to delete + #' @param api_key (optional) No description + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + delete_pet_with_http_info = function(pet_id, api_key = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet_id`)) { + rlang::abort(message = "Missing required parameter `pet_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet_id`.")) + } + + body <- NULL + url_path <- "/pet/{petId}?streaming" + if (!missing(`pet_id`)) { + url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path) + } + + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "DELETE", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Finds Pets by status + #' + #' @description + #' Finds Pets by status + #' + #' @param status Status values that need to be considered for filter + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return array[Pet] + #' @export + find_pets_by_status = function(status, data_file = NULL, ...) { + api_response <- self$find_pets_by_status_with_http_info(status, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Finds Pets by status + #' + #' @description + #' Finds Pets by status + #' + #' @param status Status values that need to be considered for filter + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (array[Pet]) with additional information such as HTTP status code, headers + #' @export + find_pets_by_status_with_http_info = function(status, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`status`)) { + rlang::abort(message = "Missing required parameter `status`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `status`.")) + } + + body <- NULL + url_path <- "/pet/findByStatus" + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Finds Pets by tags + #' + #' @description + #' Finds Pets by tags + #' + #' @param tags Tags to filter by + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return array[Pet] + #' @export + find_pets_by_tags = function(tags, data_file = NULL, ...) { + api_response <- self$find_pets_by_tags_with_http_info(tags, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Finds Pets by tags + #' + #' @description + #' Finds Pets by tags + #' + #' @param tags Tags to filter by + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (array[Pet]) with additional information such as HTTP status code, headers + #' @export + find_pets_by_tags_with_http_info = function(tags, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`tags`)) { + rlang::abort(message = "Missing required parameter `tags`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `tags`.")) + } + + body <- NULL + url_path <- "/pet/findByTags" + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Find pet by ID + #' + #' @description + #' Find pet by ID + #' + #' @param pet_id ID of pet to return + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Pet + #' @export + get_pet_by_id = function(pet_id, data_file = NULL, ...) { + api_response <- self$get_pet_by_id_with_http_info(pet_id, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Find pet by ID + #' + #' @description + #' Find pet by ID + #' + #' @param pet_id ID of pet to return + #' @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 + get_pet_by_id_with_http_info = function(pet_id, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet_id`)) { + rlang::abort(message = "Missing required parameter `pet_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet_id`.")) + } + + body <- NULL + url_path <- "/pet/{petId}" + if (!missing(`pet_id`)) { + url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path) + } + + header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Find pet by ID (streaming) + #' + #' @description + #' Find pet by ID (streaming) + #' + #' @param pet_id ID of pet to return + #' @param stream_callback (optional) callback function to process the data stream + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Pet + #' @export + get_pet_by_id_streaming = function(pet_id, stream_callback = NULL, data_file = NULL, ...) { + api_response <- self$get_pet_by_id_streaming_with_http_info(pet_id, stream_callback = stream_callback, data_file = data_file, ...) + if (typeof(stream_callback) == "closure") { # return void if streaming is enabled + return(invisible(NULL)) + } + + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Find pet by ID (streaming) + #' + #' @description + #' Find pet by ID (streaming) + #' + #' @param pet_id ID of pet to return + #' @param stream_callback (optional) callback function to process the data stream + #' @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 + get_pet_by_id_streaming_with_http_info = function(pet_id, stream_callback = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet_id`)) { + rlang::abort(message = "Missing required parameter `pet_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet_id`.")) + } + + body <- NULL + url_path <- "/pet/{petId}?streaming" + if (!missing(`pet_id`)) { + url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path) + } + + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + stream_callback = stream_callback, + ...) + + if (typeof(stream_callback) == "closure") { # return void if streaming is enabled + return(invisible(NULL)) + } + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Update an existing pet + #' + #' @description + #' Update an existing pet + #' + #' @param pet 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 + update_pet = function(pet, data_file = NULL, ...) { + api_response <- self$update_pet_with_http_info(pet, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Update an existing pet + #' + #' @description + #' Update an existing pet + #' + #' @param pet 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 + update_pet_with_http_info = function(pet, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet`)) { + rlang::abort(message = "Missing required parameter `pet`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet`.")) + } + + if (!missing(`pet`)) { + body <- `pet`$toJSONString() + } else { + body <- NULL + } + + url_path <- "/pet" + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "PUT", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Updates a pet in the store with form data + #' + #' @description + #' Updates a pet in the store with form data + #' + #' @param pet_id ID of pet that needs to be updated + #' @param name (optional) Updated name of the pet + #' @param status (optional) Updated status of the pet + #' @param ... Other optional arguments + #' @return void + #' @export + update_pet_with_form = function(pet_id, name = NULL, status = NULL, ...) { + api_response <- self$update_pet_with_form_with_http_info(pet_id, name, status, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Updates a pet in the store with form data + #' + #' @description + #' Updates a pet in the store with form data + #' + #' @param pet_id ID of pet that needs to be updated + #' @param name (optional) Updated name of the pet + #' @param status (optional) Updated status of the pet + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + update_pet_with_form_with_http_info = function(pet_id, name = NULL, status = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet_id`)) { + rlang::abort(message = "Missing required parameter `pet_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet_id`.")) + } + + body <- list( + "name" = name, + "status" = status + ) + + url_path <- "/pet/{petId}?streaming" + if (!missing(`pet_id`)) { + url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path) + } + + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' uploads an image + #' + #' @description + #' uploads an image + #' + #' @param pet_id ID of pet to update + #' @param additional_metadata (optional) Additional data to pass to server + #' @param file (optional) file to upload + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return ModelApiResponse + #' @export + upload_file = function(pet_id, additional_metadata = NULL, file = NULL, data_file = NULL, ...) { + api_response <- self$upload_file_with_http_info(pet_id, additional_metadata, file, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' uploads an image + #' + #' @description + #' uploads an image + #' + #' @param pet_id ID of pet to update + #' @param additional_metadata (optional) Additional data to pass to server + #' @param file (optional) file to upload + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (ModelApiResponse) with additional information such as HTTP status code, headers + #' @export + upload_file_with_http_info = function(pet_id, additional_metadata = NULL, file = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`pet_id`)) { + rlang::abort(message = "Missing required parameter `pet_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `pet_id`.")) + } + + body <- list( + "additionalMetadata" = additional_metadata, + "file" = httr::upload_file(file) + ) + + url_path <- "/pet/{petId}/uploadImage" + if (!missing(`pet_id`)) { + url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path) + } + + # OAuth token + header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ") + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/pig.R b/samples/client/petstore/R-httr2/R/pig.R new file mode 100644 index 000000000000..5bc21e1c6fa3 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/pig.R @@ -0,0 +1,173 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Pig +#' +#' @description Pig Class +#' +#' @format An \code{R6Class} generator object +#' +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Pig <- R6::R6Class( + "Pig", + public = list( + #' @field actual_instance the object stored in this instance. + actual_instance = NULL, + #' @field actual_type the type of the object stored in this instance. + actual_type = NULL, + #' @field one_of a list of object types defined in the oneOf schema. + one_of = list("BasquePig", "DanishPig"), + #' Initialize a new Pig. + #' + #' @description + #' Initialize a new Pig. + #' + #' @param instance an instance of the object defined in the oneOf schemas: "BasquePig", "DanishPig" + #' @export + initialize = function(instance = NULL) { + if (is.null(instance)) { + # do nothing + } else if (get(class(instance)[[1]], pos = -1)$classname == "BasquePig") { + self$actual_instance <- instance + self$actual_type <- "BasquePig" + } else if (get(class(instance)[[1]], pos = -1)$classname == "DanishPig") { + self$actual_instance <- instance + self$actual_type <- "DanishPig" + } else { + stop(paste("Failed to initialize Pig with oneOf schemas BasquePig, DanishPig. Provided class name: ", + get(class(instance)[[1]], pos = -1)$classname)) + } + }, + #' Deserialize JSON string into an instance of Pig. + #' + #' @description + #' Deserialize JSON string into an instance of Pig. + #' + #' @param input The input JSON. + #' @return An instance of Pig. + #' @export + fromJSON = function(input) { + matched <- 0 # match counter + matched_schemas <- list() #names of matched schemas + error_messages <- list() + instance <- NULL + + BasquePig_result <- tryCatch({ + BasquePig$public_methods$validateJSON(input) + BasquePig_instance <- BasquePig$new() + instance <- BasquePig_instance$fromJSON(input) + instance_type <- "BasquePig" + matched_schemas <- append(matched_schemas, "BasquePig") + matched <- matched + 1 + }, + error = function(err) err + ) + + if (!is.null(BasquePig_result["error"])) { + error_messages <- append(error_messages, BasquePig_result["message"]) + } + + DanishPig_result <- tryCatch({ + DanishPig$public_methods$validateJSON(input) + DanishPig_instance <- DanishPig$new() + instance <- DanishPig_instance$fromJSON(input) + instance_type <- "DanishPig" + matched_schemas <- append(matched_schemas, "DanishPig") + matched <- matched + 1 + }, + error = function(err) err + ) + + if (!is.null(DanishPig_result["error"])) { + error_messages <- append(error_messages, DanishPig_result["message"]) + } + + if (matched == 1) { + # successfully match exactly 1 schema specified in oneOf + self$actual_instance <- instance + self$actual_type <- instance_type + } else if (matched > 1) { + # more than 1 match + stop("Multiple matches found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig.") + } else { + # no match + stop(paste("No match found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. Details: ", + paste(error_messages, collapse = ", "))) + } + + self + }, + #' Serialize Pig to JSON string. + #' + #' @description + #' Serialize Pig to JSON string. + #' + #' @return JSON string representation of the Pig. + #' @export + toJSONString = function() { + if (!is.null(self$actual_instance)) { + as.character(jsonlite::minify(self$actual_instance$toJSONString())) + } else { + NULL + } + }, + #' Serialize Pig to JSON. + #' + #' @description + #' Serialize Pig to JSON. + #' + #' @return JSON representation of the Pig. + #' @export + toJSON = function() { + if (!is.null(self$actual_instance)) { + self$actual_instance$toJSON() + } else { + NULL + } + }, + #' Validate the input JSON with respect to Pig. + #' + #' @description + #' Validate the input JSON with respect to Pig and + #' throw exception if invalid. + #' + #' @param input The input JSON. + #' @export + validateJSON = function(input) { + # backup current values + actual_instance_bak <- self$actual_instance + actual_type_bak <- self$actual_type + + # if it's not valid, an error will be thrown + self$fromJSON(input) + + # no error thrown, restore old values + self$actual_instance <- actual_instance_bak + self$actual_type <- actual_type_bak + }, + #' Returns the string representation of the instance. + #' + #' @description + #' Returns the string representation of the instance. + #' + #' @return The string representation of the instance. + #' @export + toString = function() { + jsoncontent <- c( + sprintf('"actual_instance": %s', if (is.null(self$actual_instance)) NULL else self$actual_instance$toJSONString()), + sprintf('"actual_type": "%s"', self$actual_type), + sprintf('"one_of": "%s"', paste(unlist(self$one_of), collapse = ", ")) + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::prettify(paste("{", jsoncontent, "}", sep = ""))) + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/special.R b/samples/client/petstore/R-httr2/R/special.R new file mode 100644 index 000000000000..0680b7f193d0 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/special.R @@ -0,0 +1,238 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Special +#' @description Special Class +#' @format An \code{R6Class} generator object +#' @field item_self integer [optional] +#' @field item_private character [optional] +#' @field item_super character [optional] +#' @field 123_number character [optional] +#' @field array[test] character [optional] +#' @field empty_string character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +Special <- R6::R6Class( + "Special", + public = list( + `item_self` = NULL, + `item_private` = NULL, + `item_super` = NULL, + `123_number` = NULL, + `array[test]` = NULL, + `empty_string` = NULL, + #' Initialize a new Special class. + #' + #' @description + #' Initialize a new Special class. + #' + #' @param item_self item_self + #' @param item_private item_private + #' @param item_super item_super + #' @param 123_number 123_number + #' @param array[test] array[test] + #' @param empty_string empty_string + #' @param ... Other optional arguments. + #' @export + initialize = function( + `item_self` = NULL, `item_private` = NULL, `item_super` = NULL, `123_number` = NULL, `array[test]` = NULL, `empty_string` = NULL, ... + ) { + if (!is.null(`item_self`)) { + stopifnot(is.numeric(`item_self`), length(`item_self`) == 1) + self$`item_self` <- `item_self` + } + if (!is.null(`item_private`)) { + stopifnot(is.character(`item_private`), length(`item_private`) == 1) + self$`item_private` <- `item_private` + } + if (!is.null(`item_super`)) { + stopifnot(is.character(`item_super`), length(`item_super`) == 1) + self$`item_super` <- `item_super` + } + if (!is.null(`123_number`)) { + stopifnot(is.character(`123_number`), length(`123_number`) == 1) + self$`123_number` <- `123_number` + } + if (!is.null(`array[test]`)) { + stopifnot(is.character(`array[test]`), length(`array[test]`) == 1) + self$`array[test]` <- `array[test]` + } + if (!is.null(`empty_string`)) { + stopifnot(is.character(`empty_string`), length(`empty_string`) == 1) + self$`empty_string` <- `empty_string` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Special in JSON format + #' @export + toJSON = function() { + SpecialObject <- list() + if (!is.null(self$`item_self`)) { + SpecialObject[["self"]] <- + self$`item_self` + } + if (!is.null(self$`item_private`)) { + SpecialObject[["private"]] <- + self$`item_private` + } + if (!is.null(self$`item_super`)) { + SpecialObject[["super"]] <- + self$`item_super` + } + if (!is.null(self$`123_number`)) { + SpecialObject[["123_number"]] <- + self$`123_number` + } + if (!is.null(self$`array[test]`)) { + SpecialObject[["array[test]"]] <- + self$`array[test]` + } + if (!is.null(self$`empty_string`)) { + SpecialObject[["empty_string"]] <- + self$`empty_string` + } + + SpecialObject + }, + #' Deserialize JSON string into an instance of Special + #' + #' @description + #' Deserialize JSON string into an instance of Special + #' + #' @param input_json the JSON input + #' @return the instance of Special + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`self`)) { + self$`item_self` <- this_object$`self` + } + if (!is.null(this_object$`private`)) { + self$`item_private` <- this_object$`private` + } + if (!is.null(this_object$`super`)) { + self$`item_super` <- this_object$`super` + } + if (!is.null(this_object$`123_number`)) { + self$`123_number` <- this_object$`123_number` + } + if (!is.null(this_object$`array[test]`)) { + self$`array[test]` <- this_object$`array[test]` + } + if (!is.null(this_object$`empty_string`)) { + self$`empty_string` <- this_object$`empty_string` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return Special in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`item_self`)) { + sprintf( + '"self": + %d + ', + self$`item_self` + ) + }, + if (!is.null(self$`item_private`)) { + sprintf( + '"private": + "%s" + ', + self$`item_private` + ) + }, + if (!is.null(self$`item_super`)) { + sprintf( + '"super": + "%s" + ', + self$`item_super` + ) + }, + if (!is.null(self$`123_number`)) { + sprintf( + '"123_number": + "%s" + ', + self$`123_number` + ) + }, + if (!is.null(self$`array[test]`)) { + sprintf( + '"array[test]": + "%s" + ', + self$`array[test]` + ) + }, + if (!is.null(self$`empty_string`)) { + sprintf( + '"empty_string": + "%s" + ', + self$`empty_string` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of Special + #' + #' @description + #' Deserialize JSON string into an instance of Special + #' + #' @param input_json the JSON input + #' @return the instance of Special + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`item_self` <- this_object$`item_self` + self$`item_private` <- this_object$`item_private` + self$`item_super` <- this_object$`item_super` + self$`123_number` <- this_object$`123_number` + self$`array[test]` <- this_object$`array[test]` + self$`empty_string` <- this_object$`empty_string` + self + }, + #' Validate JSON input with respect to Special + #' + #' @description + #' Validate JSON input with respect to Special 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 Special + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/store_api.R b/samples/client/petstore/R-httr2/R/store_api.R new file mode 100644 index 000000000000..ff44b2857726 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/store_api.R @@ -0,0 +1,620 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title Store operations +#' @description petstore.Store +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ delete_order } \emph{ Delete purchase order by ID } +#' For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +#' +#' \itemize{ +#' \item \emph{ @param } order_id character +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 400 | Invalid ID supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | Order not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ get_inventory } \emph{ Returns pet inventories by status } +#' Returns a map of status codes to quantities +#' +#' \itemize{ +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : map(integer) +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ get_order_by_id } \emph{ Find purchase order by ID } +#' For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +#' +#' \itemize{ +#' \item \emph{ @param } order_id integer +#' \item \emph{ @returnType } \link{Order} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Order +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid ID supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | Order not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ place_order } \emph{ Place an order for a pet } +#' +#' +#' \itemize{ +#' \item \emph{ @param } order \link{Order} +#' \item \emph{ @returnType } \link{Order} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : Order +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid Order +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### delete_order #################### +#' +#' library(petstore) +#' var.order_id <- "order_id_example" # character | ID of the order that needs to be deleted +#' +#' #Delete purchase order by ID +#' api.instance <- StoreApi$new() +#' +#'result <- tryCatch( +#' api.instance$delete_order(var.order_id), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### get_inventory #################### +#' +#' library(petstore) +#' +#' #Returns pet inventories by status +#' api.instance <- StoreApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$get_inventory(), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### get_order_by_id #################### +#' +#' library(petstore) +#' var.order_id <- 56 # integer | ID of pet that needs to be fetched +#' +#' #Find purchase order by ID +#' api.instance <- StoreApi$new() +#' +#'result <- tryCatch( +#' api.instance$get_order_by_id(var.order_id), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### place_order #################### +#' +#' library(petstore) +#' var.order <- Order$new() # Order | order placed for purchasing the pet +#' +#' #Place an order for a pet +#' api.instance <- StoreApi$new() +#' +#'result <- tryCatch( +#' api.instance$place_order(var.order), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @importFrom rlang abort +#' @export +StoreApi <- R6::R6Class( + "StoreApi", + public = list( + api_client = NULL, + #' Initialize a new StoreApi. + #' + #' @description + #' Initialize a new StoreApi. + #' + #' @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() + } + }, + #' Delete purchase order by ID + #' + #' @description + #' Delete purchase order by ID + #' + #' @param order_id ID of the order that needs to be deleted + #' @param ... Other optional arguments + #' @return void + #' @export + delete_order = function(order_id, ...) { + api_response <- self$delete_order_with_http_info(order_id, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Delete purchase order by ID + #' + #' @description + #' Delete purchase order by ID + #' + #' @param order_id ID of the order that needs to be deleted + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + delete_order_with_http_info = function(order_id, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`order_id`)) { + rlang::abort(message = "Missing required parameter `order_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `order_id`.")) + } + + body <- NULL + url_path <- "/store/order/{orderId}" + if (!missing(`order_id`)) { + url_path <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), url_path) + } + + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "DELETE", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Returns pet inventories by status + #' + #' @description + #' Returns pet inventories by status + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return map(integer) + #' @export + get_inventory = function(data_file = NULL, ...) { + api_response <- self$get_inventory_with_http_info(data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Returns pet inventories by status + #' + #' @description + #' Returns pet inventories by status + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (map(integer)) with additional information such as HTTP status code, headers + #' @export + get_inventory_with_http_info = function(data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + body <- NULL + url_path <- "/store/inventory" + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "map(integer)", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Find purchase order by ID + #' + #' @description + #' Find purchase order by ID + #' + #' @param order_id ID of pet that needs to be fetched + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Order + #' @export + get_order_by_id = function(order_id, data_file = NULL, ...) { + api_response <- self$get_order_by_id_with_http_info(order_id, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Find purchase order by ID + #' + #' @description + #' Find purchase order by ID + #' + #' @param order_id ID of pet that needs to be fetched + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (Order) with additional information such as HTTP status code, headers + #' @export + get_order_by_id_with_http_info = function(order_id, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`order_id`)) { + rlang::abort(message = "Missing required parameter `order_id`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `order_id`.")) + } + + body <- NULL + url_path <- "/store/order/{orderId}" + if (!missing(`order_id`)) { + url_path <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), url_path) + } + + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Order", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Place an order for a pet + #' + #' @description + #' Place an order for a pet + #' + #' @param order order placed for purchasing the pet + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return Order + #' @export + place_order = function(order, data_file = NULL, ...) { + api_response <- self$place_order_with_http_info(order, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Place an order for a pet + #' + #' @description + #' Place an order for a pet + #' + #' @param order order placed for purchasing the pet + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (Order) with additional information such as HTTP status code, headers + #' @export + place_order_with_http_info = function(order, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`order`)) { + rlang::abort(message = "Missing required parameter `order`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `order`.")) + } + + if (!missing(`order`)) { + body <- `order`$toJSONString() + } else { + body <- NULL + } + + url_path <- "/store/order" + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "Order", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/tag.R b/samples/client/petstore/R-httr2/R/tag.R new file mode 100644 index 000000000000..015063f71917 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/tag.R @@ -0,0 +1,146 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @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`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + self$`id` <- `id` + } + if (!is.null(`name`)) { + stopifnot(is.character(`name`), length(`name`) == 1) + 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 = ",") + 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() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/update_pet_request.R b/samples/client/petstore/R-httr2/R/update_pet_request.R new file mode 100644 index 000000000000..de949b175ca3 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/update_pet_request.R @@ -0,0 +1,147 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title UpdatePetRequest +#' @description UpdatePetRequest Class +#' @format An \code{R6Class} generator object +#' @field jsonData \link{Pet} [optional] +#' @field binaryDataN2Information data.frame [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +UpdatePetRequest <- R6::R6Class( + "UpdatePetRequest", + public = list( + `jsonData` = NULL, + `binaryDataN2Information` = NULL, + #' Initialize a new UpdatePetRequest class. + #' + #' @description + #' Initialize a new UpdatePetRequest class. + #' + #' @param jsonData jsonData + #' @param binaryDataN2Information binaryDataN2Information + #' @param ... Other optional arguments. + #' @export + initialize = function( + `jsonData` = NULL, `binaryDataN2Information` = NULL, ... + ) { + if (!is.null(`jsonData`)) { + stopifnot(R6::is.R6(`jsonData`)) + self$`jsonData` <- `jsonData` + } + if (!is.null(`binaryDataN2Information`)) { + self$`binaryDataN2Information` <- `binaryDataN2Information` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return UpdatePetRequest in JSON format + #' @export + toJSON = function() { + UpdatePetRequestObject <- list() + if (!is.null(self$`jsonData`)) { + UpdatePetRequestObject[["jsonData"]] <- + self$`jsonData`$toJSON() + } + if (!is.null(self$`binaryDataN2Information`)) { + UpdatePetRequestObject[["binaryDataN2Information"]] <- + self$`binaryDataN2Information` + } + + UpdatePetRequestObject + }, + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @description + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @param input_json the JSON input + #' @return the instance of UpdatePetRequest + #' @export + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`jsonData`)) { + jsondata_object <- Pet$new() + jsondata_object$fromJSON(jsonlite::toJSON(this_object$jsonData, auto_unbox = TRUE, digits = NA)) + self$`jsonData` <- jsondata_object + } + if (!is.null(this_object$`binaryDataN2Information`)) { + self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return UpdatePetRequest in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`jsonData`)) { + sprintf( + '"jsonData": + %s + ', + jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox = TRUE, digits = NA) + ) + }, + if (!is.null(self$`binaryDataN2Information`)) { + sprintf( + '"binaryDataN2Information": + "%s" + ', + self$`binaryDataN2Information` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @description + #' Deserialize JSON string into an instance of UpdatePetRequest + #' + #' @param input_json the JSON input + #' @return the instance of UpdatePetRequest + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`jsonData` <- Pet$new()$fromJSON(jsonlite::toJSON(this_object$jsonData, auto_unbox = TRUE, digits = NA)) + self$`binaryDataN2Information` <- this_object$`binaryDataN2Information` + self + }, + #' Validate JSON input with respect to UpdatePetRequest + #' + #' @description + #' Validate JSON input with respect to UpdatePetRequest 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 UpdatePetRequest + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/user.R b/samples/client/petstore/R-httr2/R/user.R new file mode 100644 index 000000000000..541b1ba03326 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/user.R @@ -0,0 +1,284 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title User +#' @description User Class +#' @format An \code{R6Class} generator object +#' @field id integer [optional] +#' @field username character [optional] +#' @field firstName character [optional] +#' @field lastName character [optional] +#' @field email character [optional] +#' @field password character [optional] +#' @field phone character [optional] +#' @field userStatus integer [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +User <- R6::R6Class( + "User", + public = list( + `id` = NULL, + `username` = NULL, + `firstName` = NULL, + `lastName` = NULL, + `email` = NULL, + `password` = NULL, + `phone` = NULL, + `userStatus` = NULL, + #' Initialize a new User class. + #' + #' @description + #' Initialize a new User class. + #' + #' @param id id + #' @param username username + #' @param firstName firstName + #' @param lastName lastName + #' @param email email + #' @param password password + #' @param phone phone + #' @param userStatus User Status + #' @param ... Other optional arguments. + #' @export + initialize = function( + `id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ... + ) { + if (!is.null(`id`)) { + stopifnot(is.numeric(`id`), length(`id`) == 1) + self$`id` <- `id` + } + if (!is.null(`username`)) { + stopifnot(is.character(`username`), length(`username`) == 1) + self$`username` <- `username` + } + if (!is.null(`firstName`)) { + stopifnot(is.character(`firstName`), length(`firstName`) == 1) + self$`firstName` <- `firstName` + } + if (!is.null(`lastName`)) { + stopifnot(is.character(`lastName`), length(`lastName`) == 1) + self$`lastName` <- `lastName` + } + if (!is.null(`email`)) { + stopifnot(is.character(`email`), length(`email`) == 1) + self$`email` <- `email` + } + if (!is.null(`password`)) { + stopifnot(is.character(`password`), length(`password`) == 1) + self$`password` <- `password` + } + if (!is.null(`phone`)) { + stopifnot(is.character(`phone`), length(`phone`) == 1) + self$`phone` <- `phone` + } + if (!is.null(`userStatus`)) { + stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1) + self$`userStatus` <- `userStatus` + } + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return User in JSON format + #' @export + toJSON = function() { + UserObject <- list() + if (!is.null(self$`id`)) { + UserObject[["id"]] <- + self$`id` + } + if (!is.null(self$`username`)) { + UserObject[["username"]] <- + self$`username` + } + if (!is.null(self$`firstName`)) { + UserObject[["firstName"]] <- + self$`firstName` + } + if (!is.null(self$`lastName`)) { + UserObject[["lastName"]] <- + self$`lastName` + } + if (!is.null(self$`email`)) { + UserObject[["email"]] <- + self$`email` + } + if (!is.null(self$`password`)) { + UserObject[["password"]] <- + self$`password` + } + if (!is.null(self$`phone`)) { + UserObject[["phone"]] <- + self$`phone` + } + if (!is.null(self$`userStatus`)) { + UserObject[["userStatus"]] <- + self$`userStatus` + } + + UserObject + }, + #' Deserialize JSON string into an instance of User + #' + #' @description + #' Deserialize JSON string into an instance of User + #' + #' @param input_json the JSON input + #' @return the instance of User + #' @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$`username`)) { + self$`username` <- this_object$`username` + } + if (!is.null(this_object$`firstName`)) { + self$`firstName` <- this_object$`firstName` + } + if (!is.null(this_object$`lastName`)) { + self$`lastName` <- this_object$`lastName` + } + if (!is.null(this_object$`email`)) { + self$`email` <- this_object$`email` + } + if (!is.null(this_object$`password`)) { + self$`password` <- this_object$`password` + } + if (!is.null(this_object$`phone`)) { + self$`phone` <- this_object$`phone` + } + if (!is.null(this_object$`userStatus`)) { + self$`userStatus` <- this_object$`userStatus` + } + self + }, + #' To JSON string + #' + #' @description + #' To JSON String + #' + #' @return User in JSON format + #' @export + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`id`)) { + sprintf( + '"id": + %d + ', + self$`id` + ) + }, + if (!is.null(self$`username`)) { + sprintf( + '"username": + "%s" + ', + self$`username` + ) + }, + if (!is.null(self$`firstName`)) { + sprintf( + '"firstName": + "%s" + ', + self$`firstName` + ) + }, + if (!is.null(self$`lastName`)) { + sprintf( + '"lastName": + "%s" + ', + self$`lastName` + ) + }, + if (!is.null(self$`email`)) { + sprintf( + '"email": + "%s" + ', + self$`email` + ) + }, + if (!is.null(self$`password`)) { + sprintf( + '"password": + "%s" + ', + self$`password` + ) + }, + if (!is.null(self$`phone`)) { + sprintf( + '"phone": + "%s" + ', + self$`phone` + ) + }, + if (!is.null(self$`userStatus`)) { + sprintf( + '"userStatus": + %d + ', + self$`userStatus` + ) + } + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) + }, + #' Deserialize JSON string into an instance of User + #' + #' @description + #' Deserialize JSON string into an instance of User + #' + #' @param input_json the JSON input + #' @return the instance of User + #' @export + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`id` <- this_object$`id` + self$`username` <- this_object$`username` + self$`firstName` <- this_object$`firstName` + self$`lastName` <- this_object$`lastName` + self$`email` <- this_object$`email` + self$`password` <- this_object$`password` + self$`phone` <- this_object$`phone` + self$`userStatus` <- this_object$`userStatus` + self + }, + #' Validate JSON input with respect to User + #' + #' @description + #' Validate JSON input with respect to User 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 User + #' @export + toString = function() { + self$toJSONString() + } + ) +) diff --git a/samples/client/petstore/R-httr2/R/user_api.R b/samples/client/petstore/R-httr2/R/user_api.R new file mode 100644 index 000000000000..f7c212deedf3 --- /dev/null +++ b/samples/client/petstore/R-httr2/R/user_api.R @@ -0,0 +1,1178 @@ +#' OpenAPI Petstore +#' +#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +#' +#' The version of the OpenAPI document: 1.0.0 +#' Generated by: https://openapi-generator.tech +#' + +#' @docType class +#' @title User operations +#' @description petstore.User +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @section Methods: +#' \describe{ +#' \strong{ create_user } \emph{ Create user } +#' This can only be done by the logged in user. +#' +#' \itemize{ +#' \item \emph{ @param } user \link{User} +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 0 | successful operation +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ create_users_with_array_input } \emph{ Creates list of users with given input array } +#' +#' +#' \itemize{ +#' \item \emph{ @param } user list( \link{User} ) +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 0 | successful operation +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ create_users_with_list_input } \emph{ Creates list of users with given input array } +#' +#' +#' \itemize{ +#' \item \emph{ @param } user list( \link{User} ) +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 0 | successful operation +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ delete_user } \emph{ Delete user } +#' This can only be done by the logged in user. +#' +#' \itemize{ +#' \item \emph{ @param } username character +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 400 | Invalid username supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | User not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ get_user_by_name } \emph{ Get user by user name } +#' +#' +#' \itemize{ +#' \item \emph{ @param } username character +#' \item \emph{ @returnType } \link{User} \cr +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : User +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 400 | Invalid username supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | User not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ login_user } \emph{ Logs user into the system } +#' +#' +#' \itemize{ +#' \item \emph{ @param } username character +#' \item \emph{ @param } password character +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 200 | successful operation +#' +#' \item return type : character +#' \item response headers : +#' +#' \tabular{ll}{ +#' Set-Cookie \tab Cookie authentication key for use with the `api_key` apiKey authentication. \cr +#' X-Rate-Limit \tab calls per hour allowed by the user \cr +#' X-Expires-After \tab date in UTC when token expires \cr +#' } +#' \item status code : 400 | Invalid username/password supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ logout_user } \emph{ Logs out current logged in user session } +#' +#' +#' \itemize{ +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 0 | successful operation +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' \strong{ update_user } \emph{ Updated user } +#' This can only be done by the logged in user. +#' +#' \itemize{ +#' \item \emph{ @param } username character +#' \item \emph{ @param } user \link{User} +#' +#' \item On encountering errors, an error of subclass ApiException will be thrown. +#' +#' \item status code : 400 | Invalid user supplied +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' \item status code : 404 | User not found +#' +#' +#' \item response headers : +#' +#' \tabular{ll}{ +#' } +#' } +#' +#' } +#' +#' +#' @examples +#' \dontrun{ +#' #################### create_user #################### +#' +#' library(petstore) +#' var.user <- User$new() # User | Created user object +#' +#' #Create user +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$create_user(var.user), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### create_users_with_array_input #################### +#' +#' library(petstore) +#' var.user <- [User$new()] # array[User] | List of user object +#' +#' #Creates list of users with given input array +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$create_users_with_array_input(var.user), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### create_users_with_list_input #################### +#' +#' library(petstore) +#' var.user <- [User$new()] # array[User] | List of user object +#' +#' #Creates list of users with given input array +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$create_users_with_list_input(var.user), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### delete_user #################### +#' +#' library(petstore) +#' var.username <- "username_example" # character | The name that needs to be deleted +#' +#' #Delete user +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$delete_user(var.username), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### get_user_by_name #################### +#' +#' library(petstore) +#' var.username <- "username_example" # character | The name that needs to be fetched. Use user1 for testing. +#' +#' #Get user by user name +#' api.instance <- UserApi$new() +#' +#'result <- tryCatch( +#' api.instance$get_user_by_name(var.username), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### login_user #################### +#' +#' library(petstore) +#' var.username <- "username_example" # character | The user name for login +#' var.password <- "password_example" # character | The password for login in clear text +#' +#' #Logs user into the system +#' api.instance <- UserApi$new() +#' +#'result <- tryCatch( +#' api.instance$login_user(var.username, var.password), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # deserialized response object +#' response.object <- result$content +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### logout_user #################### +#' +#' library(petstore) +#' +#' #Logs out current logged in user session +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$logout_user(), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' #################### update_user #################### +#' +#' library(petstore) +#' var.username <- "username_example" # character | name that need to be deleted +#' var.user <- User$new() # User | Updated user object +#' +#' #Updated user +#' api.instance <- UserApi$new() +#' +#' #Configure API key authorization: api_key +#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#' +#'result <- tryCatch( +#' api.instance$update_user(var.username, var.user), +#' ApiException = function(ex) ex +#' ) +#' # In case of error, print the error object +#' if(!is.null(result$ApiException)) { +#' cat(result$ApiException$toString()) +#' } else { +#' # response headers +#' response.headers <- result$response$headers +#' # response status code +#' response.status.code <- result$response$status_code +#' } +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @importFrom rlang abort +#' @export +UserApi <- R6::R6Class( + "UserApi", + public = list( + api_client = NULL, + #' Initialize a new UserApi. + #' + #' @description + #' Initialize a new UserApi. + #' + #' @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() + } + }, + #' Create user + #' + #' @description + #' Create user + #' + #' @param user Created user object + #' @param ... Other optional arguments + #' @return void + #' @export + create_user = function(user, ...) { + api_response <- self$create_user_with_http_info(user, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Create user + #' + #' @description + #' Create user + #' + #' @param user Created user object + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + create_user_with_http_info = function(user, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`user`)) { + rlang::abort(message = "Missing required parameter `user`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `user`.")) + } + + if (!missing(`user`)) { + body <- `user`$toJSONString() + } else { + body <- NULL + } + + url_path <- "/user" + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Creates list of users with given input array + #' + #' @description + #' Creates list of users with given input array + #' + #' @param user List of user object + #' @param ... Other optional arguments + #' @return void + #' @export + create_users_with_array_input = function(user, ...) { + api_response <- self$create_users_with_array_input_with_http_info(user, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Creates list of users with given input array + #' + #' @description + #' Creates list of users with given input array + #' + #' @param user List of user object + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + create_users_with_array_input_with_http_info = function(user, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`user`)) { + rlang::abort(message = "Missing required parameter `user`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `user`.")) + } + + if (!missing(`user`)) { + body.items <- paste(unlist(lapply(user, function(param) { + param$toJSONString() + })), collapse = ",") + body <- paste0("[", body.items, "]") + } else { + body <- NULL + } + + url_path <- "/user/createWithArray" + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Creates list of users with given input array + #' + #' @description + #' Creates list of users with given input array + #' + #' @param user List of user object + #' @param ... Other optional arguments + #' @return void + #' @export + create_users_with_list_input = function(user, ...) { + api_response <- self$create_users_with_list_input_with_http_info(user, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Creates list of users with given input array + #' + #' @description + #' Creates list of users with given input array + #' + #' @param user List of user object + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + create_users_with_list_input_with_http_info = function(user, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`user`)) { + rlang::abort(message = "Missing required parameter `user`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `user`.")) + } + + if (!missing(`user`)) { + body.items <- paste(unlist(lapply(user, function(param) { + param$toJSONString() + })), collapse = ",") + body <- paste0("[", body.items, "]") + } else { + body <- NULL + } + + url_path <- "/user/createWithList" + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Delete user + #' + #' @description + #' Delete user + #' + #' @param username The name that needs to be deleted + #' @param ... Other optional arguments + #' @return void + #' @export + delete_user = function(username, ...) { + api_response <- self$delete_user_with_http_info(username, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Delete user + #' + #' @description + #' Delete user + #' + #' @param username The name that needs to be deleted + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + delete_user_with_http_info = function(username, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`username`)) { + rlang::abort(message = "Missing required parameter `username`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `username`.")) + } + + body <- NULL + url_path <- "/user/{username}" + if (!missing(`username`)) { + url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path) + } + + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "DELETE", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Get user by user name + #' + #' @description + #' Get user by user name + #' + #' @param username The name that needs to be fetched. Use user1 for testing. + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return User + #' @export + get_user_by_name = function(username, data_file = NULL, ...) { + api_response <- self$get_user_by_name_with_http_info(username, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Get user by user name + #' + #' @description + #' Get user by user name + #' + #' @param username The name that needs to be fetched. Use user1 for testing. + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return API response (User) with additional information such as HTTP status code, headers + #' @export + get_user_by_name_with_http_info = function(username, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`username`)) { + rlang::abort(message = "Missing required parameter `username`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `username`.")) + } + + body <- NULL + url_path <- "/user/{username}" + if (!missing(`username`)) { + url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path) + } + + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "User", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Logs user into the system + #' + #' @description + #' Logs user into the system + #' + #' @param username The user name for login + #' @param password The password for login in clear text + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' @return character + #' @export + login_user = function(username, password, data_file = NULL, ...) { + api_response <- self$login_user_with_http_info(username, password, data_file = data_file, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Logs user into the system + #' + #' @description + #' Logs user into the system + #' + #' @param username The user name for login + #' @param password The password for login in clear text + #' @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 + login_user_with_http_info = function(username, password, data_file = NULL, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`username`)) { + rlang::abort(message = "Missing required parameter `username`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `username`.")) + } + + if (missing(`password`)) { + rlang::abort(message = "Missing required parameter `password`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `password`.")) + } + + body <- NULL + url_path <- "/user/login" + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + } + + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(resp, "character", loadNamespace("petstore")), + error = function(e) { + rlang::abort(message = "Failed to deserialize response", + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + ) + ApiResponse$new(deserialized_resp_obj, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Logs out current logged in user session + #' + #' @description + #' Logs out current logged in user session + #' + #' @param ... Other optional arguments + #' @return void + #' @export + logout_user = function(...) { + api_response <- self$logout_user_with_http_info(...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Logs out current logged in user session + #' + #' @description + #' Logs out current logged in user session + #' + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + logout_user_with_http_info = function(...) { + args <- list(...) + query_params <- c() + header_params <- c() + + body <- NULL + url_path <- "/user/logout" + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + }, + #' Updated user + #' + #' @description + #' Updated user + #' + #' @param username name that need to be deleted + #' @param user Updated user object + #' @param ... Other optional arguments + #' @return void + #' @export + update_user = function(username, user, ...) { + api_response <- self$update_user_with_http_info(username, user, ...) + resp <- api_response$response + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + api_response$content + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + api_response + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + api_response + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + api_response + } + }, + #' Updated user + #' + #' @description + #' Updated user + #' + #' @param username name that need to be deleted + #' @param user Updated user object + #' @param ... Other optional arguments + #' @return API response (void) with additional information such as HTTP status code, headers + #' @export + update_user_with_http_info = function(username, user, ...) { + args <- list(...) + query_params <- c() + header_params <- c() + + if (missing(`username`)) { + rlang::abort(message = "Missing required parameter `username`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `username`.")) + } + + if (missing(`user`)) { + rlang::abort(message = "Missing required parameter `user`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "Missing required parameter `user`.")) + } + + if (!missing(`user`)) { + body <- `user`$toJSONString() + } else { + body <- NULL + } + + url_path <- "/user/{username}" + if (!missing(`username`)) { + url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path) + } + + # API key authentication + if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) { + header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "") + } + + resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path), + method = "PUT", + query_params = query_params, + header_params = header_params, + body = body, + ...) + + if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) { + ApiResponse$new(NULL, resp) + } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.") + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api client exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) { + error_msg <- toString(content(resp)) + if (error_msg == "") { + error_msg <- "Api server exception encountered." + } + rlang::abort(message = error_msg, + .subclass = "ApiException", + ApiException = ApiException$new(http_response = resp)) + } + } + ) +) diff --git a/samples/client/petstore/R-httr2/README.md b/samples/client/petstore/R-httr2/README.md new file mode 100644 index 000000000000..396ce4edabe5 --- /dev/null +++ b/samples/client/petstore/R-httr2/README.md @@ -0,0 +1,142 @@ +# R API client for petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## 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: 1.0.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 petstore_1.0.0.tar.gz --no-manual +R CMD INSTALL --preclean petstore_1.0.0.tar.gz +``` + +### Install the package + +```R +install.packages("petstore") +``` + +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("petstore_1.0.0.tar.gz", repos = NULL, type = "source") +``` + +### Usage + +```R +library(petstore) +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*FakeApi* | [**fake_data_file**](docs/FakeApi.md#fake_data_file) | **GET** /fake/data_file | test data_file to ensure it's escaped correctly +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId}?streaming | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**get_pet_by_id_streaming**](docs/PetApi.md#get_pet_by_id_streaming) | **GET** /pet/{petId}?streaming | Find pet by ID (streaming) +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId}?streaming | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [AllofTagApiResponse](docs/AllofTagApiResponse.md) + - [Animal](docs/Animal.md) + - [AnyOfPig](docs/AnyOfPig.md) + - [BasquePig](docs/BasquePig.md) + - [Cat](docs/Cat.md) + - [CatAllOf](docs/CatAllOf.md) + - [Category](docs/Category.md) + - [DanishPig](docs/DanishPig.md) + - [Dog](docs/Dog.md) + - [DogAllOf](docs/DogAllOf.md) + - [ModelApiResponse](docs/ModelApiResponse.md) + - [NestedOneOf](docs/NestedOneOf.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [Pig](docs/Pig.md) + - [Special](docs/Special.md) + - [Tag](docs/Tag.md) + - [UpdatePetRequest](docs/UpdatePetRequest.md) + - [User](docs/User.md) + + +## Documentation for Authorization + + +### BearerToken + +- **Type**: HTTP basic authentication + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### http_auth + +- **Type**: HTTP basic authentication + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + + + +## Author + + + diff --git a/samples/client/petstore/R-httr2/build_and_test.bash b/samples/client/petstore/R-httr2/build_and_test.bash new file mode 100644 index 000000000000..2079f75da032 --- /dev/null +++ b/samples/client/petstore/R-httr2/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')" + +rm petstore_1.0.0.tar.gz || true + +R CMD build . +R CMD check *tar.gz --no-manual +R CMD install --preclean *tar.gz diff --git a/samples/client/petstore/R-httr2/docs/AllofTagApiResponse.md b/samples/client/petstore/R-httr2/docs/AllofTagApiResponse.md new file mode 100644 index 000000000000..14bcc1e22cfc --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/AllofTagApiResponse.md @@ -0,0 +1,13 @@ +# petstore::AllofTagApiResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] +**code** | **integer** | | [optional] +**type** | **character** | | [optional] +**message** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/Animal.md b/samples/client/petstore/R-httr2/docs/Animal.md new file mode 100644 index 000000000000..5cb0eb8bbf27 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Animal.md @@ -0,0 +1,10 @@ +# petstore::Animal + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | [optional] [default to "red"] + + diff --git a/samples/client/petstore/R-httr2/docs/AnyOfPig.md b/samples/client/petstore/R-httr2/docs/AnyOfPig.md new file mode 100644 index 000000000000..296d7c7e334f --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/AnyOfPig.md @@ -0,0 +1,11 @@ +# petstore::AnyOfPig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | +**size** | **integer** | | + + diff --git a/samples/client/petstore/R-httr2/docs/ApiResponse.md b/samples/client/petstore/R-httr2/docs/ApiResponse.md new file mode 100644 index 000000000000..ef38431e4cf1 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/ApiResponse.md @@ -0,0 +1,10 @@ +# petstore::ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **integer** | | [optional] +**type** | **character** | | [optional] +**message** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/BasquePig.md b/samples/client/petstore/R-httr2/docs/BasquePig.md new file mode 100644 index 000000000000..9e00cec58b27 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/BasquePig.md @@ -0,0 +1,10 @@ +# petstore::BasquePig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | + + diff --git a/samples/client/petstore/R-httr2/docs/Cat.md b/samples/client/petstore/R-httr2/docs/Cat.md new file mode 100644 index 000000000000..ba23ea86a33e --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Cat.md @@ -0,0 +1,11 @@ +# petstore::Cat + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | [optional] [default to "red"] +**declawed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/CatAllOf.md b/samples/client/petstore/R-httr2/docs/CatAllOf.md new file mode 100644 index 000000000000..ab2f71b88e25 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/CatAllOf.md @@ -0,0 +1,9 @@ +# petstore::CatAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/Category.md b/samples/client/petstore/R-httr2/docs/Category.md new file mode 100644 index 000000000000..7fa99ae82e0f --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Category.md @@ -0,0 +1,11 @@ +# petstore::Category + +A category for a pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/DanishPig.md b/samples/client/petstore/R-httr2/docs/DanishPig.md new file mode 100644 index 000000000000..1d6c5bf2ace6 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/DanishPig.md @@ -0,0 +1,10 @@ +# petstore::DanishPig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**size** | **integer** | | + + diff --git a/samples/client/petstore/R-httr2/docs/Dog.md b/samples/client/petstore/R-httr2/docs/Dog.md new file mode 100644 index 000000000000..b2e732df451b --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Dog.md @@ -0,0 +1,11 @@ +# petstore::Dog + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | [optional] [default to "red"] +**breed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/DogAllOf.md b/samples/client/petstore/R-httr2/docs/DogAllOf.md new file mode 100644 index 000000000000..76783e8800c8 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/DogAllOf.md @@ -0,0 +1,9 @@ +# petstore::DogAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/FakeApi.md b/samples/client/petstore/R-httr2/docs/FakeApi.md new file mode 100644 index 000000000000..cd3a202b1889 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/FakeApi.md @@ -0,0 +1,69 @@ +# FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fake_data_file**](FakeApi.md#fake_data_file) | **GET** /fake/data_file | test data_file to ensure it's escaped correctly + + +# **fake_data_file** +> User fake_data_file(dummy, var_data_file = var.var_data_file) + +test data_file to ensure it's escaped correctly + + + +### Example +```R +library(petstore) + +var_dummy <- "dummy_example" # character | dummy required parameter +var_var_data_file <- "var_data_file_example" # character | header data file + +#test data_file to ensure it's escaped correctly +api_instance <- FakeApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$fake_data_file(var_dummy, var_data_file = var_var_data_file, data_file = "result.txt"), + api_instance$fake_data_file(var_dummy, var_data_file = var_var_data_file), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **dummy** | **character**| dummy required parameter | + **var_data_file** | **character**| header data file | [optional] + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + diff --git a/samples/client/petstore/R-httr2/docs/ModelApiResponse.md b/samples/client/petstore/R-httr2/docs/ModelApiResponse.md new file mode 100644 index 000000000000..c761ca7d5edf --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ +# petstore::ModelApiResponse + +Describes the result of uploading an image resource + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **integer** | | [optional] +**type** | **character** | | [optional] +**message** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/NestedOneOf.md b/samples/client/petstore/R-httr2/docs/NestedOneOf.md new file mode 100644 index 000000000000..ecc2ed891442 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/NestedOneOf.md @@ -0,0 +1,10 @@ +# petstore::NestedOneOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**size** | **integer** | | [optional] +**nested_pig** | [**Pig**](Pig.md) | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/Order.md b/samples/client/petstore/R-httr2/docs/Order.md new file mode 100644 index 000000000000..2e41a351352b --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Order.md @@ -0,0 +1,15 @@ +# petstore::Order + +An order for a pets from the pet store + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**petId** | **integer** | | [optional] +**quantity** | **integer** | | [optional] +**shipDate** | **character** | | [optional] +**status** | **character** | Order Status | [optional] +**complete** | **character** | | [optional] [default to FALSE] + + diff --git a/samples/client/petstore/R-httr2/docs/Pet.md b/samples/client/petstore/R-httr2/docs/Pet.md new file mode 100644 index 000000000000..63021a8294ad --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Pet.md @@ -0,0 +1,15 @@ +# petstore::Pet + +A pet for sale in the pet store + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **character** | | +**photoUrls** | **array[character]** | | +**tags** | [**array[Tag]**](Tag.md) | | [optional] +**status** | **character** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/PetApi.md b/samples/client/petstore/R-httr2/docs/PetApi.md new file mode 100644 index 000000000000..813a6ee2f69e --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/PetApi.md @@ -0,0 +1,572 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId}?streaming | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**get_pet_by_id_streaming**](PetApi.md#get_pet_by_id_streaming) | **GET** /pet/{petId}?streaming | Find pet by ID (streaming) +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId}?streaming | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> Pet add_pet(pet) + +Add a new pet to the store + + + +### Example +```R +library(petstore) + +var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store + +#Add a new pet to the store +api_instance <- PetApi$new() +# Configure HTTP basic authorization: http_auth +api_instance$api_client$username <- 'TODO_YOUR_USERNAME'; +api_instance$api_client$password <- 'TODO_YOUR_PASSWORD'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$add_pet(var_pet, data_file = "result.txt"), + api_instance$add_pet(var_pet), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[http_auth](../README.md#http_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml, multipart/related + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **405** | Invalid input | - | + +# **delete_pet** +> delete_pet(pet_id, api_key = var.api_key) + +Deletes a pet + + + +### Example +```R +library(petstore) + +var_pet_id <- 56 # integer | Pet id to delete +var_api_key <- "api_key_example" # character | + +#Deletes a pet +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + api_instance$delete_pet(var_pet_id, api_key = var_api_key), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **integer**| Pet id to delete | + **api_key** | **character**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +# **find_pets_by_status** +> array[Pet] find_pets_by_status(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```R +library(petstore) + +var_status <- list("available") # array[character] | Status values that need to be considered for filter + +#Finds Pets by status +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$find_pets_by_status(var_status, data_file = "result.txt"), + api_instance$find_pets_by_status(var_status), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | Enum [available, pending, sold] | Status values that need to be considered for filter | + +### Return type + +[**array[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +# **find_pets_by_tags** +> array[Pet] find_pets_by_tags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```R +library(petstore) + +var_tags <- list("inner_example") # array[character] | Tags to filter by + +#Finds Pets by tags +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$find_pets_by_tags(var_tags, data_file = "result.txt"), + api_instance$find_pets_by_tags(var_tags), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | list( **character** )| Tags to filter by | + +### Return type + +[**array[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id) + +Find pet by ID + +Returns a single pet + +### Example +```R +library(petstore) + +var_pet_id <- 56 # integer | ID of pet to return + +#Find pet by ID +api_instance <- PetApi$new() +# Configure HTTP bearer authorization: BearerToken +api.instance$api_client$bearer_token <- 'TODO_YOUR_BEARER_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$get_pet_by_id(var_pet_id, data_file = "result.txt"), + api_instance$get_pet_by_id(var_pet_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **integer**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[BearerToken](../README.md#BearerToken) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +# **get_pet_by_id_streaming** +> Pet get_pet_by_id_streaming(pet_id) + +Find pet by ID (streaming) + +Returns a single pet + +### Example +```R +library(petstore) + +var_pet_id <- 56 # integer | ID of pet to return + +#Find pet by ID (streaming) +api_instance <- PetApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$get_pet_by_id_streaming(var_pet_id, data_file = "result.txt"), + # this endpoint supports data streaming via a callback function using the optional `stream_callback` parameter, e.g. + # api_instance$get_pet_by_id_streaming(var_pet_id, stream_callback = function(x){ print(length(x)) }), + api_instance$get_pet_by_id_streaming(var_pet_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **integer**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +# **update_pet** +> Pet update_pet(pet) + +Update an existing pet + + + +### Example +```R +library(petstore) + +var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store + +#Update an existing pet +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$update_pet(var_pet, data_file = "result.txt"), + api_instance$update_pet(var_pet), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml, multipart/related + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +# **update_pet_with_form** +> update_pet_with_form(pet_id, name = var.name, status = var.status) + +Updates a pet in the store with form data + + + +### Example +```R +library(petstore) + +var_pet_id <- 56 # integer | ID of pet that needs to be updated +var_name <- "name_example" # character | Updated name of the pet +var_status <- "status_example" # character | Updated status of the pet + +#Updates a pet in the store with form data +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + api_instance$update_pet_with_form(var_pet_id, name = var_name, status = var_status), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **integer**| ID of pet that needs to be updated | + **name** | **character**| Updated name of the pet | [optional] + **status** | **character**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +# **upload_file** +> ModelApiResponse upload_file(pet_id, additional_metadata = var.additional_metadata, file = var.file) + +uploads an image + + + +### Example +```R +library(petstore) + +var_pet_id <- 56 # integer | ID of pet to update +var_additional_metadata <- "additional_metadata_example" # character | Additional data to pass to server +var_file <- File.new('/path/to/file') # data.frame | file to upload + +#uploads an image +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$upload_file(var_pet_id, additional_metadata = var_additional_metadata, file = var_file, data_file = "result.txt"), + api_instance$upload_file(var_pet_id, additional_metadata = var_additional_metadata, file = var_file), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **integer**| ID of pet to update | + **additional_metadata** | **character**| Additional data to pass to server | [optional] + **file** | **data.frame**| file to upload | [optional] + +### Return type + +[**ModelApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + diff --git a/samples/client/petstore/R-httr2/docs/Pig.md b/samples/client/petstore/R-httr2/docs/Pig.md new file mode 100644 index 000000000000..7906011bd424 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Pig.md @@ -0,0 +1,11 @@ +# petstore::Pig + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **character** | | +**color** | **character** | | +**size** | **integer** | | + + diff --git a/samples/client/petstore/R-httr2/docs/Special.md b/samples/client/petstore/R-httr2/docs/Special.md new file mode 100644 index 000000000000..0114a84c8fd6 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Special.md @@ -0,0 +1,15 @@ +# petstore::Special + +Describes the result of uploading an image resource + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**item_self** | **integer** | | [optional] +**item_private** | **character** | | [optional] +**item_super** | **character** | | [optional] +**123_number** | **character** | | [optional] +**array[test]** | **character** | | [optional] +**empty_string** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/StoreApi.md b/samples/client/petstore/R-httr2/docs/StoreApi.md new file mode 100644 index 000000000000..d3fd2535dd2e --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/StoreApi.md @@ -0,0 +1,242 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```R +library(petstore) + +var_order_id <- "order_id_example" # character | ID of the order that needs to be deleted + +#Delete purchase order by ID +api_instance <- StoreApi$new() +result <- tryCatch( + api_instance$delete_order(var_order_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **character**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +# **get_inventory** +> map(integer) get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```R +library(petstore) + + +#Returns pet inventories by status +api_instance <- StoreApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$get_inventory(data_file = "result.txt"), + api_instance$get_inventory(), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**map(integer)** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +# **get_order_by_id** +> Order get_order_by_id(order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```R +library(petstore) + +var_order_id <- 56 # integer | ID of pet that needs to be fetched + +#Find purchase order by ID +api_instance <- StoreApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$get_order_by_id(var_order_id, data_file = "result.txt"), + api_instance$get_order_by_id(var_order_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **integer**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +# **place_order** +> Order place_order(order) + +Place an order for a pet + + + +### Example +```R +library(petstore) + +var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet + +#Place an order for a pet +api_instance <- StoreApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$place_order(var_order, data_file = "result.txt"), + api_instance$place_order(var_order), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + diff --git a/samples/client/petstore/R-httr2/docs/Tag.md b/samples/client/petstore/R-httr2/docs/Tag.md new file mode 100644 index 000000000000..3cb9bd184ddd --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/Tag.md @@ -0,0 +1,11 @@ +# petstore::Tag + +A tag for a pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**name** | **character** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/UpdatePetRequest.md b/samples/client/petstore/R-httr2/docs/UpdatePetRequest.md new file mode 100644 index 000000000000..619f0b2262af --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/UpdatePetRequest.md @@ -0,0 +1,10 @@ +# petstore::UpdatePetRequest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**jsonData** | [**Pet**](Pet.md) | | [optional] +**binaryDataN2Information** | **data.frame** | | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/User.md b/samples/client/petstore/R-httr2/docs/User.md new file mode 100644 index 000000000000..98d0316ea21b --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/User.md @@ -0,0 +1,17 @@ +# petstore::User + +A User who is purchasing from the pet store + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **integer** | | [optional] +**username** | **character** | | [optional] +**firstName** | **character** | | [optional] +**lastName** | **character** | | [optional] +**email** | **character** | | [optional] +**password** | **character** | | [optional] +**phone** | **character** | | [optional] +**userStatus** | **integer** | User Status | [optional] + + diff --git a/samples/client/petstore/R-httr2/docs/UserApi.md b/samples/client/petstore/R-httr2/docs/UserApi.md new file mode 100644 index 000000000000..64d9c4224520 --- /dev/null +++ b/samples/client/petstore/R-httr2/docs/UserApi.md @@ -0,0 +1,473 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(user) + +Create user + +This can only be done by the logged in user. + +### Example +```R +library(petstore) + +var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object + +#Create user +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$create_user(var_user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +# **create_users_with_array_input** +> create_users_with_array_input(user) + +Creates list of users with given input array + + + +### Example +```R +library(petstore) + +var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object + +#Creates list of users with given input array +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$create_users_with_array_input(var_user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | list( [**User**](User.md) )| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +# **create_users_with_list_input** +> create_users_with_list_input(user) + +Creates list of users with given input array + + + +### Example +```R +library(petstore) + +var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object + +#Creates list of users with given input array +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$create_users_with_list_input(var_user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | list( [**User**](User.md) )| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +# **delete_user** +> delete_user(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```R +library(petstore) + +var_username <- "username_example" # character | The name that needs to be deleted + +#Delete user +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$delete_user(var_username), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **character**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +# **get_user_by_name** +> User get_user_by_name(username) + +Get user by user name + + + +### Example +```R +library(petstore) + +var_username <- "username_example" # character | The name that needs to be fetched. Use user1 for testing. + +#Get user by user name +api_instance <- UserApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$get_user_by_name(var_username, data_file = "result.txt"), + api_instance$get_user_by_name(var_username), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **character**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +# **login_user** +> character login_user(username, password) + +Logs user into the system + + + +### Example +```R +library(petstore) + +var_username <- "username_example" # character | The user name for login +var_password <- "password_example" # character | The password for login in clear text + +#Logs user into the system +api_instance <- UserApi$new() +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$login_user(var_username, var_password, data_file = "result.txt"), + api_instance$login_user(var_username, var_password), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # deserialized response object + response.object <- result$content + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **character**| The user name for login | + **password** | **character**| The password for login in clear text | + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +# **logout_user** +> logout_user() + +Logs out current logged in user session + + + +### Example +```R +library(petstore) + + +#Logs out current logged in user session +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$logout_user(), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +# **update_user** +> update_user(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example +```R +library(petstore) + +var_username <- "username_example" # character | name that need to be deleted +var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object + +#Updated user +api_instance <- UserApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + api_instance$update_user(var_username, var_user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if (!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { + # response headers + response.headers <- result$response$headers + # response status code + response.status.code <- result$response$status_code +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **character**| name that need to be deleted | + **user** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + diff --git a/samples/client/petstore/R-httr2/git_push.sh b/samples/client/petstore/R-httr2/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/R-httr2/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/petstore/R-httr2/man/AllofTagApiResponse.Rd b/samples/client/petstore/R-httr2/man/AllofTagApiResponse.Rd new file mode 100644 index 000000000000..eeb058dd7bd7 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/AllofTagApiResponse.Rd @@ -0,0 +1,196 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/allof_tag_api_response.R +\docType{class} +\name{AllofTagApiResponse} +\alias{AllofTagApiResponse} +\title{AllofTagApiResponse} +\format{ +An \code{R6Class} generator object +} +\description{ +AllofTagApiResponse Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{name}}{character [optional]} + +\item{\code{code}}{integer [optional]} + +\item{\code{type}}{character [optional]} + +\item{\code{message}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-AllofTagApiResponse-new}{\code{AllofTagApiResponse$new()}} +\item \href{#method-AllofTagApiResponse-toJSON}{\code{AllofTagApiResponse$toJSON()}} +\item \href{#method-AllofTagApiResponse-fromJSON}{\code{AllofTagApiResponse$fromJSON()}} +\item \href{#method-AllofTagApiResponse-toJSONString}{\code{AllofTagApiResponse$toJSONString()}} +\item \href{#method-AllofTagApiResponse-fromJSONString}{\code{AllofTagApiResponse$fromJSONString()}} +\item \href{#method-AllofTagApiResponse-validateJSON}{\code{AllofTagApiResponse$validateJSON()}} +\item \href{#method-AllofTagApiResponse-toString}{\code{AllofTagApiResponse$toString()}} +\item \href{#method-AllofTagApiResponse-clone}{\code{AllofTagApiResponse$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new AllofTagApiResponse class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$new( + id = NULL, + name = NULL, + code = NULL, + type = NULL, + message = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{id} + +\item{\code{name}}{name} + +\item{\code{code}}{code} + +\item{\code{type}}{type} + +\item{\code{message}}{message} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +AllofTagApiResponse in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of AllofTagApiResponse +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of AllofTagApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +AllofTagApiResponse in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of AllofTagApiResponse +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of AllofTagApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to AllofTagApiResponse and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of AllofTagApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AllofTagApiResponse-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AllofTagApiResponse$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Animal.Rd b/samples/client/petstore/R-httr2/man/Animal.Rd new file mode 100644 index 000000000000..36d90e9aed27 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Animal.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/animal.R +\docType{class} +\name{Animal} +\alias{Animal} +\title{Animal} +\format{ +An \code{R6Class} generator object +} +\description{ +Animal Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{character} + +\item{\code{color}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Animal-new}{\code{Animal$new()}} +\item \href{#method-Animal-toJSON}{\code{Animal$toJSON()}} +\item \href{#method-Animal-fromJSON}{\code{Animal$fromJSON()}} +\item \href{#method-Animal-toJSONString}{\code{Animal$toJSONString()}} +\item \href{#method-Animal-fromJSONString}{\code{Animal$fromJSONString()}} +\item \href{#method-Animal-validateJSON}{\code{Animal$validateJSON()}} +\item \href{#method-Animal-toString}{\code{Animal$toString()}} +\item \href{#method-Animal-clone}{\code{Animal$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Animal class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$new(className, color = "red", ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{className} + +\item{\code{color}}{color. Default to 'red'.} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Animal in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Animal +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Animal +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Animal in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Animal +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Animal +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Animal and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Animal +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Animal-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Animal$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/AnyOfPig.Rd b/samples/client/petstore/R-httr2/man/AnyOfPig.Rd new file mode 100644 index 000000000000..a40bf0c69c49 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/AnyOfPig.Rd @@ -0,0 +1,156 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/any_of_pig.R +\docType{class} +\name{AnyOfPig} +\alias{AnyOfPig} +\title{AnyOfPig} +\format{ +An \code{R6Class} generator object +} +\description{ +AnyOfPig Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{actual_instance}}{the object stored in this instance.} + +\item{\code{actual_type}}{the type of the object stored in this instance.} + +\item{\code{any_of}}{a list of object types defined in the anyOf schema. +Initialize a new AnyOfPig.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-AnyOfPig-new}{\code{AnyOfPig$new()}} +\item \href{#method-AnyOfPig-fromJSON}{\code{AnyOfPig$fromJSON()}} +\item \href{#method-AnyOfPig-toJSONString}{\code{AnyOfPig$toJSONString()}} +\item \href{#method-AnyOfPig-toJSON}{\code{AnyOfPig$toJSON()}} +\item \href{#method-AnyOfPig-validateJSON}{\code{AnyOfPig$validateJSON()}} +\item \href{#method-AnyOfPig-toString}{\code{AnyOfPig$toString()}} +\item \href{#method-AnyOfPig-clone}{\code{AnyOfPig$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new AnyOfPig. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$new(instance = NULL)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{instance}}{an instance of the object defined in the anyOf schemas: "BasquePig", "DanishPig"} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of AnyOfPig. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$fromJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{The input JSON.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +An instance of AnyOfPig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +Serialize AnyOfPig to JSON string. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +JSON string representation of the AnyOfPig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +Serialize AnyOfPig to JSON. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +JSON representation of the AnyOfPig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate the input JSON with respect to AnyOfPig and +throw exception if invalid. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{The input JSON.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-toString}{}}} +\subsection{Method \code{toString()}}{ +Returns the string representation of the instance. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +The string representation of the instance. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-AnyOfPig-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{AnyOfPig$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/ApiClient.Rd b/samples/client/petstore/R-httr2/man/ApiClient.Rd new file mode 100644 index 000000000000..decef8c6aff2 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/ApiClient.Rd @@ -0,0 +1,260 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/api_client.R +\docType{class} +\name{ApiClient} +\alias{ApiClient} +\title{ApiClient} +\format{ +An \code{R6Class} generator object +} +\description{ +ApiClient Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +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. +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{base_path}}{Base url} + +\item{\code{user_agent}}{Default user agent} + +\item{\code{default_headers}}{Default headers} + +\item{\code{username}}{Username for HTTP basic authentication} + +\item{\code{password}}{Password for HTTP basic authentication} + +\item{\code{api_keys}}{API keys} + +\item{\code{access_token}}{Access token} + +\item{\code{timeout}}{Default timeout in seconds} + +\item{\code{retry_status_codes}}{vector of status codes to retry} + +\item{\code{max_retry_attempts}}{maximum number of retries for the status codes} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-ApiClient-new}{\code{ApiClient$new()}} +\item \href{#method-ApiClient-CallApi}{\code{ApiClient$CallApi()}} +\item \href{#method-ApiClient-Execute}{\code{ApiClient$Execute()}} +\item \href{#method-ApiClient-deserialize}{\code{ApiClient$deserialize()}} +\item \href{#method-ApiClient-deserializeObj}{\code{ApiClient$deserializeObj()}} +\item \href{#method-ApiClient-clone}{\code{ApiClient$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new ApiClient. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$new( + base_path = NULL, + user_agent = NULL, + default_headers = NULL, + username = NULL, + password = NULL, + api_keys = NULL, + access_token = NULL, + timeout = NULL, + retry_status_codes = NULL, + max_retry_attempts = NULL +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{base_path}}{Base path.} + +\item{\code{user_agent}}{User agent.} + +\item{\code{default_headers}}{Default headers.} + +\item{\code{username}}{User name.} + +\item{\code{password}}{Password.} + +\item{\code{api_keys}}{API keys.} + +\item{\code{access_token}}{Access token.} + +\item{\code{timeout}}{Timeout.} + +\item{\code{retry_status_codes}}{Status codes for retry.} + +\item{\code{max_retry_attempts}}{Maxmium number of retry.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-CallApi}{}}} +\subsection{Method \code{CallApi()}}{ +Prepare to make an API call with the retry logic. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$CallApi( + url, + method, + query_params, + header_params, + body, + stream_callback = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{url}}{URL.} + +\item{\code{method}}{HTTP method.} + +\item{\code{query_params}}{The query parameters.} + +\item{\code{header_params}}{The header parameters.} + +\item{\code{body}}{The HTTP request body.} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +HTTP response +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-Execute}{}}} +\subsection{Method \code{Execute()}}{ +Make an API call +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$Execute( + url, + method, + query_params, + header_params, + body, + stream_callback = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{url}}{URL.} + +\item{\code{method}}{HTTP method.} + +\item{\code{query_params}}{The query parameters.} + +\item{\code{header_params}}{The header parameters.} + +\item{\code{body}}{The HTTP request body.} + +\item{\code{stream_callback}}{callback function to process data stream} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +HTTP response +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-deserialize}{}}} +\subsection{Method \code{deserialize()}}{ +Deserialize the content of api response to the given type. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$deserialize(resp, return_type, pkg_env)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{resp}}{Response object.} + +\item{\code{return_type}}{R return type.} + +\item{\code{pkg_env}}{Package environment.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Deserialized object. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-deserializeObj}{}}} +\subsection{Method \code{deserializeObj()}}{ +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., +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$deserializeObj(obj, return_type, pkg_env)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{obj}}{Response object.} + +\item{\code{return_type}}{R return type.} + +\item{\code{pkg_env}}{Package environment.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Deserialized object. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiClient-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiClient$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/ApiException.Rd b/samples/client/petstore/R-httr2/man/ApiException.Rd new file mode 100644 index 000000000000..94a6f746532f --- /dev/null +++ b/samples/client/petstore/R-httr2/man/ApiException.Rd @@ -0,0 +1,95 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/api_exception.R +\docType{class} +\name{ApiException} +\alias{ApiException} +\title{ApiException} +\format{ +An \code{R6Class} generator object +} +\description{ +ApiException Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{status}}{Status of the ApiException} + +\item{\code{reason}}{Reason of the ApiException} + +\item{\code{body}}{Body of the http response} + +\item{\code{headers}}{Headers of the http response} + +\item{\code{errorObject}}{error object type} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-ApiException-new}{\code{ApiException$new()}} +\item \href{#method-ApiException-toString}{\code{ApiException$toString()}} +\item \href{#method-ApiException-clone}{\code{ApiException$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiException-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new ApiExceptino class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiException$new(status = NULL, reason = NULL, http_response = NULL)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{status}}{HTTP status.} + +\item{\code{reason}}{Reason of the ApiException.} + +\item{\code{http_response}}{HTTP response object.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiException-toString}{}}} +\subsection{Method \code{toString()}}{ +Returns the string format of ApiException. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiException$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +the string format of ApiException. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiException-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiException$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/ApiResponse.Rd b/samples/client/petstore/R-httr2/man/ApiResponse.Rd new file mode 100644 index 000000000000..d6970b6b17d2 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/ApiResponse.Rd @@ -0,0 +1,73 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/api_response.R +\docType{class} +\name{ApiResponse} +\alias{ApiResponse} +\title{ApiResponse} +\format{ +An \code{R6Class} generator object +} +\description{ +ApiResponse Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{content}}{The deserialized response body.} + +\item{\code{response}}{The raw response from the endpoint.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-ApiResponse-new}{\code{ApiResponse$new()}} +\item \href{#method-ApiResponse-clone}{\code{ApiResponse$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiResponse-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new ApiResponse class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiResponse$new(content, response)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{content}}{The deserialized response body.} + +\item{\code{response}}{The raw response from the endpoint.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ApiResponse-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ApiResponse$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/BasquePig.Rd b/samples/client/petstore/R-httr2/man/BasquePig.Rd new file mode 100644 index 000000000000..df70384ea552 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/BasquePig.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/basque_pig.R +\docType{class} +\name{BasquePig} +\alias{BasquePig} +\title{BasquePig} +\format{ +An \code{R6Class} generator object +} +\description{ +BasquePig Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{character} + +\item{\code{color}}{character} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-BasquePig-new}{\code{BasquePig$new()}} +\item \href{#method-BasquePig-toJSON}{\code{BasquePig$toJSON()}} +\item \href{#method-BasquePig-fromJSON}{\code{BasquePig$fromJSON()}} +\item \href{#method-BasquePig-toJSONString}{\code{BasquePig$toJSONString()}} +\item \href{#method-BasquePig-fromJSONString}{\code{BasquePig$fromJSONString()}} +\item \href{#method-BasquePig-validateJSON}{\code{BasquePig$validateJSON()}} +\item \href{#method-BasquePig-toString}{\code{BasquePig$toString()}} +\item \href{#method-BasquePig-clone}{\code{BasquePig$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new BasquePig class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$new(className, color, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{className} + +\item{\code{color}}{color} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +BasquePig in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of BasquePig +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of BasquePig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +BasquePig in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of BasquePig +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of BasquePig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to BasquePig and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of BasquePig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-BasquePig-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{BasquePig$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Cat.Rd b/samples/client/petstore/R-httr2/man/Cat.Rd new file mode 100644 index 000000000000..00daccf540fd --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Cat.Rd @@ -0,0 +1,190 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cat.R +\docType{class} +\name{Cat} +\alias{Cat} +\title{Cat} +\format{ +An \code{R6Class} generator object +} +\description{ +Cat Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Super class}{ +\code{\link[petstore:Animal]{petstore::Animal}} -> \code{Cat} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{character} + +\item{\code{color}}{character [optional]} + +\item{\code{declawed}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Cat-new}{\code{Cat$new()}} +\item \href{#method-Cat-toJSON}{\code{Cat$toJSON()}} +\item \href{#method-Cat-fromJSON}{\code{Cat$fromJSON()}} +\item \href{#method-Cat-toJSONString}{\code{Cat$toJSONString()}} +\item \href{#method-Cat-fromJSONString}{\code{Cat$fromJSONString()}} +\item \href{#method-Cat-validateJSON}{\code{Cat$validateJSON()}} +\item \href{#method-Cat-toString}{\code{Cat$toString()}} +\item \href{#method-Cat-clone}{\code{Cat$clone()}} +} +} +\if{html}{\out{ +
Inherited methods +
    +
+
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Cat class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$new(className, color = "red", declawed = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{className} + +\item{\code{color}}{color. Default to 'red'.} + +\item{\code{declawed}}{declawed} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Cat in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Cat +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Cat +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Cat in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Cat +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Cat +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Cat and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Cat +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Cat-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Cat$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/CatAllOf.Rd b/samples/client/petstore/R-httr2/man/CatAllOf.Rd new file mode 100644 index 000000000000..643c338aeeb0 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/CatAllOf.Rd @@ -0,0 +1,173 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cat_all_of.R +\docType{class} +\name{CatAllOf} +\alias{CatAllOf} +\title{CatAllOf} +\format{ +An \code{R6Class} generator object +} +\description{ +CatAllOf Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{declawed}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-CatAllOf-new}{\code{CatAllOf$new()}} +\item \href{#method-CatAllOf-toJSON}{\code{CatAllOf$toJSON()}} +\item \href{#method-CatAllOf-fromJSON}{\code{CatAllOf$fromJSON()}} +\item \href{#method-CatAllOf-toJSONString}{\code{CatAllOf$toJSONString()}} +\item \href{#method-CatAllOf-fromJSONString}{\code{CatAllOf$fromJSONString()}} +\item \href{#method-CatAllOf-validateJSON}{\code{CatAllOf$validateJSON()}} +\item \href{#method-CatAllOf-toString}{\code{CatAllOf$toString()}} +\item \href{#method-CatAllOf-clone}{\code{CatAllOf$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new CatAllOf class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$new(declawed = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{declawed}}{declawed} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +CatAllOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of CatAllOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of CatAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +CatAllOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of CatAllOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of CatAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to CatAllOf and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of CatAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-CatAllOf-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{CatAllOf$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Category.Rd b/samples/client/petstore/R-httr2/man/Category.Rd new file mode 100644 index 000000000000..f009bbc15122 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Category.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/category.R +\docType{class} +\name{Category} +\alias{Category} +\title{Category} +\format{ +An \code{R6Class} generator object +} +\description{ +Category Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{name}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Category-new}{\code{Category$new()}} +\item \href{#method-Category-toJSON}{\code{Category$toJSON()}} +\item \href{#method-Category-fromJSON}{\code{Category$fromJSON()}} +\item \href{#method-Category-toJSONString}{\code{Category$toJSONString()}} +\item \href{#method-Category-fromJSONString}{\code{Category$fromJSONString()}} +\item \href{#method-Category-validateJSON}{\code{Category$validateJSON()}} +\item \href{#method-Category-toString}{\code{Category$toString()}} +\item \href{#method-Category-clone}{\code{Category$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Category class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$new(id = NULL, name = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{id} + +\item{\code{name}}{name} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Category in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Category +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Category +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Category in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Category +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Category +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Category and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Category +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Category-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Category$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/DanishPig.Rd b/samples/client/petstore/R-httr2/man/DanishPig.Rd new file mode 100644 index 000000000000..6d72b380383e --- /dev/null +++ b/samples/client/petstore/R-httr2/man/DanishPig.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/danish_pig.R +\docType{class} +\name{DanishPig} +\alias{DanishPig} +\title{DanishPig} +\format{ +An \code{R6Class} generator object +} +\description{ +DanishPig Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{character} + +\item{\code{size}}{integer} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-DanishPig-new}{\code{DanishPig$new()}} +\item \href{#method-DanishPig-toJSON}{\code{DanishPig$toJSON()}} +\item \href{#method-DanishPig-fromJSON}{\code{DanishPig$fromJSON()}} +\item \href{#method-DanishPig-toJSONString}{\code{DanishPig$toJSONString()}} +\item \href{#method-DanishPig-fromJSONString}{\code{DanishPig$fromJSONString()}} +\item \href{#method-DanishPig-validateJSON}{\code{DanishPig$validateJSON()}} +\item \href{#method-DanishPig-toString}{\code{DanishPig$toString()}} +\item \href{#method-DanishPig-clone}{\code{DanishPig$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new DanishPig class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$new(className, size, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{className} + +\item{\code{size}}{size} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +DanishPig in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of DanishPig +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of DanishPig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +DanishPig in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of DanishPig +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of DanishPig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to DanishPig and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of DanishPig +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DanishPig-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DanishPig$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Dog.Rd b/samples/client/petstore/R-httr2/man/Dog.Rd new file mode 100644 index 000000000000..cd38a2f8e5ec --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Dog.Rd @@ -0,0 +1,190 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dog.R +\docType{class} +\name{Dog} +\alias{Dog} +\title{Dog} +\format{ +An \code{R6Class} generator object +} +\description{ +Dog Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Super class}{ +\code{\link[petstore:Animal]{petstore::Animal}} -> \code{Dog} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{character} + +\item{\code{color}}{character [optional]} + +\item{\code{breed}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Dog-new}{\code{Dog$new()}} +\item \href{#method-Dog-toJSON}{\code{Dog$toJSON()}} +\item \href{#method-Dog-fromJSON}{\code{Dog$fromJSON()}} +\item \href{#method-Dog-toJSONString}{\code{Dog$toJSONString()}} +\item \href{#method-Dog-fromJSONString}{\code{Dog$fromJSONString()}} +\item \href{#method-Dog-validateJSON}{\code{Dog$validateJSON()}} +\item \href{#method-Dog-toString}{\code{Dog$toString()}} +\item \href{#method-Dog-clone}{\code{Dog$clone()}} +} +} +\if{html}{\out{ +
Inherited methods +
    +
+
+}} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Dog class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$new(className, color = "red", breed = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{className}}{className} + +\item{\code{color}}{color. Default to 'red'.} + +\item{\code{breed}}{breed} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Dog in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Dog +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Dog +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Dog in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Dog +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Dog +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Dog and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Dog +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Dog-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Dog$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/DogAllOf.Rd b/samples/client/petstore/R-httr2/man/DogAllOf.Rd new file mode 100644 index 000000000000..bba0063c0429 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/DogAllOf.Rd @@ -0,0 +1,173 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dog_all_of.R +\docType{class} +\name{DogAllOf} +\alias{DogAllOf} +\title{DogAllOf} +\format{ +An \code{R6Class} generator object +} +\description{ +DogAllOf Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{breed}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-DogAllOf-new}{\code{DogAllOf$new()}} +\item \href{#method-DogAllOf-toJSON}{\code{DogAllOf$toJSON()}} +\item \href{#method-DogAllOf-fromJSON}{\code{DogAllOf$fromJSON()}} +\item \href{#method-DogAllOf-toJSONString}{\code{DogAllOf$toJSONString()}} +\item \href{#method-DogAllOf-fromJSONString}{\code{DogAllOf$fromJSONString()}} +\item \href{#method-DogAllOf-validateJSON}{\code{DogAllOf$validateJSON()}} +\item \href{#method-DogAllOf-toString}{\code{DogAllOf$toString()}} +\item \href{#method-DogAllOf-clone}{\code{DogAllOf$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new DogAllOf class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$new(breed = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{breed}}{breed} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +DogAllOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of DogAllOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of DogAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +DogAllOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of DogAllOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of DogAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to DogAllOf and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of DogAllOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-DogAllOf-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{DogAllOf$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/FakeApi.Rd b/samples/client/petstore/R-httr2/man/FakeApi.Rd new file mode 100644 index 000000000000..319cd8e4e374 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/FakeApi.Rd @@ -0,0 +1,183 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fake_api.R +\docType{class} +\name{FakeApi} +\alias{FakeApi} +\title{Fake operations} +\format{ +An \code{R6Class} generator object +} +\description{ +petstore.Fake +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Methods}{ + +\describe{ +\strong{ FakeDataFile } \emph{ test data_file to ensure it's escaped correctly } + + +\itemize{ +\item \emph{ @param } dummy character +\item \emph{ @param } var_data_file character +\item \emph{ @returnType } \link{User} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : User +\item response headers : + +\tabular{ll}{ +} +} + +} +} + +\examples{ +\dontrun{ +#################### FakeDataFile #################### + +library(petstore) +var.dummy <- 'dummy_example' # character | dummy required parameter +var.var_data_file <- 'var_data_file_example' # character | header data file + +#test data_file to ensure it's escaped correctly +api.instance <- FakeApi$new() + +result <- tryCatch( + api.instance$FakeDataFile(var.dummy, var_data_file=var.var_data_file), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{Handles the client-server communication.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-FakeApi-new}{\code{FakeApi$new()}} +\item \href{#method-FakeApi-FakeDataFile}{\code{FakeApi$FakeDataFile()}} +\item \href{#method-FakeApi-FakeDataFileWithHttpInfo}{\code{FakeApi$FakeDataFileWithHttpInfo()}} +\item \href{#method-FakeApi-clone}{\code{FakeApi$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-FakeApi-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new FakeApi. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{FakeApi$new(api_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{An instance of API client.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-FakeApi-FakeDataFile}{}}} +\subsection{Method \code{FakeDataFile()}}{ +test data_file to ensure it's escaped correctly +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{FakeApi$FakeDataFile(dummy, var_data_file = NULL, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{dummy}}{dummy required parameter} + +\item{\code{var_data_file}}{(optional) header data file} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +User +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-FakeApi-FakeDataFileWithHttpInfo}{}}} +\subsection{Method \code{FakeDataFileWithHttpInfo()}}{ +test data_file to ensure it's escaped correctly +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{FakeApi$FakeDataFileWithHttpInfo( + dummy, + var_data_file = NULL, + data_file = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{dummy}}{dummy required parameter} + +\item{\code{var_data_file}}{(optional) header data file} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (User) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-FakeApi-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{FakeApi$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/ModelApiResponse.Rd b/samples/client/petstore/R-httr2/man/ModelApiResponse.Rd new file mode 100644 index 000000000000..75d2ac0bfa3c --- /dev/null +++ b/samples/client/petstore/R-httr2/man/ModelApiResponse.Rd @@ -0,0 +1,181 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/model_api_response.R +\docType{class} +\name{ModelApiResponse} +\alias{ModelApiResponse} +\title{ModelApiResponse} +\format{ +An \code{R6Class} generator object +} +\description{ +ModelApiResponse Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{code}}{integer [optional]} + +\item{\code{type}}{character [optional]} + +\item{\code{message}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-ModelApiResponse-new}{\code{ModelApiResponse$new()}} +\item \href{#method-ModelApiResponse-toJSON}{\code{ModelApiResponse$toJSON()}} +\item \href{#method-ModelApiResponse-fromJSON}{\code{ModelApiResponse$fromJSON()}} +\item \href{#method-ModelApiResponse-toJSONString}{\code{ModelApiResponse$toJSONString()}} +\item \href{#method-ModelApiResponse-fromJSONString}{\code{ModelApiResponse$fromJSONString()}} +\item \href{#method-ModelApiResponse-validateJSON}{\code{ModelApiResponse$validateJSON()}} +\item \href{#method-ModelApiResponse-toString}{\code{ModelApiResponse$toString()}} +\item \href{#method-ModelApiResponse-clone}{\code{ModelApiResponse$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new ModelApiResponse class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$new(code = NULL, type = NULL, message = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{code}}{code} + +\item{\code{type}}{type} + +\item{\code{message}}{message} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +ModelApiResponse in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of ModelApiResponse +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of ModelApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +ModelApiResponse in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of ModelApiResponse +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of ModelApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to ModelApiResponse and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of ModelApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-ModelApiResponse-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{ModelApiResponse$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/NestedOneOf.Rd b/samples/client/petstore/R-httr2/man/NestedOneOf.Rd new file mode 100644 index 000000000000..678c1edd8d81 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/NestedOneOf.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nested_one_of.R +\docType{class} +\name{NestedOneOf} +\alias{NestedOneOf} +\title{NestedOneOf} +\format{ +An \code{R6Class} generator object +} +\description{ +NestedOneOf Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{size}}{integer [optional]} + +\item{\code{nested_pig}}{\link{Pig} [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-NestedOneOf-new}{\code{NestedOneOf$new()}} +\item \href{#method-NestedOneOf-toJSON}{\code{NestedOneOf$toJSON()}} +\item \href{#method-NestedOneOf-fromJSON}{\code{NestedOneOf$fromJSON()}} +\item \href{#method-NestedOneOf-toJSONString}{\code{NestedOneOf$toJSONString()}} +\item \href{#method-NestedOneOf-fromJSONString}{\code{NestedOneOf$fromJSONString()}} +\item \href{#method-NestedOneOf-validateJSON}{\code{NestedOneOf$validateJSON()}} +\item \href{#method-NestedOneOf-toString}{\code{NestedOneOf$toString()}} +\item \href{#method-NestedOneOf-clone}{\code{NestedOneOf$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new NestedOneOf class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$new(size = NULL, nested_pig = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{size}}{size} + +\item{\code{nested_pig}}{nested_pig} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +NestedOneOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of NestedOneOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of NestedOneOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +NestedOneOf in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of NestedOneOf +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of NestedOneOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to NestedOneOf and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of NestedOneOf +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-NestedOneOf-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{NestedOneOf$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Order.Rd b/samples/client/petstore/R-httr2/man/Order.Rd new file mode 100644 index 000000000000..951c51be0259 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Order.Rd @@ -0,0 +1,201 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/order.R +\docType{class} +\name{Order} +\alias{Order} +\title{Order} +\format{ +An \code{R6Class} generator object +} +\description{ +Order Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{petId}}{integer [optional]} + +\item{\code{quantity}}{integer [optional]} + +\item{\code{shipDate}}{character [optional]} + +\item{\code{status}}{character [optional]} + +\item{\code{complete}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Order-new}{\code{Order$new()}} +\item \href{#method-Order-toJSON}{\code{Order$toJSON()}} +\item \href{#method-Order-fromJSON}{\code{Order$fromJSON()}} +\item \href{#method-Order-toJSONString}{\code{Order$toJSONString()}} +\item \href{#method-Order-fromJSONString}{\code{Order$fromJSONString()}} +\item \href{#method-Order-validateJSON}{\code{Order$validateJSON()}} +\item \href{#method-Order-toString}{\code{Order$toString()}} +\item \href{#method-Order-clone}{\code{Order$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Order class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$new( + id = NULL, + petId = NULL, + quantity = NULL, + shipDate = NULL, + status = NULL, + complete = FALSE, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{id} + +\item{\code{petId}}{petId} + +\item{\code{quantity}}{quantity} + +\item{\code{shipDate}}{shipDate} + +\item{\code{status}}{Order Status} + +\item{\code{complete}}{complete. Default to FALSE.} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Order in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Order +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Order +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Order in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Order +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Order +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Order and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Order +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Order-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Order$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Pet.Rd b/samples/client/petstore/R-httr2/man/Pet.Rd new file mode 100644 index 000000000000..73e0a9cc08aa --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Pet.Rd @@ -0,0 +1,201 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pet.R +\docType{class} +\name{Pet} +\alias{Pet} +\title{Pet} +\format{ +An \code{R6Class} generator object +} +\description{ +Pet Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{category}}{\link{Category} [optional]} + +\item{\code{name}}{character} + +\item{\code{photoUrls}}{list( character )} + +\item{\code{tags}}{list( \link{Tag} ) [optional]} + +\item{\code{status}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Pet-new}{\code{Pet$new()}} +\item \href{#method-Pet-toJSON}{\code{Pet$toJSON()}} +\item \href{#method-Pet-fromJSON}{\code{Pet$fromJSON()}} +\item \href{#method-Pet-toJSONString}{\code{Pet$toJSONString()}} +\item \href{#method-Pet-fromJSONString}{\code{Pet$fromJSONString()}} +\item \href{#method-Pet-validateJSON}{\code{Pet$validateJSON()}} +\item \href{#method-Pet-toString}{\code{Pet$toString()}} +\item \href{#method-Pet-clone}{\code{Pet$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Pet class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$new( + name, + photoUrls, + id = NULL, + category = NULL, + tags = NULL, + status = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{name}}{name} + +\item{\code{photoUrls}}{photoUrls} + +\item{\code{id}}{id} + +\item{\code{category}}{category} + +\item{\code{tags}}{tags} + +\item{\code{status}}{pet status in the store} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Pet in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Pet in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Pet and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pet-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pet$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/PetApi.Rd b/samples/client/petstore/R-httr2/man/PetApi.Rd new file mode 100644 index 000000000000..bf4827fbdeab --- /dev/null +++ b/samples/client/petstore/R-httr2/man/PetApi.Rd @@ -0,0 +1,1055 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pet_api.R +\docType{class} +\name{PetApi} +\alias{PetApi} +\title{Pet operations} +\format{ +An \code{R6Class} generator object +} +\description{ +petstore.Pet +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Methods}{ + +\describe{ +\strong{ AddPet } \emph{ Add a new pet to the store } + + +\itemize{ +\item \emph{ @param } pet \link{Pet} +\item \emph{ @returnType } \link{Pet} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Pet +\item response headers : + +\tabular{ll}{ +} +\item status code : 405 | Invalid input + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ DeletePet } \emph{ Deletes a pet } + + +\itemize{ +\item \emph{ @param } pet_id integer +\item \emph{ @param } api_key character + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 400 | Invalid pet value + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ FindPetsByStatus } \emph{ Finds Pets by status } +Multiple status values can be provided with comma separated strings + +\itemize{ +\item \emph{ @param } status Enum < [available, pending, sold] > +\item \emph{ @returnType } list( \link{Pet} ) \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : array[Pet] +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid status value + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ FindPetsByTags } \emph{ Finds Pets by tags } +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +\itemize{ +\item \emph{ @param } tags list( character ) +\item \emph{ @returnType } list( \link{Pet} ) \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : array[Pet] +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid tag value + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ GetPetById } \emph{ Find pet by ID } +Returns a single pet + +\itemize{ +\item \emph{ @param } pet_id integer +\item \emph{ @returnType } \link{Pet} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Pet +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid ID supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | Pet not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ GetPetByIdStreaming } \emph{ Find pet by ID (streaming) } +Returns a single pet + +\itemize{ +\item \emph{ @param } pet_id integer +\item \emph{ @returnType } \link{Pet} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Pet +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid ID supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | Pet not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ UpdatePet } \emph{ Update an existing pet } + + +\itemize{ +\item \emph{ @param } pet \link{Pet} +\item \emph{ @returnType } \link{Pet} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Pet +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid ID supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | Pet not found + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 405 | Validation exception + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ UpdatePetWithForm } \emph{ Updates a pet in the store with form data } + + +\itemize{ +\item \emph{ @param } pet_id integer +\item \emph{ @param } name character +\item \emph{ @param } status character + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 405 | Invalid input + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ UploadFile } \emph{ uploads an image } + + +\itemize{ +\item \emph{ @param } pet_id integer +\item \emph{ @param } additional_metadata character +\item \emph{ @param } file data.frame +\item \emph{ @returnType } \link{ModelApiResponse} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : ModelApiResponse +\item response headers : + +\tabular{ll}{ +} +} + +} +} + +\examples{ +\dontrun{ +#################### AddPet #################### + +library(petstore) +var.pet <- Pet$new() # Pet | Pet object that needs to be added to the store + +#Add a new pet to the store +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$AddPet(var.pet), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### DeletePet #################### + +library(petstore) +var.pet_id <- 56 # integer | Pet id to delete +var.api_key <- 'api_key_example' # character | + +#Deletes a pet +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$DeletePet(var.pet_id, api_key=var.api_key), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### FindPetsByStatus #################### + +library(petstore) +var.status <- ['status_example'] # array[character] | Status values that need to be considered for filter + +#Finds Pets by status +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$FindPetsByStatus(var.status), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### FindPetsByTags #################### + +library(petstore) +var.tags <- ['tags_example'] # array[character] | Tags to filter by + +#Finds Pets by tags +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$FindPetsByTags(var.tags), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### GetPetById #################### + +library(petstore) +var.pet_id <- 56 # integer | ID of pet to return + +#Find pet by ID +api.instance <- PetApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$GetPetById(var.pet_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### GetPetByIdStreaming #################### + +library(petstore) +var.pet_id <- 56 # integer | ID of pet to return + +#Find pet by ID (streaming) +api.instance <- PetApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$GetPetByIdStreaming(var.pet_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### UpdatePet #################### + +library(petstore) +var.pet <- Pet$new() # Pet | Pet object that needs to be added to the store + +#Update an existing pet +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$UpdatePet(var.pet), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### UpdatePetWithForm #################### + +library(petstore) +var.pet_id <- 56 # integer | ID of pet that needs to be updated +var.name <- 'name_example' # character | Updated name of the pet +var.status <- 'status_example' # character | Updated status of the pet + +#Updates a pet in the store with form data +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$UpdatePetWithForm(var.pet_id, name=var.name, status=var.status), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### UploadFile #################### + +library(petstore) +var.pet_id <- 56 # integer | ID of pet to update +var.additional_metadata <- 'additional_metadata_example' # character | Additional data to pass to server +var.file <- File.new('/path/to/file') # data.frame | file to upload + +#uploads an image +api.instance <- PetApi$new() + +# Configure OAuth2 access token for authorization: petstore_auth +api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; + +result <- tryCatch( + api.instance$UploadFile(var.pet_id, additional_metadata=var.additional_metadata, file=var.file), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{Handles the client-server communication.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-PetApi-new}{\code{PetApi$new()}} +\item \href{#method-PetApi-AddPet}{\code{PetApi$AddPet()}} +\item \href{#method-PetApi-AddPetWithHttpInfo}{\code{PetApi$AddPetWithHttpInfo()}} +\item \href{#method-PetApi-DeletePet}{\code{PetApi$DeletePet()}} +\item \href{#method-PetApi-DeletePetWithHttpInfo}{\code{PetApi$DeletePetWithHttpInfo()}} +\item \href{#method-PetApi-FindPetsByStatus}{\code{PetApi$FindPetsByStatus()}} +\item \href{#method-PetApi-FindPetsByStatusWithHttpInfo}{\code{PetApi$FindPetsByStatusWithHttpInfo()}} +\item \href{#method-PetApi-FindPetsByTags}{\code{PetApi$FindPetsByTags()}} +\item \href{#method-PetApi-FindPetsByTagsWithHttpInfo}{\code{PetApi$FindPetsByTagsWithHttpInfo()}} +\item \href{#method-PetApi-GetPetById}{\code{PetApi$GetPetById()}} +\item \href{#method-PetApi-GetPetByIdWithHttpInfo}{\code{PetApi$GetPetByIdWithHttpInfo()}} +\item \href{#method-PetApi-GetPetByIdStreaming}{\code{PetApi$GetPetByIdStreaming()}} +\item \href{#method-PetApi-GetPetByIdStreamingWithHttpInfo}{\code{PetApi$GetPetByIdStreamingWithHttpInfo()}} +\item \href{#method-PetApi-UpdatePet}{\code{PetApi$UpdatePet()}} +\item \href{#method-PetApi-UpdatePetWithHttpInfo}{\code{PetApi$UpdatePetWithHttpInfo()}} +\item \href{#method-PetApi-UpdatePetWithForm}{\code{PetApi$UpdatePetWithForm()}} +\item \href{#method-PetApi-UpdatePetWithFormWithHttpInfo}{\code{PetApi$UpdatePetWithFormWithHttpInfo()}} +\item \href{#method-PetApi-UploadFile}{\code{PetApi$UploadFile()}} +\item \href{#method-PetApi-UploadFileWithHttpInfo}{\code{PetApi$UploadFileWithHttpInfo()}} +\item \href{#method-PetApi-clone}{\code{PetApi$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new PetApi. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$new(api_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{An instance of API client.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-AddPet}{}}} +\subsection{Method \code{AddPet()}}{ +Add a new pet to the store +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$AddPet(pet, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet}}{Pet object that needs to be added to the store} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-AddPetWithHttpInfo}{}}} +\subsection{Method \code{AddPetWithHttpInfo()}}{ +Add a new pet to the store +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$AddPetWithHttpInfo(pet, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet}}{Pet object that needs to be added to the store} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Pet) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-DeletePet}{}}} +\subsection{Method \code{DeletePet()}}{ +Deletes a pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$DeletePet(pet_id, api_key = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{Pet id to delete} + +\item{\code{api_key}}{(optional)} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-DeletePetWithHttpInfo}{}}} +\subsection{Method \code{DeletePetWithHttpInfo()}}{ +Deletes a pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$DeletePetWithHttpInfo(pet_id, api_key = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{Pet id to delete} + +\item{\code{api_key}}{(optional)} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-FindPetsByStatus}{}}} +\subsection{Method \code{FindPetsByStatus()}}{ +Finds Pets by status +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$FindPetsByStatus(status, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{status}}{Status values that need to be considered for filter} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +array[Pet] +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-FindPetsByStatusWithHttpInfo}{}}} +\subsection{Method \code{FindPetsByStatusWithHttpInfo()}}{ +Finds Pets by status +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$FindPetsByStatusWithHttpInfo(status, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{status}}{Status values that need to be considered for filter} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (array[Pet]) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-FindPetsByTags}{}}} +\subsection{Method \code{FindPetsByTags()}}{ +Finds Pets by tags +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$FindPetsByTags(tags, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{tags}}{Tags to filter by} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +array[Pet] +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-FindPetsByTagsWithHttpInfo}{}}} +\subsection{Method \code{FindPetsByTagsWithHttpInfo()}}{ +Finds Pets by tags +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$FindPetsByTagsWithHttpInfo(tags, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{tags}}{Tags to filter by} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (array[Pet]) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-GetPetById}{}}} +\subsection{Method \code{GetPetById()}}{ +Find pet by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$GetPetById(pet_id, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to return} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-GetPetByIdWithHttpInfo}{}}} +\subsection{Method \code{GetPetByIdWithHttpInfo()}}{ +Find pet by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$GetPetByIdWithHttpInfo(pet_id, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to return} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Pet) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-GetPetByIdStreaming}{}}} +\subsection{Method \code{GetPetByIdStreaming()}}{ +Find pet by ID (streaming) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$GetPetByIdStreaming( + pet_id, + stream_callback = NULL, + data_file = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to return} + +\item{\code{stream_callback}}{(optional) callback function to process the data stream} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-GetPetByIdStreamingWithHttpInfo}{}}} +\subsection{Method \code{GetPetByIdStreamingWithHttpInfo()}}{ +Find pet by ID (streaming) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$GetPetByIdStreamingWithHttpInfo( + pet_id, + stream_callback = NULL, + data_file = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to return} + +\item{\code{stream_callback}}{(optional) callback function to process the data stream} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Pet) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UpdatePet}{}}} +\subsection{Method \code{UpdatePet()}}{ +Update an existing pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UpdatePet(pet, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet}}{Pet object that needs to be added to the store} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Pet +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UpdatePetWithHttpInfo}{}}} +\subsection{Method \code{UpdatePetWithHttpInfo()}}{ +Update an existing pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UpdatePetWithHttpInfo(pet, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet}}{Pet object that needs to be added to the store} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Pet) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UpdatePetWithForm}{}}} +\subsection{Method \code{UpdatePetWithForm()}}{ +Updates a pet in the store with form data +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UpdatePetWithForm(pet_id, name = NULL, status = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet that needs to be updated} + +\item{\code{name}}{(optional) Updated name of the pet} + +\item{\code{status}}{(optional) Updated status of the pet} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UpdatePetWithFormWithHttpInfo}{}}} +\subsection{Method \code{UpdatePetWithFormWithHttpInfo()}}{ +Updates a pet in the store with form data +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UpdatePetWithFormWithHttpInfo(pet_id, name = NULL, status = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet that needs to be updated} + +\item{\code{name}}{(optional) Updated name of the pet} + +\item{\code{status}}{(optional) Updated status of the pet} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UploadFile}{}}} +\subsection{Method \code{UploadFile()}}{ +uploads an image +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UploadFile( + pet_id, + additional_metadata = NULL, + file = NULL, + data_file = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to update} + +\item{\code{additional_metadata}}{(optional) Additional data to pass to server} + +\item{\code{file}}{(optional) file to upload} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +ModelApiResponse +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-UploadFileWithHttpInfo}{}}} +\subsection{Method \code{UploadFileWithHttpInfo()}}{ +uploads an image +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$UploadFileWithHttpInfo( + pet_id, + additional_metadata = NULL, + file = NULL, + data_file = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{pet_id}}{ID of pet to update} + +\item{\code{additional_metadata}}{(optional) Additional data to pass to server} + +\item{\code{file}}{(optional) file to upload} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (ModelApiResponse) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-PetApi-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{PetApi$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Pig.Rd b/samples/client/petstore/R-httr2/man/Pig.Rd new file mode 100644 index 000000000000..6006f995a341 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Pig.Rd @@ -0,0 +1,156 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pig.R +\docType{class} +\name{Pig} +\alias{Pig} +\title{Pig} +\format{ +An \code{R6Class} generator object +} +\description{ +Pig Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{actual_instance}}{the object stored in this instance.} + +\item{\code{actual_type}}{the type of the object stored in this instance.} + +\item{\code{one_of}}{a list of object types defined in the oneOf schema. +Initialize a new Pig.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Pig-new}{\code{Pig$new()}} +\item \href{#method-Pig-fromJSON}{\code{Pig$fromJSON()}} +\item \href{#method-Pig-toJSONString}{\code{Pig$toJSONString()}} +\item \href{#method-Pig-toJSON}{\code{Pig$toJSON()}} +\item \href{#method-Pig-validateJSON}{\code{Pig$validateJSON()}} +\item \href{#method-Pig-toString}{\code{Pig$toString()}} +\item \href{#method-Pig-clone}{\code{Pig$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Pig. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$new(instance = NULL)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{instance}}{an instance of the object defined in the oneOf schemas: "BasquePig", "DanishPig"} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Pig. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$fromJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{The input JSON.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +An instance of Pig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +Serialize Pig to JSON string. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +JSON string representation of the Pig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +Serialize Pig to JSON. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +JSON representation of the Pig. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate the input JSON with respect to Pig and +throw exception if invalid. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{The input JSON.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-toString}{}}} +\subsection{Method \code{toString()}}{ +Returns the string representation of the instance. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +The string representation of the instance. +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Pig-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Pig$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Special.Rd b/samples/client/petstore/R-httr2/man/Special.Rd new file mode 100644 index 000000000000..8c42418b09c0 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Special.Rd @@ -0,0 +1,201 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/special.R +\docType{class} +\name{Special} +\alias{Special} +\title{Special} +\format{ +An \code{R6Class} generator object +} +\description{ +Special Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{item_self}}{integer [optional]} + +\item{\code{item_private}}{character [optional]} + +\item{\code{item_super}}{character [optional]} + +\item{\code{123_number}}{character [optional]} + +\item{\code{array[test]}}{character [optional]} + +\item{\code{empty_string}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Special-new}{\code{Special$new()}} +\item \href{#method-Special-toJSON}{\code{Special$toJSON()}} +\item \href{#method-Special-fromJSON}{\code{Special$fromJSON()}} +\item \href{#method-Special-toJSONString}{\code{Special$toJSONString()}} +\item \href{#method-Special-fromJSONString}{\code{Special$fromJSONString()}} +\item \href{#method-Special-validateJSON}{\code{Special$validateJSON()}} +\item \href{#method-Special-toString}{\code{Special$toString()}} +\item \href{#method-Special-clone}{\code{Special$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Special class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$new( + item_self = NULL, + item_private = NULL, + item_super = NULL, + `123_number` = NULL, + `array[test]` = NULL, + empty_string = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{item_self}}{item_self} + +\item{\code{item_private}}{item_private} + +\item{\code{item_super}}{item_super} + +\item{\code{123_number}}{123_number} + +\item{\code{array[test]}}{array[test]} + +\item{\code{empty_string}}{empty_string} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Special in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Special +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Special +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Special in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Special +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Special +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Special and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Special +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Special-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Special$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/StoreApi.Rd b/samples/client/petstore/R-httr2/man/StoreApi.Rd new file mode 100644 index 000000000000..2423e1819e05 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/StoreApi.Rd @@ -0,0 +1,468 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/store_api.R +\docType{class} +\name{StoreApi} +\alias{StoreApi} +\title{Store operations} +\format{ +An \code{R6Class} generator object +} +\description{ +petstore.Store +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Methods}{ + +\describe{ +\strong{ DeleteOrder } \emph{ Delete purchase order by ID } +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +\itemize{ +\item \emph{ @param } order_id character + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 400 | Invalid ID supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | Order not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ GetInventory } \emph{ Returns pet inventories by status } +Returns a map of status codes to quantities + +\itemize{ + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : map(integer) +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ GetOrderById } \emph{ Find purchase order by ID } +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +\itemize{ +\item \emph{ @param } order_id integer +\item \emph{ @returnType } \link{Order} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Order +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid ID supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | Order not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ PlaceOrder } \emph{ Place an order for a pet } + + +\itemize{ +\item \emph{ @param } order \link{Order} +\item \emph{ @returnType } \link{Order} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : Order +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid Order + + +\item response headers : + +\tabular{ll}{ +} +} + +} +} + +\examples{ +\dontrun{ +#################### DeleteOrder #################### + +library(petstore) +var.order_id <- 'order_id_example' # character | ID of the order that needs to be deleted + +#Delete purchase order by ID +api.instance <- StoreApi$new() + +result <- tryCatch( + api.instance$DeleteOrder(var.order_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### GetInventory #################### + +library(petstore) + +#Returns pet inventories by status +api.instance <- StoreApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$GetInventory(), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### GetOrderById #################### + +library(petstore) +var.order_id <- 56 # integer | ID of pet that needs to be fetched + +#Find purchase order by ID +api.instance <- StoreApi$new() + +result <- tryCatch( + api.instance$GetOrderById(var.order_id), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### PlaceOrder #################### + +library(petstore) +var.order <- Order$new() # Order | order placed for purchasing the pet + +#Place an order for a pet +api.instance <- StoreApi$new() + +result <- tryCatch( + api.instance$PlaceOrder(var.order), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{Handles the client-server communication.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-StoreApi-new}{\code{StoreApi$new()}} +\item \href{#method-StoreApi-DeleteOrder}{\code{StoreApi$DeleteOrder()}} +\item \href{#method-StoreApi-DeleteOrderWithHttpInfo}{\code{StoreApi$DeleteOrderWithHttpInfo()}} +\item \href{#method-StoreApi-GetInventory}{\code{StoreApi$GetInventory()}} +\item \href{#method-StoreApi-GetInventoryWithHttpInfo}{\code{StoreApi$GetInventoryWithHttpInfo()}} +\item \href{#method-StoreApi-GetOrderById}{\code{StoreApi$GetOrderById()}} +\item \href{#method-StoreApi-GetOrderByIdWithHttpInfo}{\code{StoreApi$GetOrderByIdWithHttpInfo()}} +\item \href{#method-StoreApi-PlaceOrder}{\code{StoreApi$PlaceOrder()}} +\item \href{#method-StoreApi-PlaceOrderWithHttpInfo}{\code{StoreApi$PlaceOrderWithHttpInfo()}} +\item \href{#method-StoreApi-clone}{\code{StoreApi$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new StoreApi. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$new(api_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{An instance of API client.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-DeleteOrder}{}}} +\subsection{Method \code{DeleteOrder()}}{ +Delete purchase order by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$DeleteOrder(order_id, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order_id}}{ID of the order that needs to be deleted} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-DeleteOrderWithHttpInfo}{}}} +\subsection{Method \code{DeleteOrderWithHttpInfo()}}{ +Delete purchase order by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$DeleteOrderWithHttpInfo(order_id, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order_id}}{ID of the order that needs to be deleted} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-GetInventory}{}}} +\subsection{Method \code{GetInventory()}}{ +Returns pet inventories by status +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$GetInventory(data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +map(integer) +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-GetInventoryWithHttpInfo}{}}} +\subsection{Method \code{GetInventoryWithHttpInfo()}}{ +Returns pet inventories by status +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$GetInventoryWithHttpInfo(data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (map(integer)) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-GetOrderById}{}}} +\subsection{Method \code{GetOrderById()}}{ +Find purchase order by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$GetOrderById(order_id, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order_id}}{ID of pet that needs to be fetched} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Order +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-GetOrderByIdWithHttpInfo}{}}} +\subsection{Method \code{GetOrderByIdWithHttpInfo()}}{ +Find purchase order by ID +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$GetOrderByIdWithHttpInfo(order_id, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order_id}}{ID of pet that needs to be fetched} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Order) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-PlaceOrder}{}}} +\subsection{Method \code{PlaceOrder()}}{ +Place an order for a pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$PlaceOrder(order, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order}}{order placed for purchasing the pet} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Order +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-PlaceOrderWithHttpInfo}{}}} +\subsection{Method \code{PlaceOrderWithHttpInfo()}}{ +Place an order for a pet +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$PlaceOrderWithHttpInfo(order, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{order}}{order placed for purchasing the pet} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (Order) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-StoreApi-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{StoreApi$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/Tag.Rd b/samples/client/petstore/R-httr2/man/Tag.Rd new file mode 100644 index 000000000000..2aea0440ef9c --- /dev/null +++ b/samples/client/petstore/R-httr2/man/Tag.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tag.R +\docType{class} +\name{Tag} +\alias{Tag} +\title{Tag} +\format{ +An \code{R6Class} generator object +} +\description{ +Tag Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{name}}{character [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-Tag-new}{\code{Tag$new()}} +\item \href{#method-Tag-toJSON}{\code{Tag$toJSON()}} +\item \href{#method-Tag-fromJSON}{\code{Tag$fromJSON()}} +\item \href{#method-Tag-toJSONString}{\code{Tag$toJSONString()}} +\item \href{#method-Tag-fromJSONString}{\code{Tag$fromJSONString()}} +\item \href{#method-Tag-validateJSON}{\code{Tag$validateJSON()}} +\item \href{#method-Tag-toString}{\code{Tag$toString()}} +\item \href{#method-Tag-clone}{\code{Tag$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new Tag class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$new(id = NULL, name = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{id} + +\item{\code{name}}{name} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Tag in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of Tag +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Tag +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Tag in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of Tag +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of Tag +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to Tag and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of Tag +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-Tag-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{Tag$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/UpdatePetRequest.Rd b/samples/client/petstore/R-httr2/man/UpdatePetRequest.Rd new file mode 100644 index 000000000000..8cc115d284e3 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/UpdatePetRequest.Rd @@ -0,0 +1,177 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/update_pet_request.R +\docType{class} +\name{UpdatePetRequest} +\alias{UpdatePetRequest} +\title{UpdatePetRequest} +\format{ +An \code{R6Class} generator object +} +\description{ +UpdatePetRequest Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{jsonData}}{\link{Pet} [optional]} + +\item{\code{binaryDataN2Information}}{data.frame [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-UpdatePetRequest-new}{\code{UpdatePetRequest$new()}} +\item \href{#method-UpdatePetRequest-toJSON}{\code{UpdatePetRequest$toJSON()}} +\item \href{#method-UpdatePetRequest-fromJSON}{\code{UpdatePetRequest$fromJSON()}} +\item \href{#method-UpdatePetRequest-toJSONString}{\code{UpdatePetRequest$toJSONString()}} +\item \href{#method-UpdatePetRequest-fromJSONString}{\code{UpdatePetRequest$fromJSONString()}} +\item \href{#method-UpdatePetRequest-validateJSON}{\code{UpdatePetRequest$validateJSON()}} +\item \href{#method-UpdatePetRequest-toString}{\code{UpdatePetRequest$toString()}} +\item \href{#method-UpdatePetRequest-clone}{\code{UpdatePetRequest$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new UpdatePetRequest class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$new(jsonData = NULL, binaryDataN2Information = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{jsonData}}{jsonData} + +\item{\code{binaryDataN2Information}}{binaryDataN2Information} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +UpdatePetRequest in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of UpdatePetRequest +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of UpdatePetRequest +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +UpdatePetRequest in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of UpdatePetRequest +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of UpdatePetRequest +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to UpdatePetRequest and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of UpdatePetRequest +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UpdatePetRequest-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UpdatePetRequest$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/User.Rd b/samples/client/petstore/R-httr2/man/User.Rd new file mode 100644 index 000000000000..3646b8d8aab4 --- /dev/null +++ b/samples/client/petstore/R-httr2/man/User.Rd @@ -0,0 +1,211 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/user.R +\docType{class} +\name{User} +\alias{User} +\title{User} +\format{ +An \code{R6Class} generator object +} +\description{ +User Class +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{integer [optional]} + +\item{\code{username}}{character [optional]} + +\item{\code{firstName}}{character [optional]} + +\item{\code{lastName}}{character [optional]} + +\item{\code{email}}{character [optional]} + +\item{\code{password}}{character [optional]} + +\item{\code{phone}}{character [optional]} + +\item{\code{userStatus}}{integer [optional]} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-User-new}{\code{User$new()}} +\item \href{#method-User-toJSON}{\code{User$toJSON()}} +\item \href{#method-User-fromJSON}{\code{User$fromJSON()}} +\item \href{#method-User-toJSONString}{\code{User$toJSONString()}} +\item \href{#method-User-fromJSONString}{\code{User$fromJSONString()}} +\item \href{#method-User-validateJSON}{\code{User$validateJSON()}} +\item \href{#method-User-toString}{\code{User$toString()}} +\item \href{#method-User-clone}{\code{User$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new User class. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$new( + id = NULL, + username = NULL, + firstName = NULL, + lastName = NULL, + email = NULL, + password = NULL, + phone = NULL, + userStatus = NULL, + ... +)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{id}}{id} + +\item{\code{username}}{username} + +\item{\code{firstName}}{firstName} + +\item{\code{lastName}}{lastName} + +\item{\code{email}}{email} + +\item{\code{password}}{password} + +\item{\code{phone}}{phone} + +\item{\code{userStatus}}{User Status} + +\item{\code{...}}{Other optional arguments.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-toJSON}{}}} +\subsection{Method \code{toJSON()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$toJSON()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +User in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-fromJSON}{}}} +\subsection{Method \code{fromJSON()}}{ +Deserialize JSON string into an instance of User +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$fromJSON(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of User +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-toJSONString}{}}} +\subsection{Method \code{toJSONString()}}{ +To JSON String +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$toJSONString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +User in JSON format +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-fromJSONString}{}}} +\subsection{Method \code{fromJSONString()}}{ +Deserialize JSON string into an instance of User +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$fromJSONString(input_json)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input_json}}{the JSON input} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +the instance of User +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-validateJSON}{}}} +\subsection{Method \code{validateJSON()}}{ +Validate JSON input with respect to User and throw an exception if invalid +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$validateJSON(input)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{input}}{the JSON input} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-toString}{}}} +\subsection{Method \code{toString()}}{ +To string (JSON format) +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$toString()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +String representation of User +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-User-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{User$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/man/UserApi.Rd b/samples/client/petstore/R-httr2/man/UserApi.Rd new file mode 100644 index 000000000000..aa33773d3adf --- /dev/null +++ b/samples/client/petstore/R-httr2/man/UserApi.Rd @@ -0,0 +1,842 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/user_api.R +\docType{class} +\name{UserApi} +\alias{UserApi} +\title{User operations} +\format{ +An \code{R6Class} generator object +} +\description{ +petstore.User +} +\details{ +OpenAPI Petstore + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +The version of the OpenAPI document: 1.0.0 +Generated by: https://openapi-generator.tech +} +\section{Methods}{ + +\describe{ +\strong{ CreateUser } \emph{ Create user } +This can only be done by the logged in user. + +\itemize{ +\item \emph{ @param } user \link{User} + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 0 | successful operation + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ CreateUsersWithArrayInput } \emph{ Creates list of users with given input array } + + +\itemize{ +\item \emph{ @param } user list( \link{User} ) + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 0 | successful operation + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ CreateUsersWithListInput } \emph{ Creates list of users with given input array } + + +\itemize{ +\item \emph{ @param } user list( \link{User} ) + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 0 | successful operation + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ DeleteUser } \emph{ Delete user } +This can only be done by the logged in user. + +\itemize{ +\item \emph{ @param } username character + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 400 | Invalid username supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | User not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ GetUserByName } \emph{ Get user by user name } + + +\itemize{ +\item \emph{ @param } username character +\item \emph{ @returnType } \link{User} \cr + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : User +\item response headers : + +\tabular{ll}{ +} +\item status code : 400 | Invalid username supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | User not found + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ LoginUser } \emph{ Logs user into the system } + + +\itemize{ +\item \emph{ @param } username character +\item \emph{ @param } password character + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 200 | successful operation + +\item return type : character +\item response headers : + +\tabular{ll}{ +Set-Cookie \tab Cookie authentication key for use with the `api_key` apiKey authentication. \cr +X-Rate-Limit \tab calls per hour allowed by the user \cr +X-Expires-After \tab date in UTC when token expires \cr +} +\item status code : 400 | Invalid username/password supplied + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ LogoutUser } \emph{ Logs out current logged in user session } + + +\itemize{ + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 0 | successful operation + + +\item response headers : + +\tabular{ll}{ +} +} + +\strong{ UpdateUser } \emph{ Updated user } +This can only be done by the logged in user. + +\itemize{ +\item \emph{ @param } username character +\item \emph{ @param } user \link{User} + +\item On encountering errors, an error of subclass ApiException will be thrown. + +\item status code : 400 | Invalid user supplied + + +\item response headers : + +\tabular{ll}{ +} +\item status code : 404 | User not found + + +\item response headers : + +\tabular{ll}{ +} +} + +} +} + +\examples{ +\dontrun{ +#################### CreateUser #################### + +library(petstore) +var.user <- User$new() # User | Created user object + +#Create user +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$CreateUser(var.user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### CreateUsersWithArrayInput #################### + +library(petstore) +var.user <- [User$new()] # array[User] | List of user object + +#Creates list of users with given input array +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$CreateUsersWithArrayInput(var.user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### CreateUsersWithListInput #################### + +library(petstore) +var.user <- [User$new()] # array[User] | List of user object + +#Creates list of users with given input array +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$CreateUsersWithListInput(var.user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### DeleteUser #################### + +library(petstore) +var.username <- 'username_example' # character | The name that needs to be deleted + +#Delete user +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$DeleteUser(var.username), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### GetUserByName #################### + +library(petstore) +var.username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing. + +#Get user by user name +api.instance <- UserApi$new() + +result <- tryCatch( + api.instance$GetUserByName(var.username), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### LoginUser #################### + +library(petstore) +var.username <- 'username_example' # character | The user name for login +var.password <- 'password_example' # character | The password for login in clear text + +#Logs user into the system +api.instance <- UserApi$new() + +result <- tryCatch( + api.instance$LoginUser(var.username, var.password), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# deserialized response object +response.object <- result$content +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### LogoutUser #################### + +library(petstore) + +#Logs out current logged in user session +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$LogoutUser(), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +#################### UpdateUser #################### + +library(petstore) +var.username <- 'username_example' # character | name that need to be deleted +var.user <- User$new() # User | Updated user object + +#Updated user +api.instance <- UserApi$new() + +#Configure API key authorization: api_key +api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; + +result <- tryCatch( + api.instance$UpdateUser(var.username, var.user), + ApiException = function(ex) ex + ) +# In case of error, print the error object +if(!is.null(result$ApiException)) { + cat(result$ApiException$toString()) +} else { +# response headers +response.headers <- result$response$headers +# response status code +response.status.code <- result$response$status_code +} + + +} +} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{Handles the client-server communication.} +} +\if{html}{\out{
}} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-UserApi-new}{\code{UserApi$new()}} +\item \href{#method-UserApi-CreateUser}{\code{UserApi$CreateUser()}} +\item \href{#method-UserApi-CreateUserWithHttpInfo}{\code{UserApi$CreateUserWithHttpInfo()}} +\item \href{#method-UserApi-CreateUsersWithArrayInput}{\code{UserApi$CreateUsersWithArrayInput()}} +\item \href{#method-UserApi-CreateUsersWithArrayInputWithHttpInfo}{\code{UserApi$CreateUsersWithArrayInputWithHttpInfo()}} +\item \href{#method-UserApi-CreateUsersWithListInput}{\code{UserApi$CreateUsersWithListInput()}} +\item \href{#method-UserApi-CreateUsersWithListInputWithHttpInfo}{\code{UserApi$CreateUsersWithListInputWithHttpInfo()}} +\item \href{#method-UserApi-DeleteUser}{\code{UserApi$DeleteUser()}} +\item \href{#method-UserApi-DeleteUserWithHttpInfo}{\code{UserApi$DeleteUserWithHttpInfo()}} +\item \href{#method-UserApi-GetUserByName}{\code{UserApi$GetUserByName()}} +\item \href{#method-UserApi-GetUserByNameWithHttpInfo}{\code{UserApi$GetUserByNameWithHttpInfo()}} +\item \href{#method-UserApi-LoginUser}{\code{UserApi$LoginUser()}} +\item \href{#method-UserApi-LoginUserWithHttpInfo}{\code{UserApi$LoginUserWithHttpInfo()}} +\item \href{#method-UserApi-LogoutUser}{\code{UserApi$LogoutUser()}} +\item \href{#method-UserApi-LogoutUserWithHttpInfo}{\code{UserApi$LogoutUserWithHttpInfo()}} +\item \href{#method-UserApi-UpdateUser}{\code{UserApi$UpdateUser()}} +\item \href{#method-UserApi-UpdateUserWithHttpInfo}{\code{UserApi$UpdateUserWithHttpInfo()}} +\item \href{#method-UserApi-clone}{\code{UserApi$clone()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-new}{}}} +\subsection{Method \code{new()}}{ +Initialize a new UserApi. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$new(api_client)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{api_client}}{An instance of API client.} +} +\if{html}{\out{
}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUser}{}}} +\subsection{Method \code{CreateUser()}}{ +Create user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUser(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{Created user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUserWithHttpInfo}{}}} +\subsection{Method \code{CreateUserWithHttpInfo()}}{ +Create user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUserWithHttpInfo(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{Created user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUsersWithArrayInput}{}}} +\subsection{Method \code{CreateUsersWithArrayInput()}}{ +Creates list of users with given input array +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUsersWithArrayInput(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{List of user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUsersWithArrayInputWithHttpInfo}{}}} +\subsection{Method \code{CreateUsersWithArrayInputWithHttpInfo()}}{ +Creates list of users with given input array +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUsersWithArrayInputWithHttpInfo(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{List of user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUsersWithListInput}{}}} +\subsection{Method \code{CreateUsersWithListInput()}}{ +Creates list of users with given input array +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUsersWithListInput(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{List of user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-CreateUsersWithListInputWithHttpInfo}{}}} +\subsection{Method \code{CreateUsersWithListInputWithHttpInfo()}}{ +Creates list of users with given input array +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$CreateUsersWithListInputWithHttpInfo(user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{user}}{List of user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-DeleteUser}{}}} +\subsection{Method \code{DeleteUser()}}{ +Delete user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$DeleteUser(username, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The name that needs to be deleted} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-DeleteUserWithHttpInfo}{}}} +\subsection{Method \code{DeleteUserWithHttpInfo()}}{ +Delete user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$DeleteUserWithHttpInfo(username, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The name that needs to be deleted} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-GetUserByName}{}}} +\subsection{Method \code{GetUserByName()}}{ +Get user by user name +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$GetUserByName(username, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The name that needs to be fetched. Use user1 for testing.} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +User +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-GetUserByNameWithHttpInfo}{}}} +\subsection{Method \code{GetUserByNameWithHttpInfo()}}{ +Get user by user name +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$GetUserByNameWithHttpInfo(username, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The name that needs to be fetched. Use user1 for testing.} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (User) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-LoginUser}{}}} +\subsection{Method \code{LoginUser()}}{ +Logs user into the system +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$LoginUser(username, password, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The user name for login} + +\item{\code{password}}{The password for login in clear text} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +character +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-LoginUserWithHttpInfo}{}}} +\subsection{Method \code{LoginUserWithHttpInfo()}}{ +Logs user into the system +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$LoginUserWithHttpInfo(username, password, data_file = NULL, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{The user name for login} + +\item{\code{password}}{The password for login in clear text} + +\item{\code{data_file}}{(optional) name of the data file to save the result} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (character) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-LogoutUser}{}}} +\subsection{Method \code{LogoutUser()}}{ +Logs out current logged in user session +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$LogoutUser(...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-LogoutUserWithHttpInfo}{}}} +\subsection{Method \code{LogoutUserWithHttpInfo()}}{ +Logs out current logged in user session +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$LogoutUserWithHttpInfo(...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-UpdateUser}{}}} +\subsection{Method \code{UpdateUser()}}{ +Updated user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$UpdateUser(username, user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{name that need to be deleted} + +\item{\code{user}}{Updated user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +void +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-UpdateUserWithHttpInfo}{}}} +\subsection{Method \code{UpdateUserWithHttpInfo()}}{ +Updated user +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$UpdateUserWithHttpInfo(username, user, ...)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{username}}{name that need to be deleted} + +\item{\code{user}}{Updated user object} + +\item{\code{...}}{Other optional arguments} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +API response (void) with additional information such as HTTP status code, headers +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-UserApi-clone}{}}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{UserApi$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/samples/client/petstore/R-httr2/pom.xml b/samples/client/petstore/R-httr2/pom.xml new file mode 100644 index 000000000000..9b460d77244b --- /dev/null +++ b/samples/client/petstore/R-httr2/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + org.openapitools + RHttr2ClientTests + pom + 1.0-SNAPSHOT + R Httr2 Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + nose-test + integration-test + + exec + + + bash + + build_and_test.bash + + + + + + + + diff --git a/samples/client/petstore/R-httr2/test_petstore.R b/samples/client/petstore/R-httr2/test_petstore.R new file mode 100644 index 000000000000..ed6479680ee5 --- /dev/null +++ b/samples/client/petstore/R-httr2/test_petstore.R @@ -0,0 +1,141 @@ + +install.packages("petstore_1.0.0.tar.gz",repos=NULL, type="source") +library(petstore) + +var_pet <- Pet$new("name_example", list("photoUrls_example"), 56, Category$new(56, "name_example"), list(Tag$new(56, "name_example")), "available") # Pet | Pet object that needs to be added to the store + +#Add a new pet to the store +api_instance <- PetApi$new() +# Configure OAuth2 access token for authorization: petstore_auth +api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$AddPet(var_pet, data_file = "result.txt"), + api_instance$AddPet(var_pet), + ApiException = function(ex) ex + ) + +var_pet_id <- 56 # integer | ID of pet to return + +#Find pet by ID (streaming) +api_instance <- PetApi$new() +# Configure API key authorization: api_key +api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +result <- tryCatch( + # to save the result into a file, simply add the optional `data_file` parameter, e.g. + # api_instance$GetPetByIdStreaming(var_pet_id, data_file = "result.txt"), + api_instance$GetPetByIdStreaming(var_pet_id, stream_callback = function(x) { print(x) }), + ApiException = function(ex) ex + ) +# In case of error, print the error object +#if (!is.null(result$ApiException)) { +# cat(result$ApiException$toString()) +#} #else { +# # deserialized response object +# response.object <- result$content +# # response headers +# response.headers <- result$response$headers +# # response status code +# response.status.code <- result$response$status_code +#} + + +##errorMsg <- "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}" +###errorMsg <- '{"code": 404, "message": "Not found"}' +##a <- ModelApiResponse$new()$fromJSONString(errorMsg) +##dput(a) +## +##var_pet_id <- 1231256 # integer | ID of pet to return +## +###Find pet by ID +##api_instance <- PetApi$new() +### Configure API key authorization: api_key +##api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +##result <- tryCatch( +## api_instance$GetPetById(var_pet_id), +## ApiException = function(ex) ex +## ) +### In case of error, print the error object +##if(!is.null(result$ApiException)) { +## cat(result$ApiException$toString()) +##} else { +## # deserialized response object +## response.object <- result$content +## # response headers +## response.headers <- result$response$headers +## # response status code +## response.status.code <- result$response$status_code +##} +# +#json2 <- +#'{"name": "pet", "photoUrls" : ["http://a.com", "http://b.com"]}' +# +#jsonlite::minify(json2) +# +#pet_api <- PetApi$new() +#pet_id <- 123321 +#pet <- Pet$new("name_test", +# photoUrls = list("photo_test", "second test"), +# category = Category$new(id = 450, name = "test_cat"), +# id = pet_id, +# tags = list( +# Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown") +# ), +# status = "available" +#) +# +##jsonlite::minify(pet$toJSONString()) +##cat(pet$toJSONString()) +#toString(pet$toString()) +# +##json <- +##'[ +## {"Name" : "Mario", "Age" : 32, "Occupation" : "Plumber"}, +## {"Name" : "Peach", "Age" : 21, "Occupation" : "Princess"}, +## {}, +## {"Name" : "Bowser", "Occupation" : "Koopa"} +##]' +## +## +###Pet$public_methods +###Pet$public_methods$fromJSON(json) +###Pet$public_methods$toJson() +###Pet$public_methods$validateJSON(json2) +###Pet$public_methods$validateJson(json) +###Pet$my_static_method <- function(x) { x + 2} +###Pet$public_methods$my_static_method(1) +## +# basque_pig_json <- +# '{"className2": "BasquePig", "color": "red"}' +## +## danish_pig_json <- +## '{"className2": "DanishPig", "size": 7}' +## +## wrong_json <- +## '[ +## {"Name" : "Tom", "Age" : 32, "Occupation" : "Consultant"}, +## {}, +## {"Name" : "Ada", "Occupation" : "Engineer"} +## ]' +## +## print("==========") +# pig <- Pig$new() +# basque_pig <- pig$fromJSON(basque_pig_json) +## #print(basque_pig$actual_instance$color) +## #expect_equal(basque_pig$actual_type, "BasquePig") +## pig$fromJSON(danish_pig_json) +## #pig$fromJSON(wrong_json) +## pig$toJSON() +## +## #d <- DanishPig$new() +## #dp <- d$validateJSON(danish_pig_json) +## +## +# +## test nested oneOf +#nested_oneof <- NestedOneOf$new() +#nested_oneof$nested_pig <- pig +#nested_oneof$size <- 15 +# +#cat(nested_oneof$toJSONString()) +# diff --git a/samples/client/petstore/R-httr2/tests/testthat.R b/samples/client/petstore/R-httr2/tests/testthat.R new file mode 100644 index 000000000000..d67bd9cf2380 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(petstore) + +test_check("petstore") diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_allof_tag_api_response.R b/samples/client/petstore/R-httr2/tests/testthat/test_allof_tag_api_response.R new file mode 100644 index 000000000000..90a5d04d3f63 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_allof_tag_api_response.R @@ -0,0 +1,41 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test AllofTagApiResponse") + +model_instance <- AllofTagApiResponse$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("code", { + # tests for the property `code` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`code`, "EXPECTED_RESULT") +}) + +test_that("type", { + # tests for the property `type` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`type`, "EXPECTED_RESULT") +}) + +test_that("message", { + # tests for the property `message` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`message`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_animal.R b/samples/client/petstore/R-httr2/tests/testthat/test_animal.R new file mode 100644 index 000000000000..4402cf03c540 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_animal.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Animal") + +model_instance <- Animal$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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/petstore/R-httr2/tests/testthat/test_any_of_pig.R b/samples/client/petstore/R-httr2/tests/testthat/test_any_of_pig.R new file mode 100644 index 000000000000..8ca3b8e73d11 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_any_of_pig.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test AnyOfPig") + +model_instance <- AnyOfPig$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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("size", { + # tests for the property `size` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_basque_pig.R b/samples/client/petstore/R-httr2/tests/testthat/test_basque_pig.R new file mode 100644 index 000000000000..400268563dad --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_basque_pig.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test BasquePig") + +model_instance <- BasquePig$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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/petstore/R-httr2/tests/testthat/test_cat.R b/samples/client/petstore/R-httr2/tests/testthat/test_cat.R new file mode 100644 index 000000000000..ab85fe3340f3 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_cat.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Cat") + +model_instance <- Cat$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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("declawed", { + # tests for the property `declawed` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`declawed`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_cat_all_of.R b/samples/client/petstore/R-httr2/tests/testthat/test_cat_all_of.R new file mode 100644 index 000000000000..83ee2fb835c5 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_cat_all_of.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test CatAllOf") + +model_instance <- CatAllOf$new() + +test_that("declawed", { + # tests for the property `declawed` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`declawed`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_category.R b/samples/client/petstore/R-httr2/tests/testthat/test_category.R new file mode 100644 index 000000000000..c7838edeb623 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_category.R @@ -0,0 +1,21 @@ +# 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/petstore/R-httr2/tests/testthat/test_danish_pig.R b/samples/client/petstore/R-httr2/tests/testthat/test_danish_pig.R new file mode 100644 index 000000000000..a7c2811d89ab --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_danish_pig.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test DanishPig") + +model_instance <- DanishPig$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "EXPECTED_RESULT") +}) + +test_that("size", { + # tests for the property `size` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_dog.R b/samples/client/petstore/R-httr2/tests/testthat/test_dog.R new file mode 100644 index 000000000000..9c04cc780672 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_dog.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Dog") + +model_instance <- Dog$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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("breed", { + # tests for the property `breed` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`breed`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_dog_all_of.R b/samples/client/petstore/R-httr2/tests/testthat/test_dog_all_of.R new file mode 100644 index 000000000000..6d11847f66d3 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_dog_all_of.R @@ -0,0 +1,13 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test DogAllOf") + +model_instance <- DogAllOf$new() + +test_that("breed", { + # tests for the property `breed` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`breed`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_fake_api.R b/samples/client/petstore/R-httr2/tests/testthat/test_fake_api.R new file mode 100644 index 000000000000..7514044ac14f --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_fake_api.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test FakeApi") + +api.instance <- FakeApi$new() + +test_that("FakeDataFile", { + # tests for FakeDataFile + # base path: http://petstore.swagger.io/v2 + # test data_file to ensure it's escaped correctly + # + # @param dummy character dummy required parameter + # @param DataFile. character header data file (optional) + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_model_api_response.R b/samples/client/petstore/R-httr2/tests/testthat/test_model_api_response.R new file mode 100644 index 000000000000..d5dcef5716f9 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_model_api_response.R @@ -0,0 +1,28 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test ModelApiResponse") + +model.instance <- ModelApiResponse$new() + +test_that("code", { + # tests for the property `code` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`code`, "EXPECTED_RESULT") +}) + +test_that("type", { + # tests for the property `type` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`type`, "EXPECTED_RESULT") +}) + +test_that("message", { + # tests for the property `message` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`message`, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_nested_one_of.R b/samples/client/petstore/R-httr2/tests/testthat/test_nested_one_of.R new file mode 100644 index 000000000000..940a7fba2a62 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_nested_one_of.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test NestedOneOf") + +model_instance <- NestedOneOf$new() + +test_that("size", { + # tests for the property `size` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) + +test_that("nested_pig", { + # tests for the property `nested_pig` (Pig) + + # uncomment below to test the property + #expect_equal(model.instance$`nested_pig`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_order.R b/samples/client/petstore/R-httr2/tests/testthat/test_order.R new file mode 100644 index 000000000000..33b87520254d --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_order.R @@ -0,0 +1,50 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Order") + +model.instance <- Order$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("petId", { + # tests for the property `petId` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`petId`, "EXPECTED_RESULT") +}) + +test_that("quantity", { + # tests for the property `quantity` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`quantity`, "EXPECTED_RESULT") +}) + +test_that("shipDate", { + # tests for the property `shipDate` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`shipDate`, "EXPECTED_RESULT") +}) + +test_that("status", { + # tests for the property `status` (character) + # Order Status + + # uncomment below to test the property + #expect_equal(model.instance$`status`, "EXPECTED_RESULT") +}) + +test_that("complete", { + # tests for the property `complete` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`complete`, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_pet.R b/samples/client/petstore/R-httr2/tests/testthat/test_pet.R new file mode 100644 index 000000000000..ac3e4f31dd10 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_pet.R @@ -0,0 +1,50 @@ +# 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("category", { + # tests for the property `category` (Category) + + # uncomment below to test the property + #expect_equal(model.instance$`category`, "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("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/petstore/R-httr2/tests/testthat/test_pet_api.R b/samples/client/petstore/R-httr2/tests/testthat/test_pet_api.R new file mode 100644 index 000000000000..7fbdd1a70deb --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_pet_api.R @@ -0,0 +1,103 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test PetApi") + +api.instance <- PetApi$new() + +test_that("AddPet", { + # tests for AddPet + # base path: http://petstore.swagger.io/v2 + # Add a new pet to the store + # @param body Pet Pet object that needs to be added to the store + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("DeletePet", { + # tests for DeletePet + # base path: http://petstore.swagger.io/v2 + # Deletes a pet + # @param pet.id integer Pet id to delete + # @param api.key character (optional) + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("FindPetsByStatus", { + # tests for FindPetsByStatus + # base path: http://petstore.swagger.io/v2 + # Finds Pets by status + # Multiple status values can be provided with comma separated strings + # @param status array[character] Status values that need to be considered for filter + # @return [array[Pet]] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("FindPetsByTags", { + # tests for FindPetsByTags + # base path: http://petstore.swagger.io/v2 + # Finds Pets by tags + # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + # @param tags array[character] Tags to filter by + # @return [array[Pet]] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("GetPetById", { + # tests for GetPetById + # base path: http://petstore.swagger.io/v2 + # Find pet by ID + # Returns a single pet + # @param pet.id integer ID of pet to return + # @return [Pet] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("UpdatePet", { + # tests for UpdatePet + # base path: http://petstore.swagger.io/v2 + # Update an existing pet + # @param body Pet Pet object that needs to be added to the store + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("UpdatePetWithForm", { + # tests for UpdatePetWithForm + # base path: http://petstore.swagger.io/v2 + # Updates a pet in the store with form data + # @param pet.id integer ID of pet that needs to be updated + # @param name character Updated name of the pet (optional) + # @param status character Updated status of the pet (optional) + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("UploadFile", { + # tests for UploadFile + # base path: http://petstore.swagger.io/v2 + # uploads an image + # @param pet.id integer ID of pet to update + # @param additional.metadata character Additional data to pass to server (optional) + # @param file data.frame file to upload (optional) + # @return [ModelApiResponse] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R new file mode 100644 index 000000000000..fb292a70feb2 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R @@ -0,0 +1,321 @@ +context("basic functionality") + +pet_api <- PetApi$new() +pet_id <- 123321 +pet <- Pet$new("name_test", + photoUrls = list("photo_test", "second test"), + category = Category$new(id = 450, name = "test_cat"), + id = pet_id, + tags = list( + Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown") + ), + status = "available" +) +pet_api$api_client$username <- "username123" +pet_api$api_client$password <- "password123" +result <- pet_api$add_pet(pet) + +test_that("add_pet", { + expect_equal(pet_id, 123321) + expect_equal(pet$toJSONString(), '{"id":123321,"category":{"id":450,"name":"test_cat"},"name":"name_test","photoUrls":["photo_test","second test"],"tags":[{"id":123,"name":"tag_test"},{"id":456,"name":"unknown"}],"status":"available"}') +}) + +test_that("Test toJSON toJSONString fromJSON fromJSONString", { + pet0 <- Pet$new() + jsonpet <- pet0$toJSON() + pet2 <- pet0$fromJSON( + jsonlite::toJSON(jsonpet, auto_unbox = TRUE) + ) + expect_equal(pet0, pet2) + jsonpet <- pet0$toJSONString() + pet2 <- pet0$fromJSON( + jsonpet + ) + expect_equal(pet0, pet2) + + jsonpet <- pet0$toJSONString() + pet2 <- pet0$fromJSONString( + jsonpet + ) + expect_equal(pet0, pet2) + + pet1 <- Pet$new("name_test", + list("photo_test", "second test"), + category = Category$new(id = 450, name = "test_cat"), + id = pet_id, + tags = list( + Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown") + ), + status = "available" + ) + jsonpet <- pet1$toJSON() + pet2 <- pet1$fromJSON( + jsonlite::toJSON(jsonpet, auto_unbox = TRUE) + ) + expect_equal(pet1, pet2) + + jsonpet <- pet1$toJSONString() + pet2 <- pet1$fromJSON( + jsonpet + ) + expect_equal(pet1, pet2) + + jsonpet <- pet1$toJSONString() + pet2 <- pet1$fromJSONString( + jsonpet + ) + expect_equal(pet1, pet2) +}) + +test_that("Test Category", { + c1 <- Category$new(id = 450, name = "test_cat") + c2 <- Category$new() + c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox = TRUE)) + expect_equal(c1, c2) + c2$fromJSONString(c1$toJSONString()) + expect_equal(c1, c2) +}) + +test_that("get_pet_by_id", { + response <- pet_api$get_pet_by_id(pet_id) + expect_equal(response$id, pet_id) + expect_equal(response$name, "name_test") + expect_equal( + response$photoUrls, + list("photo_test", "second test") + ) + expect_equal(response$status, "available") + expect_equal(response$category, Category$new(id = 450, name = "test_cat")) + + expect_equal(pet$tags, response$tags) + expect_equal( + response$tags, + list(Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown")) + ) +}) + +test_that("get_pet_by_id_streaming", { + result <- tryCatch( + pet_api$get_pet_by_id_streaming(pet_id, stream_callback = function(x) { print(x) }), + ApiException = function(ex) ex + ) +}) + +#test_that("test GetPetById exception", { +# # test exception +# result <- tryCatch(petApi$GetPetById(98765), # petId not exist +# error = function(ex) ex +# ) +# +# expect_true(!is.null(result)) +# #expect_equal(result$toString(),"") +# expect_equal(result, "1") +# #expect_equal(result$ApiException$errorObject$code, 1) +# #expect_equal(response$name, "name_test") +#}) + +test_that("GetPetById with data_file", { + # test to ensure json is saved to the file `get_pet_by_id.json` + pet_response <- pet_api$GetPetById(pet_id, data_file = "get_pet_by_id.json") + response <- read_json("get_pet_by_id.json") + expect_true(!is.null(response)) + expect_equal(response$id, pet_id) + expect_equal(response$name, "name_test") +}) + +test_that("Tests allOf", { + # test allOf without discriminator + a1 <- AllofTagApiResponse$new(id = 450, name = "test_cat", code = 200, type = "test_type", message = "test_message") + + expect_true(!is.null(a1)) + expect_equal(a1$id, 450) + expect_equal(a1$name, "test_cat") +}) + +test_that("Tests allOf with discriminator", { + # test allOf without discriminator + c1 <- Cat$new(className = "cat", color = "red", declawed = TRUE) + + expect_true(!is.null(c1)) + expect_equal(c1$className, "cat") + expect_equal(c1$color, "red") + expect_true(c1$declawed) +}) + +test_that("Tests validateJSON", { + json <- + '{"name": "pet", "photoUrls" : ["http://a.com", "http://b.com"]}' + + json2 <- + '[ + {"Name" : "Tom", "Age" : 32, "Occupation" : "Consultant"}, + {}, + {"Name" : "Ada", "Occupation" : "Engineer"} + ]' + + # validate `json` and no error throw + Pet$public_methods$validateJSON(json) + + # validate `json2` and should throw an error due to missing required fields + #expect_error(Pet$public_methods$validateJSON(json2), 'The JSON input ` [\n {\"Name\" : \"Tom\", \"Age\" : 32, \"Occupation\" : \"Consultant\"}, \n {},\n {\"Name\" : \"Ada\", \"Occupation\" : \"Engineer\"}\n ] ` is invalid for Pet: the required field `name` is missing.') + +}) + +# test object with special item names: self, private, super +test_that("Tests special item names", { + special_json <- + '{"self": 123, "private": "red", "super": "something"}' + + # test fromJSON + special <- Special$new()$fromJSON(special_json) + expect_equal(special$item_self, 123) + expect_equal(special$item_private, "red") + expect_equal(special$item_super, "something") + + # test toJSONString + expect_true(grepl('"private"', special$toJSONString())) + expect_true(grepl('"self"', special$toJSONString())) + expect_true(grepl('"super"', special$toJSONString())) + expect_equal('{"self":123,"private":"red","super":"something"}', special$toJSONString()) + + # round trip test + s1 <- Special$new()$fromJSONString(special_json) + s2 <- Special$new()$fromJSONString(s1$toJSONString()) + expect_equal(s1, s2) + +}) + +test_that("Tests oneOf", { + basque_pig_json <- + '{"className": "BasquePig", "color": "red"}' + + danish_pig_json <- + '{"className": "DanishPig", "size": 7}' + + wrong_json <- + '[ + {"Name" : "Tom", "Age" : 32, "Occupation" : "Consultant"}, + {}, + {"Name" : "Ada", "Occupation" : "Engineer"} + ]' + + original_danish_pig <- DanishPig$new()$fromJSON(danish_pig_json) + original_basque_pig <- BasquePig$new()$fromJSON(basque_pig_json) + + # test fromJSON, actual_tpye, actual_instance + pig <- Pig$new() + danish_pig <- pig$fromJSON(danish_pig_json) + pig$validateJSON(basque_pig_json) # validate JSON to ensure its actual_instance, actual_type are not updated + expect_equal(danish_pig$actual_type, "DanishPig") + expect_equal(danish_pig$actual_instance$size, 7) + expect_equal(danish_pig$actual_instance$className, "DanishPig") + + expect_equal(pig$actual_type, "DanishPig") + expect_equal(pig$actual_instance$size, 7) + expect_equal(pig$actual_instance$className, "DanishPig") + + # test toJSON + expect_equal(danish_pig$toJSONString(), original_danish_pig$toJSONString()) + + basque_pig <- pig$fromJSON(basque_pig_json) + expect_equal(basque_pig$actual_type, "BasquePig") + expect_equal(basque_pig$actual_instance$color, "red") + expect_equal(basque_pig$actual_instance$className, "BasquePig") + expect_equal(basque_pig$toJSONString(), original_basque_pig$toJSONString()) + + # test exception when no matche found + expect_error(pig$fromJSON('{}'), 'No match found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. Details: The JSON input ` \\{\\} ` is invalid for BasquePig: the required field `className` is missing\\., The JSON input ` \\{\\} ` is invalid for DanishPig: the required field `className` is missing\\.') + expect_error(pig$validateJSON('{}'), 'No match found when deserializing the payload into Pig with oneOf schemas BasquePig, DanishPig. Details: The JSON input ` \\{\\} ` is invalid for BasquePig: the required field `className` is missing\\., The JSON input ` \\{\\} ` is invalid for DanishPig: the required field `className` is missing\\.') + + # class name test + expect_equal(get(class(basque_pig$actual_instance)[[1]], pos = -1)$classname, "BasquePig") + + # test contructors + pig2 <- Pig$new(instance = basque_pig$actual_instance) + expect_equal(pig2$actual_type, "BasquePig") + expect_equal(pig2$actual_instance$color, "red") + expect_equal(pig2$actual_instance$className, "BasquePig") + expect_equal(pig2$toJSONString(), original_basque_pig$toJSONString()) + + expect_error(Pig$new(instance = basque_pig), 'Failed to initialize Pig with oneOf schemas BasquePig, DanishPig. Provided class name: Pig') + + # test nested oneOf toJSONString + nested_oneof <- NestedOneOf$new() + nested_oneof$nested_pig <- pig + nested_oneof$size <- 15 + expect_equal(nested_oneof$toJSONString(), '{"size":15,"nested_pig":{"className":"BasquePig","color":"red"}}') + + # test fromJSONString with nested oneOf + nested_json_str <- '{"size":15,"nested_pig":{"className":"BasquePig","color":"red"}}' + nested_oneof2 <- NestedOneOf$new()$fromJSONString(nested_json_str) + expect_equal(nested_oneof2$toJSONString(), '{"size":15,"nested_pig":{"className":"BasquePig","color":"red"}}') + + # test toString + expect_equal(as.character(jsonlite::minify(pig$toString())), "{\"actual_instance\":{\"className\":\"BasquePig\",\"color\":\"red\"},\"actual_type\":\"BasquePig\",\"one_of\":\"BasquePig, DanishPig\"}") + expect_equal(as.character(jsonlite::minify(Pig$new()$toString())), "{\"one_of\":\"BasquePig, DanishPig\"}") +}) + +test_that("Tests anyOf", { + basque_pig_json <- + '{"className": "BasquePig", "color": "red"}' + + danish_pig_json <- + '{"className": "DanishPig", "size": 7}' + + wrong_json <- + '[ + {"Name" : "Tom", "Age" : 32, "Occupation" : "Consultant"}, + {}, + {"Name" : "Ada", "Occupation" : "Engineer"} + ]' + + original_danish_pig <- DanishPig$new()$fromJSON(danish_pig_json) + original_basque_pig <- BasquePig$new()$fromJSON(basque_pig_json) + + # test fromJSON, actual_tpye, actual_instance + pig <- AnyOfPig$new() + danish_pig <- pig$fromJSON(danish_pig_json) + expect_equal(danish_pig$actual_type, "DanishPig") + expect_equal(danish_pig$actual_instance$size, 7) + expect_equal(danish_pig$actual_instance$className, "DanishPig") + + expect_equal(pig$actual_type, "DanishPig") + expect_equal(pig$actual_instance$size, 7) + expect_equal(pig$actual_instance$className, "DanishPig") + + # test toJSONString + expect_equal(danish_pig$toJSONString(), original_danish_pig$toJSONString()) + + basque_pig <- pig$fromJSON(basque_pig_json) + expect_equal(basque_pig$actual_type, "BasquePig") + expect_equal(basque_pig$actual_instance$color, "red") + expect_equal(basque_pig$actual_instance$className, "BasquePig") + expect_equal(basque_pig$toJSONString(), original_basque_pig$toJSONString()) + + # test exception when no matche found + expect_error(pig$fromJSON('{}'), 'No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: The JSON input ` \\{\\} ` is invalid for BasquePig: the required field `className` is missing\\., The JSON input ` \\{\\} ` is invalid for DanishPig: the required field `className` is missing\\.') + expect_error(pig$validateJSON('{}'), 'No match found when deserializing the payload into AnyOfPig with anyOf schemas BasquePig, DanishPig. Details: The JSON input ` \\{\\} ` is invalid for BasquePig: the required field `className` is missing\\., The JSON input ` \\{\\} ` is invalid for DanishPig: the required field `className` is missing\\.') + +}) + +#test_that("GetPetById", { +# pet.id <- pet.id +# pet <- Pet$new(pet.id, NULL, "name_test2", +# list("photo_test2", "second test2"), +# NULL, NULL) +# result <-pet_api$AddPet(pet) +# +# response <- pet_api$GetPetById(pet.id) +# +# expect_equal(response$id, pet.id) +# expect_equal(response$name, "name_test2") +# #expect_equal(response$category, Category$new(450,"test_cat")) +# expect_equal(response$photoUrls, list("photo_test2", "second test2")) +# expect_equal(response$status, NULL) +# #expect_equal(response$tags, list(Tag$new(123, "tag_test"), Tag$new(456, "unknown"))) +#}) + +#test_that("updatePetWithForm", { +# response <- pet_api$updatePetWithForm(pet_id, "test", "sold") +# expect_equal(response, "Pet updated") +#}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_pig.R b/samples/client/petstore/R-httr2/tests/testthat/test_pig.R new file mode 100644 index 000000000000..4846cfbb0fa6 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_pig.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Pig") + +model_instance <- Pig$new() + +test_that("className", { + # tests for the property `className` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`className`, "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("size", { + # tests for the property `size` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`size`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_special.R b/samples/client/petstore/R-httr2/tests/testthat/test_special.R new file mode 100644 index 000000000000..c76671b21334 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_special.R @@ -0,0 +1,27 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test Special") + +model_instance <- Special$new() + +test_that("self", { + # tests for the property `self` (integer) + + # uncomment below to test the property + #expect_equal(model.instance$`self`, "EXPECTED_RESULT") +}) + +test_that("private", { + # tests for the property `private` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`private`, "EXPECTED_RESULT") +}) + +test_that("super", { + # tests for the property `super` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`super`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_store_api.R b/samples/client/petstore/R-httr2/tests/testthat/test_store_api.R new file mode 100644 index 000000000000..1ebb3f82a639 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_store_api.R @@ -0,0 +1,53 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test StoreApi") + +api.instance <- StoreApi$new() + +test_that("DeleteOrder", { + # tests for DeleteOrder + # base path: http://petstore.swagger.io/v2 + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order.id character ID of the order that needs to be deleted + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("GetInventory", { + # tests for GetInventory + # base path: http://petstore.swagger.io/v2 + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @return [map(integer)] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("GetOrderById", { + # tests for GetOrderById + # base path: http://petstore.swagger.io/v2 + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order.id integer ID of pet that needs to be fetched + # @return [Order] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("PlaceOrder", { + # tests for PlaceOrder + # base path: http://petstore.swagger.io/v2 + # Place an order for a pet + # @param body Order order placed for purchasing the pet + # @return [Order] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_tag.R b/samples/client/petstore/R-httr2/tests/testthat/test_tag.R new file mode 100644 index 000000000000..2dd6d369af0a --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_tag.R @@ -0,0 +1,21 @@ +# 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/petstore/R-httr2/tests/testthat/test_update_pet_request.R b/samples/client/petstore/R-httr2/tests/testthat/test_update_pet_request.R new file mode 100644 index 000000000000..b39b2b4d0d76 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_update_pet_request.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test UpdatePetRequest") + +model_instance <- UpdatePetRequest$new() + +test_that("jsonData", { + # tests for the property `jsonData` (Pet) + + # uncomment below to test the property + #expect_equal(model.instance$`jsonData`, "EXPECTED_RESULT") +}) + +test_that("binaryDataN2Information", { + # tests for the property `binaryDataN2Information` (data.frame) + + # uncomment below to test the property + #expect_equal(model.instance$`binaryDataN2Information`, "EXPECTED_RESULT") +}) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_user.R b/samples/client/petstore/R-httr2/tests/testthat/test_user.R new file mode 100644 index 000000000000..9929623b42f8 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_user.R @@ -0,0 +1,64 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test User") + +model.instance <- User$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("username", { + # tests for the property `username` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`username`, "EXPECTED_RESULT") +}) + +test_that("firstName", { + # tests for the property `firstName` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`firstName`, "EXPECTED_RESULT") +}) + +test_that("lastName", { + # tests for the property `lastName` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`lastName`, "EXPECTED_RESULT") +}) + +test_that("email", { + # tests for the property `email` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`email`, "EXPECTED_RESULT") +}) + +test_that("password", { + # tests for the property `password` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`password`, "EXPECTED_RESULT") +}) + +test_that("phone", { + # tests for the property `phone` (character) + + # uncomment below to test the property + #expect_equal(model.instance$`phone`, "EXPECTED_RESULT") +}) + +test_that("userStatus", { + # tests for the property `userStatus` (integer) + # User Status + + # uncomment below to test the property + #expect_equal(model.instance$`userStatus`, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_user_api.R b/samples/client/petstore/R-httr2/tests/testthat/test_user_api.R new file mode 100644 index 000000000000..8b8c3ba38477 --- /dev/null +++ b/samples/client/petstore/R-httr2/tests/testthat/test_user_api.R @@ -0,0 +1,99 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test UserApi") + +api.instance <- UserApi$new() + +test_that("CreateUser", { + # tests for CreateUser + # base path: http://petstore.swagger.io/v2 + # Create user + # This can only be done by the logged in user. + # @param body User Created user object + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("CreateUsersWithArrayInput", { + # tests for CreateUsersWithArrayInput + # base path: http://petstore.swagger.io/v2 + # Creates list of users with given input array + # @param body array[User] List of user object + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("CreateUsersWithListInput", { + # tests for CreateUsersWithListInput + # base path: http://petstore.swagger.io/v2 + # Creates list of users with given input array + # @param body array[User] List of user object + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("DeleteUser", { + # tests for DeleteUser + # base path: http://petstore.swagger.io/v2 + # Delete user + # This can only be done by the logged in user. + # @param username character The name that needs to be deleted + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("GetUserByName", { + # tests for GetUserByName + # base path: http://petstore.swagger.io/v2 + # Get user by user name + # @param username character The name that needs to be fetched. Use user1 for testing. + # @return [User] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("LoginUser", { + # tests for LoginUser + # base path: http://petstore.swagger.io/v2 + # Logs user into the system + # @param username character The user name for login + # @param password character The password for login in clear text + # @return [character] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("LogoutUser", { + # tests for LogoutUser + # base path: http://petstore.swagger.io/v2 + # Logs out current logged in user session + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + +test_that("UpdateUser", { + # tests for UpdateUser + # base path: http://petstore.swagger.io/v2 + # Updated user + # This can only be done by the logged in user. + # @param username character name that need to be deleted + # @param body User Updated user object + # @return [Void] + + # uncomment below to test the operation + #expect_equal(result, "EXPECTED_RESULT") +}) + diff --git a/samples/client/petstore/R/R/fake_api.R b/samples/client/petstore/R/R/fake_api.R index 250b0a822d4a..40b74a2854fd 100644 --- a/samples/client/petstore/R/R/fake_api.R +++ b/samples/client/petstore/R/R/fake_api.R @@ -124,7 +124,7 @@ FakeApi <- R6::R6Class( #' @export FakeDataFileWithHttpInfo = function(dummy, var_data_file = NULL, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`dummy`)) { diff --git a/samples/client/petstore/R/R/pet_api.R b/samples/client/petstore/R/R/pet_api.R index 707283312acd..71d28fe57f3a 100644 --- a/samples/client/petstore/R/R/pet_api.R +++ b/samples/client/petstore/R/R/pet_api.R @@ -568,7 +568,7 @@ PetApi <- R6::R6Class( #' @export AddPetWithHttpInfo = function(pet, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet`)) { @@ -671,7 +671,7 @@ PetApi <- R6::R6Class( #' @export DeletePetWithHttpInfo = function(pet_id, api_key = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet_id`)) { @@ -760,7 +760,7 @@ PetApi <- R6::R6Class( #' @export FindPetsByStatusWithHttpInfo = function(status, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`status`)) { @@ -858,7 +858,7 @@ PetApi <- R6::R6Class( #' @export FindPetsByTagsWithHttpInfo = function(tags, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`tags`)) { @@ -956,7 +956,7 @@ PetApi <- R6::R6Class( #' @export GetPetByIdWithHttpInfo = function(pet_id, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet_id`)) { @@ -1063,7 +1063,7 @@ PetApi <- R6::R6Class( #' @export GetPetByIdStreamingWithHttpInfo = function(pet_id, stream_callback = NULL, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet_id`)) { @@ -1172,7 +1172,7 @@ PetApi <- R6::R6Class( #' @export UpdatePetWithHttpInfo = function(pet, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet`)) { @@ -1277,7 +1277,7 @@ PetApi <- R6::R6Class( #' @export UpdatePetWithFormWithHttpInfo = function(pet_id, name = NULL, status = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet_id`)) { @@ -1374,7 +1374,7 @@ PetApi <- R6::R6Class( #' @export UploadFileWithHttpInfo = function(pet_id, additional_metadata = NULL, file = NULL, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`pet_id`)) { diff --git a/samples/client/petstore/R/R/store_api.R b/samples/client/petstore/R/R/store_api.R index 9ce83ad4e4fc..321131f38f0e 100644 --- a/samples/client/petstore/R/R/store_api.R +++ b/samples/client/petstore/R/R/store_api.R @@ -272,7 +272,7 @@ StoreApi <- R6::R6Class( #' @export DeleteOrderWithHttpInfo = function(order_id, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`order_id`)) { @@ -357,7 +357,7 @@ StoreApi <- R6::R6Class( #' @export GetInventoryWithHttpInfo = function(data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() body <- NULL @@ -450,7 +450,7 @@ StoreApi <- R6::R6Class( #' @export GetOrderByIdWithHttpInfo = function(order_id, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`order_id`)) { @@ -550,7 +550,7 @@ StoreApi <- R6::R6Class( #' @export PlaceOrderWithHttpInfo = function(order, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`order`)) { diff --git a/samples/client/petstore/R/R/user_api.R b/samples/client/petstore/R/R/user_api.R index 07dbd47a3079..644c53ad472a 100644 --- a/samples/client/petstore/R/R/user_api.R +++ b/samples/client/petstore/R/R/user_api.R @@ -458,7 +458,7 @@ UserApi <- R6::R6Class( #' @export CreateUserWithHttpInfo = function(user, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`user`)) { @@ -548,7 +548,7 @@ UserApi <- R6::R6Class( #' @export CreateUsersWithArrayInputWithHttpInfo = function(user, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`user`)) { @@ -641,7 +641,7 @@ UserApi <- R6::R6Class( #' @export CreateUsersWithListInputWithHttpInfo = function(user, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`user`)) { @@ -734,7 +734,7 @@ UserApi <- R6::R6Class( #' @export DeleteUserWithHttpInfo = function(username, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`username`)) { @@ -825,7 +825,7 @@ UserApi <- R6::R6Class( #' @export GetUserByNameWithHttpInfo = function(username, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`username`)) { @@ -927,7 +927,7 @@ UserApi <- R6::R6Class( #' @export LoginUserWithHttpInfo = function(username, password, data_file = NULL, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`username`)) { @@ -1026,7 +1026,7 @@ UserApi <- R6::R6Class( #' @export LogoutUserWithHttpInfo = function(...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() body <- NULL @@ -1106,7 +1106,7 @@ UserApi <- R6::R6Class( #' @export UpdateUserWithHttpInfo = function(username, user, ...) { args <- list(...) - query_params <- list() + query_params <- c() header_params <- c() if (missing(`username`)) { From e11200d6910a2d4cf694ee3c414abb3400c50853 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 27 Jul 2022 16:48:23 +0800 Subject: [PATCH 2/9] fix headers --- .../r/libraries/httr2/api_client.mustache | 20 ++++++++++++------- .../client/petstore/R-httr2/R/api_client.R | 14 +++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index 05e633839527..4b8a9e3755f9 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -181,15 +181,21 @@ ApiClient <- R6::R6Class( ## add headers and default headers if (!is.null(header_params) && length(header_params) != 0) { - req %>% req_headers(header_params) + for (http_header in names(header_params)) { + req %>% req_headers(http_header = header_params[http_header]) + } } - if (length(self$default_headers) != 0) { - req %>% req_headers(self$default_headers) + if (!is.null(self$default_headers) && length(self$default_headers) != 0) { + for (http_header in names(header_params)) { + req %>% req_headers(http_header = self$default_headers[http_header]) + } } ## add query parameters if (length(query_params) != 0) { - req %>% req_url_query(query_params) + for (query_param in names(query_params)) { + req %>% req_url_query(query_param = query_params[query_param]) + } } # add body parameters @@ -218,9 +224,9 @@ ApiClient <- R6::R6Class( req %>% req_method(method) # stream data - if (typeof(stream_callback) == "closure") { - req %>% req_stream(stream_callback) - } + #if (typeof(stream_callback) == "closure") { + # req %>% req_stream(stream_callback) + #} # perform the HTTP request req_perform(req) diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index 84c9d620568f..8129f9703d62 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -186,15 +186,21 @@ ApiClient <- R6::R6Class( ## add headers and default headers if (!is.null(header_params) && length(header_params) != 0) { - req %>% req_headers(header_params) + for (http_header in names(header_params)) { + req %>% req_headers(http_header = header_params[http_header]) + } } - if (length(self$default_headers) != 0) { - req %>% req_headers(self$default_headers) + if (!is.null(self$default_headers) && length(self$default_headers) != 0) { + for (http_header in names(header_params)) { + req %>% req_headers(http_header = self$default_headers[http_header]) + } } ## add query parameters if (length(query_params) != 0) { - req %>% req_url_query(query_params) + for (query_param in names(query_params)) { + req %>% req_url_query(query_param = query_params[query_param]) + } } # add body parameters From b814137e1b9dc0d3b05e8e3af8f30422db6598e1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 27 Jul 2022 17:43:49 +0800 Subject: [PATCH 3/9] add accepts, content-types --- .../r/libraries/httr2/api_client.mustache | 47 +++++++++++++++++-- .../client/petstore/R-httr2/R/api_client.R | 47 +++++++++++++++++-- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index 4b8a9e3755f9..456bbc089665 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -138,9 +138,12 @@ ApiClient <- R6::R6Class( #' @param ... Other optional arguments. #' @return HTTP response #' @export - CallApi = function(url, method, query_params, header_params, body, stream_callback = NULL, ...) { + CallApi = function(url, method, query_params, header_params, accepts, + content_types, body, stream_callback = NULL, ...) { - resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...) + resp <- self$Execute(url, method, query_params, header_params, + accepts, content_types, + body, stream_callback = stream_callback, ...) #status_code <- httr::status_code(resp) #if (is.null(self$max_retry_attempts)) { @@ -176,7 +179,8 @@ ApiClient <- R6::R6Class( #' @param ... Other optional arguments. #' @return HTTP response #' @export - Execute = function(url, method, query_params, header_params, body, stream_callback = NULL, ...) { + Execute = function(url, method, query_params, header_params, accepts, content_types, + body, stream_callback = NULL, ...) { req <- request(url) ## add headers and default headers @@ -191,6 +195,18 @@ ApiClient <- R6::R6Class( } } + # set HTTP accept header + accept = self$select_header(accepts) + if (!is.null(accept)) { + req %>% req_headers("Accept" = accept) + } + + # set HTTP content-type header + content_type = self$select_header(content_types) + if (!is.null(content_type)) { + req %>% req_headers("Content-Type" = content_type) + } + ## add query parameters if (length(query_params) != 0) { for (query_param in names(query_params)) { @@ -370,6 +386,31 @@ ApiClient <- R6::R6Class( return_obj <- obj } return_obj + }, + #' Return a propery header (for accept or content-type). If JSON-related MIME is found, + #' return it. Otherwise, return the first one, if any. + #' + #' @description + #' Return a propery 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/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index b6dd676c455c..82998cc63cf8 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -143,9 +143,12 @@ ApiClient <- R6::R6Class( #' @param ... Other optional arguments. #' @return HTTP response #' @export - CallApi = function(url, method, query_params, header_params, body, stream_callback = NULL, ...) { + CallApi = function(url, method, query_params, header_params, accepts, + content_types, body, stream_callback = NULL, ...) { - resp <- self$Execute(url, method, query_params, header_params, body, stream_callback = stream_callback, ...) + resp <- self$Execute(url, method, query_params, header_params, + accepts, content_types, + body, stream_callback = stream_callback, ...) #status_code <- httr::status_code(resp) #if (is.null(self$max_retry_attempts)) { @@ -181,7 +184,8 @@ ApiClient <- R6::R6Class( #' @param ... Other optional arguments. #' @return HTTP response #' @export - Execute = function(url, method, query_params, header_params, body, stream_callback = NULL, ...) { + Execute = function(url, method, query_params, header_params, accepts, content_types, + body, stream_callback = NULL, ...) { req <- request(url) ## add headers and default headers @@ -196,6 +200,18 @@ ApiClient <- R6::R6Class( } } + # set HTTP accept header + accept = self$select_header(accepts) + if (!is.null(accept)) { + req %>% req_headers("Accept" = accept) + } + + # set HTTP content-type header + content_type = self$select_header(content_types) + if (!is.null(content_type)) { + req %>% req_headers("Content-Type" = content_type) + } + ## add query parameters if (length(query_params) != 0) { for (query_param in names(query_params)) { @@ -372,6 +388,31 @@ ApiClient <- R6::R6Class( return_obj <- obj } return_obj + }, + #' Return a propery header (for accept or content-type). If JSON-related MIME is found, + #' return it. Otherwise, return the first one, if any. + #' + #' @description + #' Return a propery 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]) + } } ) ) From 593830fb972bc9080ecf56bcd77652503d6184db Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 29 Jul 2022 15:00:36 +0800 Subject: [PATCH 4/9] update samples --- samples/client/petstore/R-httr2/R/fake_api.R | 4 ++++ samples/client/petstore/R-httr2/R/pet_api.R | 12 ++++++++++++ samples/client/petstore/R-httr2/R/user_api.R | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/samples/client/petstore/R-httr2/R/fake_api.R b/samples/client/petstore/R-httr2/R/fake_api.R index b0baa7715636..d00bb501f8be 100644 --- a/samples/client/petstore/R-httr2/R/fake_api.R +++ b/samples/client/petstore/R-httr2/R/fake_api.R @@ -134,6 +134,10 @@ FakeApi <- R6::R6Class( reason = "Missing required parameter `dummy`.")) } + header_params["dummy"] <- `dummy` + + header_params["data_file"] <- `var_data_file` + local_var_body <- NULL local_var_url_path <- "/fake/data_file" diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R index 63f70247ce09..9dee32a91ccf 100644 --- a/samples/client/petstore/R-httr2/R/pet_api.R +++ b/samples/client/petstore/R-httr2/R/pet_api.R @@ -586,6 +586,12 @@ PetApi <- R6::R6Class( local_var_url_path <- "/pet" # HTTP basic auth + if (is.null(self$api_client$username) || is.null(self$api_client$password)) { + rlang::abort(message = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`.", + .subclass = "ApiException", + ApiException = ApiException$new(status = 0, + reason = "username, password in `api_client` must be set for authentication in the endpoint `add_pet`.")) + } header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":")))) # The Accept request HTTP header @@ -689,6 +695,8 @@ PetApi <- R6::R6Class( reason = "Missing required parameter `pet_id`.")) } + header_params["api_key"] <- `api_key` + local_var_body <- NULL local_var_url_path <- "/pet/{petId}?streaming" if (!missing(`pet_id`)) { @@ -786,6 +794,8 @@ PetApi <- R6::R6Class( reason = "Missing required parameter `status`.")) } + query_params["status"] <- status + local_var_body <- NULL local_var_url_path <- "/pet/findByStatus" # OAuth token @@ -892,6 +902,8 @@ PetApi <- R6::R6Class( reason = "Missing required parameter `tags`.")) } + query_params["tags"] <- tags + local_var_body <- NULL local_var_url_path <- "/pet/findByTags" # OAuth token diff --git a/samples/client/petstore/R-httr2/R/user_api.R b/samples/client/petstore/R-httr2/R/user_api.R index 3d897ef75e7e..f3ded748e1b2 100644 --- a/samples/client/petstore/R-httr2/R/user_api.R +++ b/samples/client/petstore/R-httr2/R/user_api.R @@ -984,6 +984,10 @@ UserApi <- R6::R6Class( reason = "Missing required parameter `password`.")) } + query_params["username"] <- username + + query_params["password"] <- password + local_var_body <- NULL local_var_url_path <- "/user/login" From 095653d471854845bc3becfcd1ce2480a30f9f3c Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 29 Jul 2022 15:38:51 +0800 Subject: [PATCH 5/9] fix req --- .../r/libraries/httr2/api_client.mustache | 22 +++++++++---------- .../client/petstore/R-httr2/R/api_client.R | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index 456bbc089665..efad1600f675 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -186,58 +186,58 @@ ApiClient <- R6::R6Class( ## add headers and default headers if (!is.null(header_params) && length(header_params) != 0) { for (http_header in names(header_params)) { - req %>% req_headers(http_header = header_params[http_header]) + req <- req %>% req_headers(http_header = header_params[http_header]) } } if (!is.null(self$default_headers) && length(self$default_headers) != 0) { for (http_header in names(header_params)) { - req %>% req_headers(http_header = self$default_headers[http_header]) + req <- req %>% req_headers(http_header = self$default_headers[http_header]) } } # set HTTP accept header accept = self$select_header(accepts) if (!is.null(accept)) { - req %>% req_headers("Accept" = accept) + req <- req %>% req_headers("Accept" = accept) } # set HTTP content-type header content_type = self$select_header(content_types) if (!is.null(content_type)) { - req %>% req_headers("Content-Type" = content_type) + req <- req %>% req_headers("Content-Type" = content_type) } ## add query parameters if (length(query_params) != 0) { for (query_param in names(query_params)) { - req %>% req_url_query(query_param = query_params[query_param]) + req <- req %>% req_url_query(query_param = query_params[query_param]) } } # add body parameters if (!is.null(body)) { - req %>% req_body_raw(body) + req <- req %>% req_body_raw(body) } # set timeout {{! Adding timeout that can be set at the apiClient object level}} if (!is.null(self$timeout)) { - req %>% req_timeout(self$timeout) + req <- req %>% req_timeout(self$timeout) } # set retry if (!is.null(self$max_retry_attempts)) { - req %>% retry_max_tries(self$timeout) - req %>% retry_max_seconds(self$timeout) + req <- req %>% retry_max_tries(self$timeout) + req <- req %>% retry_max_seconds(self$timeout) } # set user agent if (!is.null(self$user_agent)) { - req %>% req_user_agent(self$user_agent) + req <- req %>% req_user_agent(self$user_agent) } # set HTTP verb - req %>% req_method(method) + req <- req %>% req_method(method) # stream data #if (typeof(stream_callback) == "closure") { diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index 82998cc63cf8..a0d4d763cb95 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -191,57 +191,57 @@ ApiClient <- R6::R6Class( ## add headers and default headers if (!is.null(header_params) && length(header_params) != 0) { for (http_header in names(header_params)) { - req %>% req_headers(http_header = header_params[http_header]) + req <- req %>% req_headers(http_header = header_params[http_header]) } } if (!is.null(self$default_headers) && length(self$default_headers) != 0) { for (http_header in names(header_params)) { - req %>% req_headers(http_header = self$default_headers[http_header]) + req <- req %>% req_headers(http_header = self$default_headers[http_header]) } } # set HTTP accept header accept = self$select_header(accepts) if (!is.null(accept)) { - req %>% req_headers("Accept" = accept) + req <- req %>% req_headers("Accept" = accept) } # set HTTP content-type header content_type = self$select_header(content_types) if (!is.null(content_type)) { - req %>% req_headers("Content-Type" = content_type) + req <- req %>% req_headers("Content-Type" = content_type) } ## add query parameters if (length(query_params) != 0) { for (query_param in names(query_params)) { - req %>% req_url_query(query_param = query_params[query_param]) + req <- req %>% req_url_query(query_param = query_params[query_param]) } } # add body parameters if (!is.null(body)) { - req %>% req_body_raw(body) + req <- req %>% req_body_raw(body) } # set timeout if (!is.null(self$timeout)) { - req %>% req_timeout(self$timeout) + req <- req %>% req_timeout(self$timeout) } # set retry if (!is.null(self$max_retry_attempts)) { - req %>% retry_max_tries(self$timeout) - req %>% retry_max_seconds(self$timeout) + req <- req %>% retry_max_tries(self$timeout) + req <- req %>% retry_max_seconds(self$timeout) } # set user agent if (!is.null(self$user_agent)) { - req %>% req_user_agent(self$user_agent) + req <- req %>% req_user_agent(self$user_agent) } # set HTTP verb - req %>% req_method(method) + req <- req %>% req_method(method) # stream data #if (typeof(stream_callback) == "closure") { From 327dd1a568cfe0492d0e6c8fee49342b32c8ef6d Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 31 Jul 2022 10:58:50 +0800 Subject: [PATCH 6/9] update samples --- .../client/petstore/R-httr2/R/api_exception.R | 8 +- .../client/petstore/R-httr2/R/api_response.R | 18 +- samples/client/petstore/R-httr2/R/fake_api.R | 42 +- samples/client/petstore/R-httr2/R/pet_api.R | 370 +++++++++--------- samples/client/petstore/R-httr2/R/store_api.R | 164 ++++---- samples/client/petstore/R-httr2/R/user_api.R | 312 +++++++-------- 6 files changed, 465 insertions(+), 449 deletions(-) diff --git a/samples/client/petstore/R-httr2/R/api_exception.R b/samples/client/petstore/R-httr2/R/api_exception.R index 41bee0bb2031..e198854bf340 100644 --- a/samples/client/petstore/R-httr2/R/api_exception.R +++ b/samples/client/petstore/R-httr2/R/api_exception.R @@ -36,14 +36,14 @@ ApiException <- R6::R6Class( initialize = function(status = NULL, reason = NULL, http_response = NULL) { if (!is.null(http_response)) { self$status <- http_response$status_code - errorMsg <- toString(content(http_response)) - if (errorMsg == "") { + errorMsg <- http_response$response + if (is.null(errorMsg) || errorMsg == "") { errorMsg <- "Api exception encountered. No details given." } self$body <- errorMsg self$headers <- http_response$headers - self$reason <- httr::http_status(http_response)$reason - self$errorObject <- ModelApiResponse$new()$fromJSONString(content(http_response, "text")) + self$reason <- http_response$http_status_desc + self$errorObject <- ModelApiResponse$new()$fromJSONString(http_response$response) } else { self$status <- status self$reason <- reason diff --git a/samples/client/petstore/R-httr2/R/api_response.R b/samples/client/petstore/R-httr2/R/api_response.R index 2362fd4e4662..6035283a86da 100644 --- a/samples/client/petstore/R-httr2/R/api_response.R +++ b/samples/client/petstore/R-httr2/R/api_response.R @@ -12,12 +12,18 @@ #' @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 descriptoin 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 @@ -25,10 +31,20 @@ ApiResponse <- R6::R6Class( #' #' @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, response) { + 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/petstore/R-httr2/R/fake_api.R b/samples/client/petstore/R-httr2/R/fake_api.R index d00bb501f8be..5c5b6a9613b6 100644 --- a/samples/client/petstore/R-httr2/R/fake_api.R +++ b/samples/client/petstore/R-httr2/R/fake_api.R @@ -99,16 +99,15 @@ FakeApi <- R6::R6Class( #' @return User #' @export fake_data_file = function(dummy, var_data_file = NULL, data_file = NULL, ...) { - api_response <- self$fake_data_file_with_http_info(dummy, var_data_file, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$fake_data_file_with_http_info(dummy, var_data_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 data_file to ensure it's escaped correctly @@ -156,39 +155,40 @@ FakeApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "User", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R index 9dee32a91ccf..77ede8bd251b 100644 --- a/samples/client/petstore/R-httr2/R/pet_api.R +++ b/samples/client/petstore/R-httr2/R/pet_api.R @@ -544,16 +544,15 @@ PetApi <- R6::R6Class( #' @return Pet #' @export add_pet = function(pet, data_file = NULL, ...) { - api_response <- self$add_pet_with_http_info(pet, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$add_pet_with_http_info(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 } }, #' Add a new pet to the store @@ -609,39 +608,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Pet", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -661,16 +661,15 @@ PetApi <- R6::R6Class( #' @return void #' @export delete_pet = function(pet_id, api_key = NULL, ...) { - api_response <- self$delete_pet_with_http_info(pet_id, api_key, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$delete_pet_with_http_info(pet_id, api_key, ...) + 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 } }, #' Deletes a pet @@ -721,26 +720,27 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -760,16 +760,15 @@ PetApi <- R6::R6Class( #' @return array[Pet] #' @export find_pets_by_status = function(status, data_file = NULL, ...) { - api_response <- self$find_pets_by_status_with_http_info(status, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$find_pets_by_status_with_http_info(status, 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 } }, #' Finds Pets by status @@ -816,39 +815,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "array[Pet]", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -868,16 +868,15 @@ PetApi <- R6::R6Class( #' @return array[Pet] #' @export find_pets_by_tags = function(tags, data_file = NULL, ...) { - api_response <- self$find_pets_by_tags_with_http_info(tags, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$find_pets_by_tags_with_http_info(tags, 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 } }, #' Finds Pets by tags @@ -924,39 +923,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "array[Pet]", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "array[Pet]", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -976,16 +976,15 @@ PetApi <- R6::R6Class( #' @return Pet #' @export get_pet_by_id = function(pet_id, data_file = NULL, ...) { - api_response <- self$get_pet_by_id_with_http_info(pet_id, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$get_pet_by_id_with_http_info(pet_id, 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 } }, #' Find pet by ID @@ -1033,39 +1032,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Pet", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1086,20 +1086,19 @@ PetApi <- R6::R6Class( #' @return Pet #' @export get_pet_by_id_streaming = function(pet_id, stream_callback = NULL, data_file = NULL, ...) { - api_response <- self$get_pet_by_id_streaming_with_http_info(pet_id, stream_callback = stream_callback, data_file = data_file, ...) + local_var_response <- self$get_pet_by_id_streaming_with_http_info(pet_id, stream_callback = stream_callback, data_file = data_file, ...) if (typeof(stream_callback) == "closure") { # return void if streaming is enabled return(invisible(NULL)) } - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + 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 } }, #' Find pet by ID (streaming) @@ -1156,39 +1155,40 @@ PetApi <- R6::R6Class( return(invisible(NULL)) } - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Pet", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1208,16 +1208,15 @@ PetApi <- R6::R6Class( #' @return Pet #' @export update_pet = function(pet, data_file = NULL, ...) { - api_response <- self$update_pet_with_http_info(pet, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$update_pet_with_http_info(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 } }, #' Update an existing pet @@ -1267,39 +1266,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Pet", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Pet", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1320,16 +1320,15 @@ PetApi <- R6::R6Class( #' @return void #' @export update_pet_with_form = function(pet_id, name = NULL, status = NULL, ...) { - api_response <- self$update_pet_with_form_with_http_info(pet_id, name, status, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$update_pet_with_form_with_http_info(pet_id, name, status, ...) + 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 } }, #' Updates a pet in the store with form data @@ -1383,26 +1382,27 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1424,16 +1424,15 @@ PetApi <- R6::R6Class( #' @return ModelApiResponse #' @export upload_file = function(pet_id, additional_metadata = NULL, file = NULL, data_file = NULL, ...) { - api_response <- self$upload_file_with_http_info(pet_id, additional_metadata, file, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$upload_file_with_http_info(pet_id, additional_metadata, 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 } }, #' uploads an image @@ -1488,39 +1487,40 @@ PetApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "ModelApiResponse", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "ModelApiResponse", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } diff --git a/samples/client/petstore/R-httr2/R/store_api.R b/samples/client/petstore/R-httr2/R/store_api.R index 39980f7d5c92..addc0b0d6025 100644 --- a/samples/client/petstore/R-httr2/R/store_api.R +++ b/samples/client/petstore/R-httr2/R/store_api.R @@ -249,16 +249,15 @@ StoreApi <- R6::R6Class( #' @return void #' @export delete_order = function(order_id, ...) { - api_response <- self$delete_order_with_http_info(order_id, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$delete_order_with_http_info(order_id, ...) + 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 } }, #' Delete purchase order by ID @@ -304,26 +303,27 @@ StoreApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -342,16 +342,15 @@ StoreApi <- R6::R6Class( #' @return map(integer) #' @export get_inventory = function(data_file = NULL, ...) { - api_response <- self$get_inventory_with_http_info(data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$get_inventory_with_http_info(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 } }, #' Returns pet inventories by status @@ -390,39 +389,40 @@ StoreApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "map(integer)", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "map(integer)", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -442,16 +442,15 @@ StoreApi <- R6::R6Class( #' @return Order #' @export get_order_by_id = function(order_id, data_file = NULL, ...) { - api_response <- self$get_order_by_id_with_http_info(order_id, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$get_order_by_id_with_http_info(order_id, 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 } }, #' Find purchase order by ID @@ -498,39 +497,40 @@ StoreApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Order", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -550,16 +550,15 @@ StoreApi <- R6::R6Class( #' @return Order #' @export place_order = function(order, data_file = NULL, ...) { - api_response <- self$place_order_with_http_info(order, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$place_order_with_http_info(order, 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 } }, #' Place an order for a pet @@ -607,39 +606,40 @@ StoreApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "Order", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "Order", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } diff --git a/samples/client/petstore/R-httr2/R/user_api.R b/samples/client/petstore/R-httr2/R/user_api.R index f3ded748e1b2..a11452d1b917 100644 --- a/samples/client/petstore/R-httr2/R/user_api.R +++ b/samples/client/petstore/R-httr2/R/user_api.R @@ -435,16 +435,15 @@ UserApi <- R6::R6Class( #' @return void #' @export create_user = function(user, ...) { - api_response <- self$create_user_with_http_info(user, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$create_user_with_http_info(user, ...) + 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 } }, #' Create user @@ -495,26 +494,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -533,16 +533,15 @@ UserApi <- R6::R6Class( #' @return void #' @export create_users_with_array_input = function(user, ...) { - api_response <- self$create_users_with_array_input_with_http_info(user, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$create_users_with_array_input_with_http_info(user, ...) + 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 } }, #' Creates list of users with given input array @@ -596,26 +595,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -634,16 +634,15 @@ UserApi <- R6::R6Class( #' @return void #' @export create_users_with_list_input = function(user, ...) { - api_response <- self$create_users_with_list_input_with_http_info(user, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$create_users_with_list_input_with_http_info(user, ...) + 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 } }, #' Creates list of users with given input array @@ -697,26 +696,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -735,16 +735,15 @@ UserApi <- R6::R6Class( #' @return void #' @export delete_user = function(username, ...) { - api_response <- self$delete_user_with_http_info(username, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$delete_user_with_http_info(username, ...) + 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 } }, #' Delete user @@ -794,26 +793,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -833,16 +833,15 @@ UserApi <- R6::R6Class( #' @return User #' @export get_user_by_name = function(username, data_file = NULL, ...) { - api_response <- self$get_user_by_name_with_http_info(username, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$get_user_by_name_with_http_info(username, 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 } }, #' Get user by user name @@ -889,39 +888,40 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "User", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "User", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -942,16 +942,15 @@ UserApi <- R6::R6Class( #' @return character #' @export login_user = function(username, password, data_file = NULL, ...) { - api_response <- self$login_user_with_http_info(username, password, data_file = data_file, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$login_user_with_http_info(username, password, 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 } }, #' Logs user into the system @@ -1006,39 +1005,40 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { # save response in a file if (!is.null(data_file)) { - write(httr::content(local_var_resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file) + write(local_var_resp$response, data_file) } deserialized_resp_obj <- tryCatch( - self$api_client$deserialize(local_var_resp, "character", loadNamespace("petstore")), + self$api_client$deserialize(local_var_resp$response, "character", loadNamespace("petstore")), error = function(e) { rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) } ) - ApiResponse$new(deserialized_resp_obj, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + local_var_resp$content <- deserialized_resp_obj + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1056,16 +1056,15 @@ UserApi <- R6::R6Class( #' @return void #' @export logout_user = function(...) { - api_response <- self$logout_user_with_http_info(...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$logout_user_with_http_info(...) + 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 } }, #' Logs out current logged in user session @@ -1103,26 +1102,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } @@ -1142,16 +1142,15 @@ UserApi <- R6::R6Class( #' @return void #' @export update_user = function(username, user, ...) { - api_response <- self$update_user_with_http_info(username, user, ...) - local_var_response <- api_response$response - if (httr::status_code(local_var_response) >= 200 && httr::status_code(local_var_response) <= 299) { - api_response$content - } else if (httr::status_code(local_var_response) >= 300 && httr::status_code(local_var_response) <= 399) { - api_response - } else if (httr::status_code(local_var_response) >= 400 && httr::status_code(local_var_response) <= 499) { - api_response - } else if (httr::status_code(local_var_response) >= 500 && httr::status_code(local_var_response) <= 599) { - api_response + local_var_response <- self$update_user_with_http_info(username, user, ...) + 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 } }, #' Updated user @@ -1214,26 +1213,27 @@ UserApi <- R6::R6Class( body = local_var_body, ...) - if (httr::status_code(local_var_resp) >= 200 && httr::status_code(local_var_resp) <= 299) { - ApiResponse$new(NULL, local_var_resp) - } else if (httr::status_code(local_var_resp) >= 300 && httr::status_code(local_var_resp) <= 399) { - local_var_error_msg <- toString(content(local_var_resp)) + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { - local_var_error_msg <- paste("Server returned ", httr::status_code(local_var_resp), " response status code.") + local_var_error_msg <- paste("Server returned ", local_var_resp$status_code, " response status code.") } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 400 && httr::status_code(local_var_resp) <= 499) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api client exception encountered." } rlang::abort(message = local_var_error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = local_var_resp)) - } else if (httr::status_code(local_var_resp) >= 500 && httr::status_code(local_var_resp) <= 599) { - local_var_error_msg <- toString(content(local_var_resp)) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + local_var_error_msg <- local_var_resp$response if (local_var_error_msg == "") { local_var_error_msg <- "Api server exception encountered." } From 9a57950f99171e3410bfc5c2d72df8900d5ec4eb Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 31 Jul 2022 20:09:29 +0800 Subject: [PATCH 7/9] various fixes --- .../r/libraries/httr2/api_client.mustache | 88 ++++--------------- .../client/petstore/R-httr2/R/api_client.R | 86 ++++-------------- .../client/petstore/R-httr2/R/api_exception.R | 12 +-- .../client/petstore/R-httr2/docs/FakeApi.md | 10 ++- .../client/petstore/R-httr2/docs/PetApi.md | 86 +++++++++++------- .../client/petstore/R-httr2/docs/StoreApi.md | 38 ++++---- .../client/petstore/R-httr2/docs/UserApi.md | 68 ++++++++------ .../R-httr2/tests/testthat/test_petstore.R | 10 +-- 8 files changed, 166 insertions(+), 232 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index efad1600f675..9869cee399f9 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -245,89 +245,33 @@ ApiClient <- R6::R6Class( #} # perform the HTTP request - req_perform(req) + resp <- req %>% + req_error(is_error = function(resp) FALSE) %>% + req_perform() - #if (method == "GET") { - # if (typeof(stream_callback) == "closure") { - # httr::GET(url, query = query_params, headers, http_timeout, - # httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # httr::GET(url, query = query_params, headers, http_timeout, - # httr::user_agent(self$`user_agent`), ...) - # } - #} else if (method == "POST") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # httr::HEAD(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # httr::HEAD(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), ...) - # } - #} else if (method == "DELETE") { - # if (typeof(stream_callback) == "closure") { - # httr::DELETE(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # 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`." - # {{#useDefaultExceptionHandling}} - # stop(err_msg) - # {{/useDefaultExceptionHandling}} - # {{#useRlangExceptionHandling}} - # rlang::abort(message = err_msg, - # .subclass = "ApiException", - # ApiException = ApiException$new(status = 0, reason = err_msg)) - # {{/useRlangExceptionHandling}} - #} + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- resp %>% resp_status() + api_response$status_code_desc <- resp %>% resp_status_desc() + api_response$response <- resp %>% resp_body_string() + api_response$headers <- resp %>% resp_headers() + + api_response }, - #' Deserialize the content of api response to the given type. + #' Deserialize the content of API response to the given type. #' #' @description - #' Deserialize the content of api response to the given type. + #' Deserialize the content of API response to the given type. #' - #' @param resp Response object. + #' @param raw_response Raw response. #' @param return_type R return type. #' @param pkg_env Package environment. #' @return Deserialized object. #' @export - deserialize = function(resp, return_type, pkg_env) { - resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) + 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 diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index a0d4d763cb95..b9e46bbaa5d4 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -249,87 +249,33 @@ ApiClient <- R6::R6Class( #} # perform the HTTP request - req_perform(req) + resp <- req %>% + req_error(is_error = function(resp) FALSE) %>% + req_perform() - #if (method == "GET") { - # if (typeof(stream_callback) == "closure") { - # httr::GET(url, query = query_params, headers, http_timeout, - # httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # httr::GET(url, query = query_params, headers, http_timeout, - # httr::user_agent(self$`user_agent`), ...) - # } - #} else if (method == "POST") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # 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 { - # 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") { - # if (typeof(stream_callback) == "closure") { - # httr::HEAD(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # httr::HEAD(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), ...) - # } - #} else if (method == "DELETE") { - # if (typeof(stream_callback) == "closure") { - # httr::DELETE(url, query = query_params, headers, http_timeout, - # http_timeout, httr::user_agent(self$`user_agent`), write_stream(stream_callback), ...) - # } else { - # 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`." - # - # - # rlang::abort(message = err_msg, - # .subclass = "ApiException", - # ApiException = ApiException$new(status = 0, reason = err_msg)) - # - #} + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- resp %>% resp_status() + api_response$status_code_desc <- resp %>% resp_status_desc() + api_response$response <- resp %>% resp_body_string() + api_response$headers <- resp %>% resp_headers() + + api_response }, - #' Deserialize the content of api response to the given type. + #' Deserialize the content of API response to the given type. #' #' @description - #' Deserialize the content of api response to the given type. + #' Deserialize the content of API response to the given type. #' - #' @param resp Response object. + #' @param raw_response Raw response. #' @param return_type R return type. #' @param pkg_env Package environment. #' @return Deserialized object. #' @export - deserialize = function(resp, return_type, pkg_env) { - resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8")) + 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 diff --git a/samples/client/petstore/R-httr2/R/api_exception.R b/samples/client/petstore/R-httr2/R/api_exception.R index e198854bf340..77b1d26d111f 100644 --- a/samples/client/petstore/R-httr2/R/api_exception.R +++ b/samples/client/petstore/R-httr2/R/api_exception.R @@ -14,7 +14,7 @@ #' @field reason Reason of the ApiException #' @field body Body of the http response #' @field headers Headers of the http response -#' @field errorObject error object type +#' @field error_object error object type #' @export ApiException <- R6::R6Class( "ApiException", @@ -23,7 +23,7 @@ ApiException <- R6::R6Class( reason = NULL, body = NULL, headers = NULL, - errorObject = NULL, + error_object = NULL, #' Initialize a new ApiException class. #' #' @description @@ -43,13 +43,13 @@ ApiException <- R6::R6Class( self$body <- errorMsg self$headers <- http_response$headers self$reason <- http_response$http_status_desc - self$errorObject <- ModelApiResponse$new()$fromJSONString(http_response$response) + self$error_object <- ModelApiResponse$new()$fromJSONString(http_response$response) } else { self$status <- status self$reason <- reason self$body <- NULL self$headers <- NULL - self$errorObject <- NULL + self$error_object <- NULL } }, #' Returns the string format of ApiException. @@ -73,9 +73,9 @@ ApiException <- R6::R6Class( errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "") errorMsg <- paste(errorMsg, self$body, "\n") } - if (!is.null(self$errorObject)) { + if (!is.null(self$error_object)) { errorMsg <- paste(errorMsg, "Error object : ", "\n", sep = "") - errorMsg <- paste(errorMsg, self$errorObject$toJSONString(), "\n") + errorMsg <- paste(errorMsg, self$error_object$toJSONString(), "\n") } errorMsg } diff --git a/samples/client/petstore/R-httr2/docs/FakeApi.md b/samples/client/petstore/R-httr2/docs/FakeApi.md index cd3a202b1889..cdd8f8d38e70 100644 --- a/samples/client/petstore/R-httr2/docs/FakeApi.md +++ b/samples/client/petstore/R-httr2/docs/FakeApi.md @@ -31,14 +31,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` diff --git a/samples/client/petstore/R-httr2/docs/PetApi.md b/samples/client/petstore/R-httr2/docs/PetApi.md index 813a6ee2f69e..1a67dfab08a8 100644 --- a/samples/client/petstore/R-httr2/docs/PetApi.md +++ b/samples/client/petstore/R-httr2/docs/PetApi.md @@ -41,14 +41,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -101,12 +103,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -160,14 +164,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -221,14 +227,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -282,14 +290,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -346,14 +356,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -408,14 +420,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -471,12 +485,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -533,14 +549,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` diff --git a/samples/client/petstore/R-httr2/docs/StoreApi.md b/samples/client/petstore/R-httr2/docs/StoreApi.md index d3fd2535dd2e..be64f9ba72ba 100644 --- a/samples/client/petstore/R-httr2/docs/StoreApi.md +++ b/samples/client/petstore/R-httr2/docs/StoreApi.md @@ -31,12 +31,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -89,14 +91,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -144,14 +148,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -204,14 +210,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` diff --git a/samples/client/petstore/R-httr2/docs/UserApi.md b/samples/client/petstore/R-httr2/docs/UserApi.md index 64d9c4224520..55b9970fab54 100644 --- a/samples/client/petstore/R-httr2/docs/UserApi.md +++ b/samples/client/petstore/R-httr2/docs/UserApi.md @@ -37,12 +37,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -93,12 +95,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -149,12 +153,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -205,12 +211,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -262,14 +270,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -323,14 +333,16 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # deserialized response object - response.object <- result$content + dput(result$content) # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -382,12 +394,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` @@ -436,12 +450,14 @@ result <- tryCatch( ) # In case of error, print the error object if (!is.null(result$ApiException)) { - cat(result$ApiException$toString()) + dput(result$ApiException) + # error object + dput(result$ApiException$error_object) } else { # response headers - response.headers <- result$response$headers + dput(result$response$headers) # response status code - response.status.code <- result$response$status_code + dput(result$response$status_code) } ``` diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R index fb292a70feb2..4c240b4c7613 100644 --- a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R +++ b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R @@ -116,11 +116,11 @@ test_that("get_pet_by_id_streaming", { test_that("GetPetById with data_file", { # test to ensure json is saved to the file `get_pet_by_id.json` - pet_response <- pet_api$GetPetById(pet_id, data_file = "get_pet_by_id.json") - response <- read_json("get_pet_by_id.json") - expect_true(!is.null(response)) - expect_equal(response$id, pet_id) - expect_equal(response$name, "name_test") + #pet_response <- pet_api$GetPetById(pet_id, data_file = "get_pet_by_id.json") + #response <- read_json("get_pet_by_id.json") + #expect_true(!is.null(response)) + #expect_equal(response$id, pet_id) + #expect_equal(response$name, "name_test") }) test_that("Tests allOf", { From 5153164643990c29d060643690734cb6b469b1c0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 31 Jul 2022 23:15:56 +0800 Subject: [PATCH 8/9] add data file test --- .../src/main/resources/r/api.mustache | 5 ++++ samples/client/petstore/R-httr2/R/pet_api.R | 2 +- .../client/petstore/R-httr2/test_petstore.R | 24 +++++++++++-------- .../R-httr2/tests/testthat/test_petstore.R | 10 ++++---- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/api.mustache b/modules/openapi-generator/src/main/resources/r/api.mustache index dab15bfcf4c9..c7c4c4b90fba 100644 --- a/modules/openapi-generator/src/main/resources/r/api.mustache +++ b/modules/openapi-generator/src/main/resources/r/api.mustache @@ -265,7 +265,12 @@ "{{baseName}}" = {{paramName}}{{^-last}},{{/-last}} {{/isFile}} {{#isFile}} + {{^isHttr2}} "{{baseName}}" = httr::upload_file({{paramName}}){{^-last}},{{/-last}} + {{/isHttr2}} + {{#isHttr2}} + "{{baseName}}" = {{paramName}}{{^-last}},{{/-last}} + {{/isHttr2}} {{/isFile}} {{/formParams}} ) diff --git a/samples/client/petstore/R-httr2/R/pet_api.R b/samples/client/petstore/R-httr2/R/pet_api.R index 77ede8bd251b..ae81853573f9 100644 --- a/samples/client/petstore/R-httr2/R/pet_api.R +++ b/samples/client/petstore/R-httr2/R/pet_api.R @@ -1461,7 +1461,7 @@ PetApi <- R6::R6Class( local_var_body <- list( "additionalMetadata" = additional_metadata, - "file" = httr::upload_file(file) + "file" = file ) local_var_url_path <- "/pet/{petId}/uploadImage" diff --git a/samples/client/petstore/R-httr2/test_petstore.R b/samples/client/petstore/R-httr2/test_petstore.R index ed6479680ee5..353c52b6bcd6 100644 --- a/samples/client/petstore/R-httr2/test_petstore.R +++ b/samples/client/petstore/R-httr2/test_petstore.R @@ -17,16 +17,19 @@ result <- tryCatch( var_pet_id <- 56 # integer | ID of pet to return -#Find pet by ID (streaming) -api_instance <- PetApi$new() -# Configure API key authorization: api_key -api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; -result <- tryCatch( - # to save the result into a file, simply add the optional `data_file` parameter, e.g. - # api_instance$GetPetByIdStreaming(var_pet_id, data_file = "result.txt"), - api_instance$GetPetByIdStreaming(var_pet_id, stream_callback = function(x) { print(x) }), - ApiException = function(ex) ex - ) +pet_response <- api_instance$get_pet_by_id(var_pet_id, data_file = "get_pet_by_id.json") +response <- read_json("get_pet_by_id.json") + +##Find pet by ID (streaming) +#api_instance <- PetApi$new() +## Configure API key authorization: api_key +#api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY'; +#result <- tryCatch( +# # to save the result into a file, simply add the optional `data_file` parameter, e.g. +# # api_instance$GetPetByIdStreaming(var_pet_id, data_file = "result.txt"), +# api_instance$GetPetByIdStreaming(var_pet_id, stream_callback = function(x) { print(x) }), +# ApiException = function(ex) ex +# ) # In case of error, print the error object #if (!is.null(result$ApiException)) { # cat(result$ApiException$toString()) @@ -40,6 +43,7 @@ result <- tryCatch( #} + ##errorMsg <- "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}" ###errorMsg <- '{"code": 404, "message": "Not found"}' ##a <- ModelApiResponse$new()$fromJSONString(errorMsg) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R index 4c240b4c7613..3fa7f640c1a8 100644 --- a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R +++ b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R @@ -116,11 +116,11 @@ test_that("get_pet_by_id_streaming", { test_that("GetPetById with data_file", { # test to ensure json is saved to the file `get_pet_by_id.json` - #pet_response <- pet_api$GetPetById(pet_id, data_file = "get_pet_by_id.json") - #response <- read_json("get_pet_by_id.json") - #expect_true(!is.null(response)) - #expect_equal(response$id, pet_id) - #expect_equal(response$name, "name_test") + pet_response <- pet_api$get_pet_by_id(pet_id, data_file = "get_pet_by_id.json") + response <- read_json("get_pet_by_id.json") + expect_true(!is.null(response)) + expect_equal(response$id, pet_id) + expect_equal(response$name, "name_test") }) test_that("Tests allOf", { From c1f11de9e01d9821503dbab4fa56173acd29d9a7 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 1 Aug 2022 00:08:00 +0800 Subject: [PATCH 9/9] fix streaming, add tests --- .../r/libraries/httr2/api_client.mustache | 30 +++++++++---------- .../client/petstore/R-httr2/R/api_client.R | 30 +++++++++---------- .../client/petstore/R-httr2/test_petstore.R | 9 ++++-- .../R-httr2/tests/testthat/test_petstore.R | 25 ++++++++-------- 4 files changed, 49 insertions(+), 45 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache index 9869cee399f9..9fac8f302b59 100644 --- a/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/r/libraries/httr2/api_client.mustache @@ -240,23 +240,23 @@ ApiClient <- R6::R6Class( req <- req %>% req_method(method) # stream data - #if (typeof(stream_callback) == "closure") { - # req %>% req_stream(stream_callback) - #} - - # perform the HTTP request - resp <- req %>% - req_error(is_error = function(resp) FALSE) %>% - req_perform() + if (typeof(stream_callback) == "closure") { + req %>% req_stream(stream_callback) + } else { + # perform the HTTP request + resp <- req %>% + req_error(is_error = function(resp) FALSE) %>% + req_perform() - # return ApiResponse - api_response <- ApiResponse$new() - api_response$status_code <- resp %>% resp_status() - api_response$status_code_desc <- resp %>% resp_status_desc() - api_response$response <- resp %>% resp_body_string() - api_response$headers <- resp %>% resp_headers() + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- resp %>% resp_status() + api_response$status_code_desc <- resp %>% resp_status_desc() + api_response$response <- resp %>% resp_body_string() + api_response$headers <- resp %>% resp_headers() - api_response + api_response + } }, #' Deserialize the content of API response to the given type. #' diff --git a/samples/client/petstore/R-httr2/R/api_client.R b/samples/client/petstore/R-httr2/R/api_client.R index b9e46bbaa5d4..91de834777f7 100644 --- a/samples/client/petstore/R-httr2/R/api_client.R +++ b/samples/client/petstore/R-httr2/R/api_client.R @@ -244,23 +244,23 @@ ApiClient <- R6::R6Class( req <- req %>% req_method(method) # stream data - #if (typeof(stream_callback) == "closure") { - # req %>% req_stream(stream_callback) - #} - - # perform the HTTP request - resp <- req %>% - req_error(is_error = function(resp) FALSE) %>% - req_perform() + if (typeof(stream_callback) == "closure") { + req %>% req_stream(stream_callback) + } else { + # perform the HTTP request + resp <- req %>% + req_error(is_error = function(resp) FALSE) %>% + req_perform() - # return ApiResponse - api_response <- ApiResponse$new() - api_response$status_code <- resp %>% resp_status() - api_response$status_code_desc <- resp %>% resp_status_desc() - api_response$response <- resp %>% resp_body_string() - api_response$headers <- resp %>% resp_headers() + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- resp %>% resp_status() + api_response$status_code_desc <- resp %>% resp_status_desc() + api_response$response <- resp %>% resp_body_string() + api_response$headers <- resp %>% resp_headers() - api_response + api_response + } }, #' Deserialize the content of API response to the given type. #' diff --git a/samples/client/petstore/R-httr2/test_petstore.R b/samples/client/petstore/R-httr2/test_petstore.R index 353c52b6bcd6..a0a15a2972b4 100644 --- a/samples/client/petstore/R-httr2/test_petstore.R +++ b/samples/client/petstore/R-httr2/test_petstore.R @@ -1,6 +1,7 @@ install.packages("petstore_1.0.0.tar.gz",repos=NULL, type="source") library(petstore) +library(jsonlite) var_pet <- Pet$new("name_example", list("photoUrls_example"), 56, Category$new(56, "name_example"), list(Tag$new(56, "name_example")), "available") # Pet | Pet object that needs to be added to the store @@ -11,7 +12,7 @@ api_instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN'; result <- tryCatch( # to save the result into a file, simply add the optional `data_file` parameter, e.g. # api_instance$AddPet(var_pet, data_file = "result.txt"), - api_instance$AddPet(var_pet), + api_instance$add_pet(var_pet), ApiException = function(ex) ex ) @@ -19,6 +20,10 @@ var_pet_id <- 56 # integer | ID of pet to return pet_response <- api_instance$get_pet_by_id(var_pet_id, data_file = "get_pet_by_id.json") response <- read_json("get_pet_by_id.json") +dput(response) + +# test streaming +api_instance$get_pet_by_id_streaming(var_pet_id, stream_callback = function(x) { print(x) }) ##Find pet by ID (streaming) #api_instance <- PetApi$new() @@ -42,8 +47,6 @@ response <- read_json("get_pet_by_id.json") # response.status.code <- result$response$status_code #} - - ##errorMsg <- "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}" ###errorMsg <- '{"code": 404, "message": "Not found"}' ##a <- ModelApiResponse$new()$fromJSONString(errorMsg) diff --git a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R index 3fa7f640c1a8..2383ebd33178 100644 --- a/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R +++ b/samples/client/petstore/R-httr2/tests/testthat/test_petstore.R @@ -101,18 +101,19 @@ test_that("get_pet_by_id_streaming", { ) }) -#test_that("test GetPetById exception", { -# # test exception -# result <- tryCatch(petApi$GetPetById(98765), # petId not exist -# error = function(ex) ex -# ) -# -# expect_true(!is.null(result)) -# #expect_equal(result$toString(),"") -# expect_equal(result, "1") -# #expect_equal(result$ApiException$errorObject$code, 1) -# #expect_equal(response$name, "name_test") -#}) +test_that("Test GetPetById exception", { + # test exception + result <- tryCatch(pet_api$get_pet_by_id(98765), # petId not exist + ApiException = function(ex) ex + ) + + expect_true(!is.null(result)) + expect_true(!is.null(result$ApiException)) + expect_equal(result$ApiException$status, 404) + # test error object `ApiResponse` + expect_equal(result$ApiException$error_object$toString(), "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}") + expect_equal(result$ApiException$error_object$code, 1) +}) test_that("GetPetById with data_file", { # test to ensure json is saved to the file `get_pet_by_id.json`