forked from loafle/openapi-generator-original
[R] escape item reserved words in model items (#12653)
* fix item reserved words * add comment * add log
This commit is contained in:
@@ -56,6 +56,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected boolean returnExceptionOnFailure = false;
|
||||
protected String exceptionPackage = "default";
|
||||
protected Map<String, String> exceptionPackages = new LinkedHashMap<String, String>();
|
||||
protected Set<String> itemReservedWords = new TreeSet<String>();
|
||||
|
||||
public static final String EXCEPTION_PACKAGE = "exceptionPackage";
|
||||
public static final String USE_DEFAULT_EXCEPTION = "useDefaultExceptionHandling";
|
||||
@@ -130,6 +131,11 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
)
|
||||
);
|
||||
|
||||
// these are reserved words in items: https://github.com/r-lib/R6/blob/main/R/r6_class.R#L484
|
||||
itemReservedWords.add("self");
|
||||
itemReservedWords.add("private");
|
||||
itemReservedWords.add("super");
|
||||
|
||||
languageSpecificPrimitives.clear();
|
||||
languageSpecificPrimitives.add("integer");
|
||||
languageSpecificPrimitives.add("numeric");
|
||||
@@ -305,6 +311,12 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// escape item reserved words with "item_" prefix
|
||||
if (itemReservedWords.contains(name)) {
|
||||
LOGGER.info("The item `{}` has been renamed to `item_{}` as it's a reserved word.", name, name);
|
||||
return "item_" + name;
|
||||
}
|
||||
|
||||
// don't do anything as we'll put property name inside ` `, e.g. `date-time`
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#' @format An \code{R6Class} generator object
|
||||
#'
|
||||
{{#vars}}
|
||||
#' @field {{baseName}} {{title}} {{#isContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/isContainer}}{{^isPrimitiveType}}\link{{=<% %>=}}{<%/isPrimitiveType%><%={{ }}=%>{{#isContainer}}{{#items}}{{dataType}}{{/items}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}{{=<% %>=}}<%^isPrimitiveType%>}<%={{ }}=%>{{/isPrimitiveType}}{{#isContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/isContainer}} {{^required}}[optional]{{/required}}
|
||||
#' @field {{name}} {{title}} {{#isContainer}}{{#isArray}}list( {{/isArray}}{{#isMap}}named list( {{/isMap}}{{/isContainer}}{{^isPrimitiveType}}\link{{=<% %>=}}{<%/isPrimitiveType%><%={{ }}=%>{{#isContainer}}{{#items}}{{dataType}}{{/items}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}{{=<% %>=}}<%^isPrimitiveType%>}<%={{ }}=%>{{/isPrimitiveType}}{{#isContainer}}{{#isArray}} ){{/isArray}}{{#isMap}} ){{/isMap}}{{/isContainer}} {{^required}}[optional]{{/required}}
|
||||
#'
|
||||
{{/vars}}
|
||||
#' @importFrom R6 R6Class
|
||||
@@ -25,129 +25,129 @@
|
||||
{{/parent}}
|
||||
public = list(
|
||||
{{#vars}}
|
||||
`{{{baseName}}}` = NULL,
|
||||
`{{{name}}}` = NULL,
|
||||
{{/vars}}
|
||||
initialize = function(
|
||||
{{#requiredVars}}`{{baseName}}`, {{/requiredVars}}{{#optionalVars}}`{{baseName}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
|
||||
{{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}`={{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}...
|
||||
) {
|
||||
{{#requiredVars}}
|
||||
if (!missing(`{{baseName}}`)) {
|
||||
if (!missing(`{{name}}`)) {
|
||||
{{^isContainer}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{nme}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{nme}}`), length(`{{nme}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
stopifnot(is.logical(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isBoolean}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(`{{baseName}}`))
|
||||
stopifnot(R6::is.R6(`{{name}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
stopifnot(is.vector(`{{name}}`), length(`{{name}}`) != 0)
|
||||
sapply(`{{name}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
stopifnot(is.vector(`{{name}}`), length(`{{name}}`) != 0)
|
||||
sapply(`{{name}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
self$`{{baseName}}` <- `{{baseName}}`
|
||||
self$`{{name}}` <- `{{name}}`
|
||||
}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
if (!is.null(`{{baseName}}`)) {
|
||||
if (!is.null(`{{name}}`)) {
|
||||
{{^isContainer}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
stopifnot(is.logical(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.logical(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isBoolean}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(`{{baseName}}`), length(`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(`{{name}}`), length(`{{name}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(`{{baseName}}`))
|
||||
stopifnot(R6::is.R6(`{{name}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
stopifnot(is.vector(`{{name}}`), length(`{{name}}`) != 0)
|
||||
sapply(`{{name}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(`{{baseName}}`), length(`{{baseName}}`) != 0)
|
||||
sapply(`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
stopifnot(is.vector(`{{name}}`), length(`{{name}}`) != 0)
|
||||
sapply(`{{name}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
self$`{{baseName}}` <- `{{baseName}}`
|
||||
self$`{{name}}` <- `{{name}}`
|
||||
}
|
||||
{{/optionalVars}}
|
||||
},
|
||||
toJSON = function() {
|
||||
{{classname}}Object <- list()
|
||||
{{#vars}}
|
||||
if (!is.null(self$`{{baseName}}`)) {
|
||||
if (!is.null(self$`{{name}}`)) {
|
||||
{{classname}}Object[['{{baseName}}']] <-
|
||||
{{#isContainer}}
|
||||
{{#isArray}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
self$`{{name}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
lapply(self$`{{baseName}}`, function(x) x$toJSON())
|
||||
lapply(self$`{{name}}`, function(x) x$toJSON())
|
||||
{{/isPrimitiveType}}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
self$`{{name}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
lapply(self$`{{baseName}}`, function(x) x$toJSON())
|
||||
lapply(self$`{{name}}`, function(x) x$toJSON())
|
||||
{{/isPrimitiveType}}
|
||||
{{/isMap}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}`
|
||||
self$`{{name}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}`$toJSON()
|
||||
self$`{{name}}`$toJSON()
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
}
|
||||
@@ -158,18 +158,18 @@
|
||||
fromJSON = function({{classname}}Json) {
|
||||
{{classname}}Object <- jsonlite::fromJSON({{classname}}Json)
|
||||
{{#vars}}
|
||||
if (!is.null({{classname}}Object$`{{baseName}}`)) {
|
||||
if (!is.null({{classname}}Object$`{{name}}`)) {
|
||||
{{#isContainer}}
|
||||
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
|
||||
self$`{{name}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{name}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
self$`{{name}}` <- {{classname}}Object$`{{name}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{baseName}}Object <- {{dataType}}$new()
|
||||
{{baseName}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE, digits = NA))
|
||||
self$`{{baseName}}` <- {{baseName}}Object
|
||||
{{name}}Object <- {{dataType}}$new()
|
||||
{{name}}Object$fromJSON(jsonlite::toJSON({{classname}}Object${{name}}, auto_unbox = TRUE, digits = NA))
|
||||
self$`{{name}}` <- {{name}}Object
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
}
|
||||
@@ -179,7 +179,7 @@
|
||||
toJSONString = function() {
|
||||
jsoncontent <- c(
|
||||
{{#vars}}
|
||||
if (!is.null(self$`{{baseName}}`)) {
|
||||
if (!is.null(self$`{{name}}`)) {
|
||||
sprintf(
|
||||
'"{{baseName}}":
|
||||
{{#isContainer}}
|
||||
@@ -208,27 +208,27 @@
|
||||
{{#isContainer}}
|
||||
{{#isArray}}
|
||||
{{#isPrimitiveType}}
|
||||
paste(unlist(lapply(self$`{{{baseName}}}`, function(x) paste0('"', x, '"'))), collapse=",")
|
||||
paste(unlist(lapply(self$`{{{name}}}`, function(x) paste0('"', x, '"'))), collapse=",")
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
paste(sapply(self$`{{{baseName}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
|
||||
paste(sapply(self$`{{{name}}}`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
|
||||
{{/isPrimitiveType}}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
{{#isPrimitiveType}}
|
||||
jsonlite::toJSON(lapply(self$`{{{baseName}}}`, function(x){ x }), auto_unbox = TRUE, digits=NA)
|
||||
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x }), auto_unbox = TRUE, digits=NA)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::toJSON(lapply(self$`{{{baseName}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
|
||||
jsonlite::toJSON(lapply(self$`{{{name}}}`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
|
||||
{{/isPrimitiveType}}
|
||||
{{/isMap}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isBoolean}}tolower({{/isBoolean}}self$`{{baseName}}`{{#isBoolean}}){{/isBoolean}}
|
||||
{{#isBoolean}}tolower({{/isBoolean}}self$`{{name}}`{{#isBoolean}}){{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
jsonlite::toJSON(self$`{{baseName}}`$toJSON(), auto_unbox=TRUE, digits = NA)
|
||||
jsonlite::toJSON(self$`{{name}}`$toJSON(), auto_unbox=TRUE, digits = NA)
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
)}{{^-last}},{{/-last}}
|
||||
@@ -242,14 +242,14 @@
|
||||
{{#vars}}
|
||||
{{! AAPI - added condition for handling container type of parameters, map and array}}
|
||||
{{#isContainer}}
|
||||
self$`{{baseName}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{baseName}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
|
||||
self$`{{name}}` <- ApiClient$new()$deserializeObj({{classname}}Object$`{{name}}`, "{{dataType}}", loadNamespace("{{packageName}}"))
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{classname}}Object$`{{baseName}}`
|
||||
self$`{{name}}` <- {{classname}}Object$`{{name}}`
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
self$`{{baseName}}` <- {{dataType}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{baseName}}, auto_unbox = TRUE, digits = NA))
|
||||
self$`{{name}}` <- {{dataType}}$new()$fromJSON(jsonlite::toJSON({{classname}}Object${{name}}, auto_unbox = TRUE, digits = NA))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{/vars}}
|
||||
@@ -258,49 +258,49 @@
|
||||
validateJSON = function(input) {
|
||||
input_json <- jsonlite::fromJSON(input)
|
||||
{{#requiredVars}}
|
||||
# check the required field `{{baseName}}`
|
||||
if (!is.null(input_json$`{{baseName}}`)) {
|
||||
# check the required field `{{name}}`
|
||||
if (!is.null(input_json$`{{name}}`)) {
|
||||
{{^isContainer}}
|
||||
{{#isInteger}}
|
||||
stopifnot(is.numeric(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isInteger}}
|
||||
{{#isLong}}
|
||||
stopifnot(is.numeric(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
stopifnot(is.numeric(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
stopifnot(is.numeric(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.numeric(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isDouble}}
|
||||
{{#isString}}
|
||||
stopifnot(is.character(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
stopifnot(is.logical(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.logical(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isBoolean}}
|
||||
{{#isDate}}
|
||||
stopifnot(is.character(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
stopifnot(is.character(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) == 1)
|
||||
stopifnot(is.character(input_json$`{{name}}`), length(input_json$`{{name}}`) == 1)
|
||||
{{/isDateTime}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(R6::is.R6(input_json$`{{baseName}}`))
|
||||
stopifnot(R6::is.R6(input_json$`{{name}}`))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
stopifnot(is.vector(input_json$`{{baseName}}`), length(input_json$`{{baseName}}`) != 0)
|
||||
tmp <- sapply(input_json$`{{baseName}}`, function(x) stopifnot(is.character(x)))
|
||||
stopifnot(is.vector(input_json$`{{name}}`), length(input_json$`{{name}}`) != 0)
|
||||
tmp <- sapply(input_json$`{{name}}`, function(x) stopifnot(is.character(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
stopifnot(is.vector(input_json$`{{baseName}}`), length(json_input$`{{baseName}}`) != 0)
|
||||
tmp <- sapply(input_json$`{{baseName}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
stopifnot(is.vector(input_json$`{{name}}`), length(json_input$`{{name}}`) != 0)
|
||||
tmp <- sapply(input_json$`{{name}}`, function(x) stopifnot(R6::is.R6(x)))
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
} else {
|
||||
stop(paste("The JSON input `", input, "` is invalid for {{classname}}: the required field `{{baseName}}` is missing."))
|
||||
stop(paste("The JSON input `", input, "` is invalid for {{classname}}: the required field `{{name}}` is missing."))
|
||||
}
|
||||
{{/requiredVars}}
|
||||
}
|
||||
|
||||
@@ -784,6 +784,18 @@ components:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
Special:
|
||||
title: An uploaded response
|
||||
description: Describes the result of uploading an image resource
|
||||
type: object
|
||||
properties:
|
||||
self:
|
||||
type: integer
|
||||
format: int32
|
||||
private:
|
||||
type: string
|
||||
super:
|
||||
type: string
|
||||
Dog:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Animal'
|
||||
|
||||
@@ -22,6 +22,7 @@ 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
|
||||
@@ -44,6 +45,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/Special.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/UpdatePetRequest.md
|
||||
|
||||
@@ -26,6 +26,7 @@ export(ModelApiResponse)
|
||||
export(Order)
|
||||
export(Pet)
|
||||
export(Pig)
|
||||
export(Special)
|
||||
export(Tag)
|
||||
export(UpdatePetRequest)
|
||||
export(User)
|
||||
|
||||
117
samples/client/petstore/R/R/special.R
Normal file
117
samples/client/petstore/R/R/special.R
Normal file
@@ -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)
|
||||
}
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
@@ -95,6 +95,7 @@ Class | Method | HTTP request | Description
|
||||
- [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)
|
||||
|
||||
12
samples/client/petstore/R/docs/Special.md
Normal file
12
samples/client/petstore/R/docs/Special.md
Normal file
@@ -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]
|
||||
|
||||
|
||||
27
samples/client/petstore/R/tests/testthat/test_special.R
Normal file
27
samples/client/petstore/R/tests/testthat/test_special.R
Normal file
@@ -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")
|
||||
})
|
||||
Reference in New Issue
Block a user