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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/openapi-generator/src/main/resources/r/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@
"{{baseName}}":
{{#isListContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}[%d]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}{{#hasMore}},{{/hasMore}}
{{#isNumeric}}[%f]{{/isNumeric}}{{^isNumeric}}[%s]{{/isNumeric}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
[%s]{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{/isListContainer}}
{{^isListContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}%d{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}{{#hasMore}},{{/hasMore}}
{{#isNumeric}}%f{{/isNumeric}}{{^isNumeric}}"%s"{{/isNumeric}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
%s{{#hasMore}},{{/hasMore}}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/R/R/category.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Category <- R6::R6Class(
sprintf(
'{
"id":
%d,
%f,
"name":
"%s"
}',
Expand Down
75 changes: 75 additions & 0 deletions samples/client/petstore/R/R/inline_object.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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


#' InlineObject Class
#'
#' @field name
#' @field status
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InlineObject <- R6::R6Class(
'InlineObject',
public = list(
`name` = NULL,
`status` = NULL,
initialize = function(`name`=NULL, `status`=NULL, ...){
local.optional.var <- list(...)
if (!is.null(`name`)) {
stopifnot(is.character(`name`), length(`name`) == 1)
self$`name` <- `name`
}
if (!is.null(`status`)) {
stopifnot(is.character(`status`), length(`status`) == 1)
self$`status` <- `status`
}
},
toJSON = function() {
InlineObjectObject <- list()
if (!is.null(self$`name`)) {
InlineObjectObject[['name']] <-
self$`name`
}
if (!is.null(self$`status`)) {
InlineObjectObject[['status']] <-
self$`status`
}

InlineObjectObject
},
fromJSON = function(InlineObjectJson) {
InlineObjectObject <- jsonlite::fromJSON(InlineObjectJson)
if (!is.null(InlineObjectObject$`name`)) {
self$`name` <- InlineObjectObject$`name`
}
if (!is.null(InlineObjectObject$`status`)) {
self$`status` <- InlineObjectObject$`status`
}
},
toJSONString = function() {
sprintf(
'{
"name":
"%s",
"status":
"%s"
}',
self$`name`,
self$`status`
)
},
fromJSONString = function(InlineObjectJson) {
InlineObjectObject <- jsonlite::fromJSON(InlineObjectJson)
self$`name` <- InlineObjectObject$`name`
self$`status` <- InlineObjectObject$`status`
self
}
)
)
74 changes: 74 additions & 0 deletions samples/client/petstore/R/R/inline_object1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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


#' InlineObject1 Class
#'
#' @field additionalMetadata
#' @field file
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
InlineObject1 <- R6::R6Class(
'InlineObject1',
public = list(
`additionalMetadata` = NULL,
`file` = NULL,
initialize = function(`additionalMetadata`=NULL, `file`=NULL, ...){
local.optional.var <- list(...)
if (!is.null(`additionalMetadata`)) {
stopifnot(is.character(`additionalMetadata`), length(`additionalMetadata`) == 1)
self$`additionalMetadata` <- `additionalMetadata`
}
if (!is.null(`file`)) {
self$`file` <- `file`
}
},
toJSON = function() {
InlineObject1Object <- list()
if (!is.null(self$`additionalMetadata`)) {
InlineObject1Object[['additionalMetadata']] <-
self$`additionalMetadata`
}
if (!is.null(self$`file`)) {
InlineObject1Object[['file']] <-
self$`file`
}

InlineObject1Object
},
fromJSON = function(InlineObject1Json) {
InlineObject1Object <- jsonlite::fromJSON(InlineObject1Json)
if (!is.null(InlineObject1Object$`additionalMetadata`)) {
self$`additionalMetadata` <- InlineObject1Object$`additionalMetadata`
}
if (!is.null(InlineObject1Object$`file`)) {
self$`file` <- InlineObject1Object$`file`
}
},
toJSONString = function() {
sprintf(
'{
"additionalMetadata":
"%s",
"file":
"%s"
}',
self$`additionalMetadata`,
self$`file`
)
},
fromJSONString = function(InlineObject1Json) {
InlineObject1Object <- jsonlite::fromJSON(InlineObject1Json)
self$`additionalMetadata` <- InlineObject1Object$`additionalMetadata`
self$`file` <- InlineObject1Object$`file`
self
}
)
)
2 changes: 1 addition & 1 deletion samples/client/petstore/R/R/model_api_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ModelApiResponse <- R6::R6Class(
sprintf(
'{
"code":
%d,
%f,
"type":
"%s",
"message":
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/R/R/order.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ Order <- R6::R6Class(
sprintf(
'{
"id":
%d,
%f,
"petId":
%d,
%f,
"quantity":
%d,
%f,
"shipDate":
"%s",
"status":
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/R/R/pet.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Pet <- R6::R6Class(
sprintf(
'{
"id":
%d,
%f,
"category":
%s,
"name":
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/R/R/tag.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Tag <- R6::R6Class(
sprintf(
'{
"id":
%d,
%f,
"name":
"%s"
}',
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/R/R/user.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ User <- R6::R6Class(
sprintf(
'{
"id":
%d,
%f,
"username":
"%s",
"firstName":
Expand All @@ -149,7 +149,7 @@ User <- R6::R6Class(
"phone":
"%s",
"userStatus":
%d
%f
}',
self$`id`,
self$`username`,
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/R/docs/InlineObject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# petstore::InlineObject

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **character** | Updated name of the pet | [optional]
**status** | **character** | Updated status of the pet | [optional]


9 changes: 9 additions & 0 deletions samples/client/petstore/R/docs/InlineObject1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# petstore::InlineObject1

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additionalMetadata** | **character** | Additional data to pass to server | [optional]
**file** | **data.frame** | file to upload | [optional]


23 changes: 23 additions & 0 deletions samples/client/petstore/R/tests/testthat/test_inline_object.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate

context("Test InlineObject")

model.instance <- InlineObject$new()

test_that("name", {
# tests for the property `name` (character)
# Updated name of the pet

# uncomment below to test the property
#expect_equal(model.instance$`name`, "EXPECTED_RESULT")
})

test_that("status", {
# tests for the property `status` (character)
# Updated status of the pet

# uncomment below to test the property
#expect_equal(model.instance$`status`, "EXPECTED_RESULT")
})

23 changes: 23 additions & 0 deletions samples/client/petstore/R/tests/testthat/test_inline_object1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate

context("Test InlineObject1")

model.instance <- InlineObject1$new()

test_that("additionalMetadata", {
# tests for the property `additionalMetadata` (character)
# Additional data to pass to server

# uncomment below to test the property
#expect_equal(model.instance$`additionalMetadata`, "EXPECTED_RESULT")
})

test_that("file", {
# tests for the property `file` (data.frame)
# file to upload

# uncomment below to test the property
#expect_equal(model.instance$`file`, "EXPECTED_RESULT")
})