-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[R] escape item reserved words in model items (#12653)
* fix item reserved words * add comment * add log
- Loading branch information
Showing
9 changed files
with
256 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 72 additions & 72 deletions
144
modules/openapi-generator/src/main/resources/r/modelGeneric.mustache
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#' 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] | ||
#' | ||
#' @importFrom R6 R6Class | ||
#' @importFrom jsonlite fromJSON toJSON | ||
#' @export | ||
Special <- R6::R6Class( | ||
'Special', | ||
public = list( | ||
`item_self` = NULL, | ||
`item_private` = NULL, | ||
`item_super` = NULL, | ||
initialize = function( | ||
`item_self`=NULL, `item_private`=NULL, `item_super`=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` | ||
} | ||
}, | ||
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` | ||
} | ||
|
||
SpecialObject | ||
}, | ||
fromJSON = function(SpecialJson) { | ||
SpecialObject <- jsonlite::fromJSON(SpecialJson) | ||
if (!is.null(SpecialObject$`item_self`)) { | ||
self$`item_self` <- SpecialObject$`item_self` | ||
} | ||
if (!is.null(SpecialObject$`item_private`)) { | ||
self$`item_private` <- SpecialObject$`item_private` | ||
} | ||
if (!is.null(SpecialObject$`item_super`)) { | ||
self$`item_super` <- SpecialObject$`item_super` | ||
} | ||
self | ||
}, | ||
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` | ||
)} | ||
) | ||
jsoncontent <- paste(jsoncontent, collapse = ",") | ||
paste('{', jsoncontent, '}', sep = "") | ||
}, | ||
fromJSONString = function(SpecialJson) { | ||
SpecialObject <- jsonlite::fromJSON(SpecialJson) | ||
self$`item_self` <- SpecialObject$`item_self` | ||
self$`item_private` <- SpecialObject$`item_private` | ||
self$`item_super` <- SpecialObject$`item_super` | ||
self | ||
}, | ||
validateJSON = function(input) { | ||
input_json <- jsonlite::fromJSON(input) | ||
} | ||
|
||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 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] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
}) |