From 05d49d910761280b2bbaf8d7bcdf44dc964cc9b3 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 29 May 2022 07:22:18 +0800 Subject: [PATCH] Add support for allOf in R client generator (#12487) * add support for all in R client generator * update samples --- .../src/main/resources/r/model.mustache | 3 + .../src/test/resources/3_0/r/petstore.yaml | 35 ++++ .../petstore/R/.openapi-generator/FILES | 12 ++ samples/client/petstore/R/NAMESPACE | 6 + .../petstore/R/R/allof_tag_api_response.R | 156 ++++++++++++++++++ samples/client/petstore/R/R/animal.R | 90 ++++++++++ samples/client/petstore/R/R/cat.R | 113 +++++++++++++ samples/client/petstore/R/R/cat_all_of.R | 68 ++++++++ samples/client/petstore/R/R/dog.R | 113 +++++++++++++ samples/client/petstore/R/R/dog_all_of.R | 68 ++++++++ samples/client/petstore/R/README.md | 6 + .../petstore/R/docs/AllofTagApiResponse.md | 13 ++ samples/client/petstore/R/docs/Animal.md | 10 ++ samples/client/petstore/R/docs/Cat.md | 11 ++ samples/client/petstore/R/docs/CatAllOf.md | 9 + samples/client/petstore/R/docs/Dog.md | 11 ++ samples/client/petstore/R/docs/DogAllOf.md | 9 + .../testthat/test_allof_tag_api_response.R | 41 +++++ .../petstore/R/tests/testthat/test_animal.R | 20 +++ .../petstore/R/tests/testthat/test_cat.R | 27 +++ .../R/tests/testthat/test_cat_all_of.R | 13 ++ .../petstore/R/tests/testthat/test_dog.R | 27 +++ .../R/tests/testthat/test_dog_all_of.R | 13 ++ .../petstore/R/tests/testthat/test_petstore.R | 19 +++ 24 files changed, 893 insertions(+) create mode 100644 samples/client/petstore/R/R/allof_tag_api_response.R create mode 100644 samples/client/petstore/R/R/animal.R create mode 100644 samples/client/petstore/R/R/cat.R create mode 100644 samples/client/petstore/R/R/cat_all_of.R create mode 100644 samples/client/petstore/R/R/dog.R create mode 100644 samples/client/petstore/R/R/dog_all_of.R create mode 100644 samples/client/petstore/R/docs/AllofTagApiResponse.md create mode 100644 samples/client/petstore/R/docs/Animal.md create mode 100644 samples/client/petstore/R/docs/Cat.md create mode 100644 samples/client/petstore/R/docs/CatAllOf.md create mode 100644 samples/client/petstore/R/docs/Dog.md create mode 100644 samples/client/petstore/R/docs/DogAllOf.md create mode 100644 samples/client/petstore/R/tests/testthat/test_allof_tag_api_response.R create mode 100644 samples/client/petstore/R/tests/testthat/test_animal.R create mode 100644 samples/client/petstore/R/tests/testthat/test_cat.R create mode 100644 samples/client/petstore/R/tests/testthat/test_cat_all_of.R create mode 100644 samples/client/petstore/R/tests/testthat/test_dog.R create mode 100644 samples/client/petstore/R/tests/testthat/test_dog_all_of.R diff --git a/modules/openapi-generator/src/main/resources/r/model.mustache b/modules/openapi-generator/src/main/resources/r/model.mustache index caa50d80fd5..1585f110d2e 100644 --- a/modules/openapi-generator/src/main/resources/r/model.mustache +++ b/modules/openapi-generator/src/main/resources/r/model.mustache @@ -21,6 +21,9 @@ #' @export {{classname}} <- R6::R6Class( '{{classname}}', + {{#parent}} + inherit = {{{.}}}, + {{/parent}} public = list( {{#vars}} `{{{baseName}}}` = NULL, diff --git a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml index 502deb56f88..965860d44d0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml @@ -766,3 +766,38 @@ components: type: string message: type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - type: object + properties: + declawed: + type: boolean + Address: + type: object + additionalProperties: + type: integer + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + allof_tag_api_response: + allOf: + - $ref: '#/components/schemas/Tag' + - $ref: '#/components/schemas/ApiResponse' diff --git a/samples/client/petstore/R/.openapi-generator/FILES b/samples/client/petstore/R/.openapi-generator/FILES index b728b3f1d60..7c5f45bad20 100644 --- a/samples/client/petstore/R/.openapi-generator/FILES +++ b/samples/client/petstore/R/.openapi-generator/FILES @@ -3,9 +3,15 @@ .travis.yml DESCRIPTION NAMESPACE +R/allof_tag_api_response.R +R/animal.R R/api_client.R R/api_response.R +R/cat.R +R/cat_all_of.R R/category.R +R/dog.R +R/dog_all_of.R R/fake_api.R R/model_api_response.R R/order.R @@ -16,7 +22,13 @@ R/tag.R R/user.R R/user_api.R README.md +docs/AllofTagApiResponse.md +docs/Animal.md +docs/Cat.md +docs/CatAllOf.md docs/Category.md +docs/Dog.md +docs/DogAllOf.md docs/FakeApi.md docs/ModelApiResponse.md docs/Order.md diff --git a/samples/client/petstore/R/NAMESPACE b/samples/client/petstore/R/NAMESPACE index dc2b03b289f..a889c35c709 100644 --- a/samples/client/petstore/R/NAMESPACE +++ b/samples/client/petstore/R/NAMESPACE @@ -11,7 +11,13 @@ export(ApiClient) export(ApiResponse) # Models +export(AllofTagApiResponse) +export(Animal) +export(Cat) +export(CatAllOf) export(Category) +export(Dog) +export(DogAllOf) export(ModelApiResponse) export(Order) export(Pet) diff --git a/samples/client/petstore/R/R/allof_tag_api_response.R b/samples/client/petstore/R/R/allof_tag_api_response.R new file mode 100644 index 00000000000..c3937aacc5e --- /dev/null +++ b/samples/client/petstore/R/R/allof_tag_api_response.R @@ -0,0 +1,156 @@ +# 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 = function( + `id`=NULL, `name`=NULL, `code`=NULL, `type`=NULL, `message`=NULL, ... + ) { + local.optional.var <- list(...) + 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` + } + }, + 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 + }, + fromJSON = function(AllofTagApiResponseJson) { + AllofTagApiResponseObject <- jsonlite::fromJSON(AllofTagApiResponseJson) + if (!is.null(AllofTagApiResponseObject$`id`)) { + self$`id` <- AllofTagApiResponseObject$`id` + } + if (!is.null(AllofTagApiResponseObject$`name`)) { + self$`name` <- AllofTagApiResponseObject$`name` + } + if (!is.null(AllofTagApiResponseObject$`code`)) { + self$`code` <- AllofTagApiResponseObject$`code` + } + if (!is.null(AllofTagApiResponseObject$`type`)) { + self$`type` <- AllofTagApiResponseObject$`type` + } + if (!is.null(AllofTagApiResponseObject$`message`)) { + self$`message` <- AllofTagApiResponseObject$`message` + } + self + }, + 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 = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(AllofTagApiResponseJson) { + AllofTagApiResponseObject <- jsonlite::fromJSON(AllofTagApiResponseJson) + self$`id` <- AllofTagApiResponseObject$`id` + self$`name` <- AllofTagApiResponseObject$`name` + self$`code` <- AllofTagApiResponseObject$`code` + self$`type` <- AllofTagApiResponseObject$`type` + self$`message` <- AllofTagApiResponseObject$`message` + self + } + ) +) diff --git a/samples/client/petstore/R/R/animal.R b/samples/client/petstore/R/R/animal.R new file mode 100644 index 00000000000..94c77837920 --- /dev/null +++ b/samples/client/petstore/R/R/animal.R @@ -0,0 +1,90 @@ +# 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 = function( + `className`, `color`='red', ... + ) { + local.optional.var <- list(...) + 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` + } + }, + toJSON = function() { + AnimalObject <- list() + if (!is.null(self$`className`)) { + AnimalObject[['className']] <- + self$`className` + } + if (!is.null(self$`color`)) { + AnimalObject[['color']] <- + self$`color` + } + + AnimalObject + }, + fromJSON = function(AnimalJson) { + AnimalObject <- jsonlite::fromJSON(AnimalJson) + if (!is.null(AnimalObject$`className`)) { + self$`className` <- AnimalObject$`className` + } + if (!is.null(AnimalObject$`color`)) { + self$`color` <- AnimalObject$`color` + } + self + }, + 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 = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(AnimalJson) { + AnimalObject <- jsonlite::fromJSON(AnimalJson) + self$`className` <- AnimalObject$`className` + self$`color` <- AnimalObject$`color` + self + } + ) +) diff --git a/samples/client/petstore/R/R/cat.R b/samples/client/petstore/R/R/cat.R new file mode 100644 index 00000000000..b321a7a75f0 --- /dev/null +++ b/samples/client/petstore/R/R/cat.R @@ -0,0 +1,113 @@ +# 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 = function( + `className`, `color`='red', `declawed`=NULL, ... + ) { + local.optional.var <- list(...) + 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` + } + }, + 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 + }, + fromJSON = function(CatJson) { + CatObject <- jsonlite::fromJSON(CatJson) + if (!is.null(CatObject$`className`)) { + self$`className` <- CatObject$`className` + } + if (!is.null(CatObject$`color`)) { + self$`color` <- CatObject$`color` + } + if (!is.null(CatObject$`declawed`)) { + self$`declawed` <- CatObject$`declawed` + } + self + }, + 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 = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(CatJson) { + CatObject <- jsonlite::fromJSON(CatJson) + self$`className` <- CatObject$`className` + self$`color` <- CatObject$`color` + self$`declawed` <- CatObject$`declawed` + self + } + ) +) diff --git a/samples/client/petstore/R/R/cat_all_of.R b/samples/client/petstore/R/R/cat_all_of.R new file mode 100644 index 00000000000..ae4892a880e --- /dev/null +++ b/samples/client/petstore/R/R/cat_all_of.R @@ -0,0 +1,68 @@ +# 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 = function( + `declawed`=NULL, ... + ) { + local.optional.var <- list(...) + if (!is.null(`declawed`)) { + stopifnot(is.logical(`declawed`), length(`declawed`) == 1) + self$`declawed` <- `declawed` + } + }, + toJSON = function() { + CatAllOfObject <- list() + if (!is.null(self$`declawed`)) { + CatAllOfObject[['declawed']] <- + self$`declawed` + } + + CatAllOfObject + }, + fromJSON = function(CatAllOfJson) { + CatAllOfObject <- jsonlite::fromJSON(CatAllOfJson) + if (!is.null(CatAllOfObject$`declawed`)) { + self$`declawed` <- CatAllOfObject$`declawed` + } + self + }, + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`declawed`)) { + sprintf( + '"declawed": + %s + ', + tolower(self$`declawed`) + )} + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(CatAllOfJson) { + CatAllOfObject <- jsonlite::fromJSON(CatAllOfJson) + self$`declawed` <- CatAllOfObject$`declawed` + self + } + ) +) diff --git a/samples/client/petstore/R/R/dog.R b/samples/client/petstore/R/R/dog.R new file mode 100644 index 00000000000..09c782a8192 --- /dev/null +++ b/samples/client/petstore/R/R/dog.R @@ -0,0 +1,113 @@ +# 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 = function( + `className`, `color`='red', `breed`=NULL, ... + ) { + local.optional.var <- list(...) + 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` + } + }, + 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 + }, + fromJSON = function(DogJson) { + DogObject <- jsonlite::fromJSON(DogJson) + if (!is.null(DogObject$`className`)) { + self$`className` <- DogObject$`className` + } + if (!is.null(DogObject$`color`)) { + self$`color` <- DogObject$`color` + } + if (!is.null(DogObject$`breed`)) { + self$`breed` <- DogObject$`breed` + } + self + }, + 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 = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(DogJson) { + DogObject <- jsonlite::fromJSON(DogJson) + self$`className` <- DogObject$`className` + self$`color` <- DogObject$`color` + self$`breed` <- DogObject$`breed` + self + } + ) +) diff --git a/samples/client/petstore/R/R/dog_all_of.R b/samples/client/petstore/R/R/dog_all_of.R new file mode 100644 index 00000000000..243d542f395 --- /dev/null +++ b/samples/client/petstore/R/R/dog_all_of.R @@ -0,0 +1,68 @@ +# 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 = function( + `breed`=NULL, ... + ) { + local.optional.var <- list(...) + if (!is.null(`breed`)) { + stopifnot(is.character(`breed`), length(`breed`) == 1) + self$`breed` <- `breed` + } + }, + toJSON = function() { + DogAllOfObject <- list() + if (!is.null(self$`breed`)) { + DogAllOfObject[['breed']] <- + self$`breed` + } + + DogAllOfObject + }, + fromJSON = function(DogAllOfJson) { + DogAllOfObject <- jsonlite::fromJSON(DogAllOfJson) + if (!is.null(DogAllOfObject$`breed`)) { + self$`breed` <- DogAllOfObject$`breed` + } + self + }, + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`breed`)) { + sprintf( + '"breed": + "%s" + ', + self$`breed` + )} + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(DogAllOfJson) { + DogAllOfObject <- jsonlite::fromJSON(DogAllOfJson) + self$`breed` <- DogAllOfObject$`breed` + self + } + ) +) diff --git a/samples/client/petstore/R/README.md b/samples/client/petstore/R/README.md index 66e82ab48e6..cb277954ff9 100644 --- a/samples/client/petstore/R/README.md +++ b/samples/client/petstore/R/README.md @@ -81,7 +81,13 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [AllofTagApiResponse](docs/AllofTagApiResponse.md) + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) + - [CatAllOf](docs/CatAllOf.md) - [Category](docs/Category.md) + - [Dog](docs/Dog.md) + - [DogAllOf](docs/DogAllOf.md) - [ModelApiResponse](docs/ModelApiResponse.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/R/docs/AllofTagApiResponse.md b/samples/client/petstore/R/docs/AllofTagApiResponse.md new file mode 100644 index 00000000000..14bcc1e22cf --- /dev/null +++ b/samples/client/petstore/R/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/docs/Animal.md b/samples/client/petstore/R/docs/Animal.md new file mode 100644 index 00000000000..f21cc2147b6 --- /dev/null +++ b/samples/client/petstore/R/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/docs/Cat.md b/samples/client/petstore/R/docs/Cat.md new file mode 100644 index 00000000000..d6e99c85c69 --- /dev/null +++ b/samples/client/petstore/R/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/docs/CatAllOf.md b/samples/client/petstore/R/docs/CatAllOf.md new file mode 100644 index 00000000000..ab2f71b88e2 --- /dev/null +++ b/samples/client/petstore/R/docs/CatAllOf.md @@ -0,0 +1,9 @@ +# petstore::CatAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R/docs/Dog.md b/samples/client/petstore/R/docs/Dog.md new file mode 100644 index 00000000000..6a7c1f53a14 --- /dev/null +++ b/samples/client/petstore/R/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/docs/DogAllOf.md b/samples/client/petstore/R/docs/DogAllOf.md new file mode 100644 index 00000000000..76783e8800c --- /dev/null +++ b/samples/client/petstore/R/docs/DogAllOf.md @@ -0,0 +1,9 @@ +# petstore::DogAllOf + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **character** | | [optional] + + diff --git a/samples/client/petstore/R/tests/testthat/test_allof_tag_api_response.R b/samples/client/petstore/R/tests/testthat/test_allof_tag_api_response.R new file mode 100644 index 00000000000..90a5d04d3f6 --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_animal.R b/samples/client/petstore/R/tests/testthat/test_animal.R new file mode 100644 index 00000000000..4402cf03c54 --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_cat.R b/samples/client/petstore/R/tests/testthat/test_cat.R new file mode 100644 index 00000000000..ab85fe3340f --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_cat_all_of.R b/samples/client/petstore/R/tests/testthat/test_cat_all_of.R new file mode 100644 index 00000000000..83ee2fb835c --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_dog.R b/samples/client/petstore/R/tests/testthat/test_dog.R new file mode 100644 index 00000000000..9c04cc78067 --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_dog_all_of.R b/samples/client/petstore/R/tests/testthat/test_dog_all_of.R new file mode 100644 index 00000000000..6d11847f66d --- /dev/null +++ b/samples/client/petstore/R/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/tests/testthat/test_petstore.R b/samples/client/petstore/R/tests/testthat/test_petstore.R index 8ce2edfd5c3..88319edf3f2 100644 --- a/samples/client/petstore/R/tests/testthat/test_petstore.R +++ b/samples/client/petstore/R/tests/testthat/test_petstore.R @@ -100,6 +100,25 @@ test_that("GetPetById with data_file", { 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("GetPetById", { # pet.id <- pet.id # pet <- Pet$new(pet.id, NULL, "name_test2",