forked from loafle/openapi-generator-original
[R] Remove obsolete importMapping code, add tests (#13345)
* remove import obsolete code, add tests * remove man fodler * update .gitignore
This commit is contained in:
parent
bdf9114d3e
commit
c81c103572
2
.gitignore
vendored
2
.gitignore
vendored
@ -224,6 +224,8 @@ samples/client/petstore/R/**/petstore.Rcheck/
|
|||||||
samples/client/petstore/R/**/*.tar.gz
|
samples/client/petstore/R/**/*.tar.gz
|
||||||
samples/client/petstore/R/R.Rproj
|
samples/client/petstore/R/R.Rproj
|
||||||
samples/client/petstore/R/man/
|
samples/client/petstore/R/man/
|
||||||
|
samples/client/petstore/R-httr2-wrapper/man/
|
||||||
|
samples/client/petstore/R-httr2/man/
|
||||||
|
|
||||||
# elixir
|
# elixir
|
||||||
samples/client/petstore/elixir/_build/
|
samples/client/petstore/elixir/_build/
|
||||||
|
@ -176,7 +176,10 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("map", "map");
|
typeMapping.put("map", "map");
|
||||||
typeMapping.put("object", "object");
|
typeMapping.put("object", "object");
|
||||||
|
|
||||||
|
// no need for import mapping as R doesn't reqiure api,model import
|
||||||
|
// https://github.com/OpenAPITools/openapi-generator/issues/2217
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
|
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "R package name (convention: lowercase).")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "R package name (convention: lowercase).")
|
||||||
.defaultValue("openapi"));
|
.defaultValue("openapi"));
|
||||||
@ -587,31 +590,6 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
var.vendorExtensions.put("x-r-doc-type", constructRdocType(var));
|
var.vendorExtensions.put("x-r-doc-type", constructRdocType(var));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove model imports to avoid error
|
|
||||||
List<Map<String, String>> imports = objs.getImports();
|
|
||||||
final String prefix = modelPackage();
|
|
||||||
Iterator<Map<String, String>> iterator = imports.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
String _import = iterator.next().get("import");
|
|
||||||
if (_import.startsWith(prefix))
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
// recursively add import for mapping one type to multiple imports
|
|
||||||
List<Map<String, String>> recursiveImports = objs.getImports();
|
|
||||||
if (recursiveImports != null) {
|
|
||||||
ListIterator<Map<String, String>> listIterator = imports.listIterator();
|
|
||||||
while (listIterator.hasNext()) {
|
|
||||||
String _import = listIterator.next().get("import");
|
|
||||||
// if the import package happens to be found in the importMapping (key)
|
|
||||||
// add the corresponding import package to the list
|
|
||||||
if (importMapping.containsKey(_import)) {
|
|
||||||
listIterator.add(createMapping("import", importMapping.get(_import)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return postProcessModelsEnum(objs);
|
return postProcessModelsEnum(objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,3 +1001,11 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- className
|
- className
|
||||||
|
Date:
|
||||||
|
description: to test the model name `Date`
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
className:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- className
|
||||||
|
@ -17,6 +17,7 @@ R/cat.R
|
|||||||
R/cat_all_of.R
|
R/cat_all_of.R
|
||||||
R/category.R
|
R/category.R
|
||||||
R/danish_pig.R
|
R/danish_pig.R
|
||||||
|
R/date.R
|
||||||
R/dog.R
|
R/dog.R
|
||||||
R/dog_all_of.R
|
R/dog_all_of.R
|
||||||
R/fake_api.R
|
R/fake_api.R
|
||||||
@ -47,6 +48,7 @@ docs/Cat.md
|
|||||||
docs/CatAllOf.md
|
docs/CatAllOf.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
docs/DanishPig.md
|
docs/DanishPig.md
|
||||||
|
docs/Date.md
|
||||||
docs/Dog.md
|
docs/Dog.md
|
||||||
docs/DogAllOf.md
|
docs/DogAllOf.md
|
||||||
docs/FakeApi.md
|
docs/FakeApi.md
|
||||||
|
@ -25,6 +25,7 @@ export(Cat)
|
|||||||
export(CatAllOf)
|
export(CatAllOf)
|
||||||
export(Category)
|
export(Category)
|
||||||
export(DanishPig)
|
export(DanishPig)
|
||||||
|
export(Date)
|
||||||
export(Dog)
|
export(Dog)
|
||||||
export(DogAllOf)
|
export(DogAllOf)
|
||||||
export(Mammal)
|
export(Mammal)
|
||||||
|
211
samples/client/petstore/R-httr2-wrapper/R/date.R
Normal file
211
samples/client/petstore/R-httr2-wrapper/R/date.R
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
#' Create a new Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' to test the model name `Date`
|
||||||
|
#'
|
||||||
|
#' @docType class
|
||||||
|
#' @title Date
|
||||||
|
#' @description Date Class
|
||||||
|
#' @format An \code{R6Class} generator object
|
||||||
|
#' @field className character
|
||||||
|
#' @field _field_list a list of fields list(character)
|
||||||
|
#' @field additional_properties additional properties list(character) [optional]
|
||||||
|
#' @importFrom R6 R6Class
|
||||||
|
#' @importFrom jsonlite fromJSON toJSON
|
||||||
|
#' @export
|
||||||
|
Date <- R6::R6Class(
|
||||||
|
"Date",
|
||||||
|
public = list(
|
||||||
|
`className` = NULL,
|
||||||
|
`_field_list` = c("className"),
|
||||||
|
`additional_properties` = list(),
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @param className className
|
||||||
|
#' @param additional_properties additonal properties (optional)
|
||||||
|
#' @param ... Other optional arguments.
|
||||||
|
#' @export
|
||||||
|
initialize = function(
|
||||||
|
`className`, additional_properties = NULL, ...
|
||||||
|
) {
|
||||||
|
if (!missing(`className`)) {
|
||||||
|
stopifnot(is.character(`className`), length(`className`) == 1)
|
||||||
|
self$`className` <- `className`
|
||||||
|
}
|
||||||
|
if (!is.null(additional_properties)) {
|
||||||
|
for (key in names(additional_properties)) {
|
||||||
|
self$additional_properties[[key]] <- additional_properties[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSON = function() {
|
||||||
|
DateObject <- list()
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
DateObject[["className"]] <-
|
||||||
|
self$`className`
|
||||||
|
}
|
||||||
|
for (key in names(self$additional_properties)) {
|
||||||
|
DateObject[[key]] <- self$additional_properties[[key]]
|
||||||
|
}
|
||||||
|
|
||||||
|
DateObject
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSON = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
if (!is.null(this_object$`className`)) {
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
}
|
||||||
|
# process additional properties/fields in the payload
|
||||||
|
for (key in names(this_object)) {
|
||||||
|
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
|
||||||
|
self$additional_properties[[key]] <- this_object[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSONString = function() {
|
||||||
|
jsoncontent <- c(
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
sprintf(
|
||||||
|
'"className":
|
||||||
|
"%s"
|
||||||
|
',
|
||||||
|
self$`className`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||||
|
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||||
|
json_obj <- jsonlite::fromJSON(json_string)
|
||||||
|
for (key in names(self$additional_properties)) {
|
||||||
|
json_obj[[key]] <- self$additional_properties[[key]]
|
||||||
|
}
|
||||||
|
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSONString = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
# process additional properties/fields in the payload
|
||||||
|
for (key in names(this_object)) {
|
||||||
|
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
|
||||||
|
self$additional_properties[[key]] <- this_object[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' Validate JSON input with respect to Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Validate JSON input with respect to Date 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 Date: the required field `className` is missing."))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @return String representation of Date
|
||||||
|
#' @export
|
||||||
|
toString = function() {
|
||||||
|
self$toJSONString()
|
||||||
|
},
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @return true if the values in all fields are valid.
|
||||||
|
#' @export
|
||||||
|
isValid = function() {
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
return(FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
TRUE
|
||||||
|
},
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @return A list of invalid fields (if any).
|
||||||
|
#' @export
|
||||||
|
getInvalidFields = function() {
|
||||||
|
invalid_fields <- list()
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
|
||||||
|
}
|
||||||
|
|
||||||
|
invalid_fields
|
||||||
|
},
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @export
|
||||||
|
print = function() {
|
||||||
|
print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
invisible(self)
|
||||||
|
}),
|
||||||
|
# Lock the class to prevent modifications to the method or field
|
||||||
|
lock_class = TRUE
|
||||||
|
)
|
||||||
|
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||||
|
#Date$unlock()
|
||||||
|
#
|
||||||
|
## Below is an example to define the print fnuction
|
||||||
|
#Date$set("public", "print", function(...) {
|
||||||
|
# print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
# invisible(self)
|
||||||
|
#})
|
||||||
|
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||||
|
#Date$lock()
|
||||||
|
|
@ -98,6 +98,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [CatAllOf](docs/CatAllOf.md)
|
- [CatAllOf](docs/CatAllOf.md)
|
||||||
- [Category](docs/Category.md)
|
- [Category](docs/Category.md)
|
||||||
- [DanishPig](docs/DanishPig.md)
|
- [DanishPig](docs/DanishPig.md)
|
||||||
|
- [Date](docs/Date.md)
|
||||||
- [Dog](docs/Dog.md)
|
- [Dog](docs/Dog.md)
|
||||||
- [DogAllOf](docs/DogAllOf.md)
|
- [DogAllOf](docs/DogAllOf.md)
|
||||||
- [Mammal](docs/Mammal.md)
|
- [Mammal](docs/Mammal.md)
|
||||||
|
10
samples/client/petstore/R-httr2-wrapper/docs/Date.md
Normal file
10
samples/client/petstore/R-httr2-wrapper/docs/Date.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# petstore::Date
|
||||||
|
|
||||||
|
to test the model name `Date`
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**className** | **character** | |
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
|
||||||
|
context("Test Date")
|
||||||
|
|
||||||
|
model_instance <- Date$new()
|
||||||
|
|
||||||
|
test_that("className", {
|
||||||
|
# tests for the property `className` (character)
|
||||||
|
|
||||||
|
# uncomment below to test the property
|
||||||
|
#expect_equal(model.instance$`className`, "EXPECTED_RESULT")
|
||||||
|
})
|
@ -17,6 +17,7 @@ R/cat.R
|
|||||||
R/cat_all_of.R
|
R/cat_all_of.R
|
||||||
R/category.R
|
R/category.R
|
||||||
R/danish_pig.R
|
R/danish_pig.R
|
||||||
|
R/date.R
|
||||||
R/dog.R
|
R/dog.R
|
||||||
R/dog_all_of.R
|
R/dog_all_of.R
|
||||||
R/fake_api.R
|
R/fake_api.R
|
||||||
@ -46,6 +47,7 @@ docs/Cat.md
|
|||||||
docs/CatAllOf.md
|
docs/CatAllOf.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
docs/DanishPig.md
|
docs/DanishPig.md
|
||||||
|
docs/Date.md
|
||||||
docs/Dog.md
|
docs/Dog.md
|
||||||
docs/DogAllOf.md
|
docs/DogAllOf.md
|
||||||
docs/FakeApi.md
|
docs/FakeApi.md
|
||||||
|
@ -23,6 +23,7 @@ export(Cat)
|
|||||||
export(CatAllOf)
|
export(CatAllOf)
|
||||||
export(Category)
|
export(Category)
|
||||||
export(DanishPig)
|
export(DanishPig)
|
||||||
|
export(Date)
|
||||||
export(Dog)
|
export(Dog)
|
||||||
export(DogAllOf)
|
export(DogAllOf)
|
||||||
export(Mammal)
|
export(Mammal)
|
||||||
|
178
samples/client/petstore/R-httr2/R/date.R
Normal file
178
samples/client/petstore/R-httr2/R/date.R
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
#' Create a new Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' to test the model name `Date`
|
||||||
|
#'
|
||||||
|
#' @docType class
|
||||||
|
#' @title Date
|
||||||
|
#' @description Date Class
|
||||||
|
#' @format An \code{R6Class} generator object
|
||||||
|
#' @field className character
|
||||||
|
#' @importFrom R6 R6Class
|
||||||
|
#' @importFrom jsonlite fromJSON toJSON
|
||||||
|
#' @export
|
||||||
|
Date <- R6::R6Class(
|
||||||
|
"Date",
|
||||||
|
public = list(
|
||||||
|
`className` = NULL,
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @param className className
|
||||||
|
#' @param ... Other optional arguments.
|
||||||
|
#' @export
|
||||||
|
initialize = function(
|
||||||
|
`className`, ...
|
||||||
|
) {
|
||||||
|
if (!missing(`className`)) {
|
||||||
|
stopifnot(is.character(`className`), length(`className`) == 1)
|
||||||
|
self$`className` <- `className`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSON = function() {
|
||||||
|
DateObject <- list()
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
DateObject[["className"]] <-
|
||||||
|
self$`className`
|
||||||
|
}
|
||||||
|
DateObject
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSON = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
if (!is.null(this_object$`className`)) {
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
}
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSONString = function() {
|
||||||
|
jsoncontent <- c(
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
sprintf(
|
||||||
|
'"className":
|
||||||
|
"%s"
|
||||||
|
',
|
||||||
|
self$`className`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||||
|
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSONString = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' Validate JSON input with respect to Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Validate JSON input with respect to Date 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 Date: the required field `className` is missing."))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @return String representation of Date
|
||||||
|
#' @export
|
||||||
|
toString = function() {
|
||||||
|
self$toJSONString()
|
||||||
|
},
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @return true if the values in all fields are valid.
|
||||||
|
#' @export
|
||||||
|
isValid = function() {
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
return(FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
TRUE
|
||||||
|
},
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @return A list of invalid fields (if any).
|
||||||
|
#' @export
|
||||||
|
getInvalidFields = function() {
|
||||||
|
invalid_fields <- list()
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
|
||||||
|
}
|
||||||
|
|
||||||
|
invalid_fields
|
||||||
|
},
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @export
|
||||||
|
print = function() {
|
||||||
|
print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
invisible(self)
|
||||||
|
}),
|
||||||
|
# Lock the class to prevent modifications to the method or field
|
||||||
|
lock_class = TRUE
|
||||||
|
)
|
||||||
|
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||||
|
#Date$unlock()
|
||||||
|
#
|
||||||
|
## Below is an example to define the print fnuction
|
||||||
|
#Date$set("public", "print", function(...) {
|
||||||
|
# print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
# invisible(self)
|
||||||
|
#})
|
||||||
|
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||||
|
#Date$lock()
|
||||||
|
|
@ -98,6 +98,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [CatAllOf](docs/CatAllOf.md)
|
- [CatAllOf](docs/CatAllOf.md)
|
||||||
- [Category](docs/Category.md)
|
- [Category](docs/Category.md)
|
||||||
- [DanishPig](docs/DanishPig.md)
|
- [DanishPig](docs/DanishPig.md)
|
||||||
|
- [Date](docs/Date.md)
|
||||||
- [Dog](docs/Dog.md)
|
- [Dog](docs/Dog.md)
|
||||||
- [DogAllOf](docs/DogAllOf.md)
|
- [DogAllOf](docs/DogAllOf.md)
|
||||||
- [Mammal](docs/Mammal.md)
|
- [Mammal](docs/Mammal.md)
|
||||||
|
10
samples/client/petstore/R-httr2/docs/Date.md
Normal file
10
samples/client/petstore/R-httr2/docs/Date.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# petstore::Date
|
||||||
|
|
||||||
|
to test the model name `Date`
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**className** | **character** | |
|
||||||
|
|
||||||
|
|
13
samples/client/petstore/R-httr2/tests/testthat/test_date.R
Normal file
13
samples/client/petstore/R-httr2/tests/testthat/test_date.R
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
|
||||||
|
context("Test Date")
|
||||||
|
|
||||||
|
model_instance <- Date$new()
|
||||||
|
|
||||||
|
test_that("className", {
|
||||||
|
# tests for the property `className` (character)
|
||||||
|
|
||||||
|
# uncomment below to test the property
|
||||||
|
#expect_equal(model.instance$`className`, "EXPECTED_RESULT")
|
||||||
|
})
|
@ -17,6 +17,7 @@ R/cat.R
|
|||||||
R/cat_all_of.R
|
R/cat_all_of.R
|
||||||
R/category.R
|
R/category.R
|
||||||
R/danish_pig.R
|
R/danish_pig.R
|
||||||
|
R/date.R
|
||||||
R/dog.R
|
R/dog.R
|
||||||
R/dog_all_of.R
|
R/dog_all_of.R
|
||||||
R/fake_api.R
|
R/fake_api.R
|
||||||
@ -46,6 +47,7 @@ docs/Cat.md
|
|||||||
docs/CatAllOf.md
|
docs/CatAllOf.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
docs/DanishPig.md
|
docs/DanishPig.md
|
||||||
|
docs/Date.md
|
||||||
docs/Dog.md
|
docs/Dog.md
|
||||||
docs/DogAllOf.md
|
docs/DogAllOf.md
|
||||||
docs/FakeApi.md
|
docs/FakeApi.md
|
||||||
|
@ -23,6 +23,7 @@ export(Cat)
|
|||||||
export(CatAllOf)
|
export(CatAllOf)
|
||||||
export(Category)
|
export(Category)
|
||||||
export(DanishPig)
|
export(DanishPig)
|
||||||
|
export(Date)
|
||||||
export(Dog)
|
export(Dog)
|
||||||
export(DogAllOf)
|
export(DogAllOf)
|
||||||
export(Mammal)
|
export(Mammal)
|
||||||
|
211
samples/client/petstore/R/R/date.R
Normal file
211
samples/client/petstore/R/R/date.R
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
#' Create a new Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' to test the model name `Date`
|
||||||
|
#'
|
||||||
|
#' @docType class
|
||||||
|
#' @title Date
|
||||||
|
#' @description Date Class
|
||||||
|
#' @format An \code{R6Class} generator object
|
||||||
|
#' @field className character
|
||||||
|
#' @field _field_list a list of fields list(character)
|
||||||
|
#' @field additional_properties additional properties list(character) [optional]
|
||||||
|
#' @importFrom R6 R6Class
|
||||||
|
#' @importFrom jsonlite fromJSON toJSON
|
||||||
|
#' @export
|
||||||
|
Date <- R6::R6Class(
|
||||||
|
"Date",
|
||||||
|
public = list(
|
||||||
|
`className` = NULL,
|
||||||
|
`_field_list` = c("className"),
|
||||||
|
`additional_properties` = list(),
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Initialize a new Date class.
|
||||||
|
#'
|
||||||
|
#' @param className className
|
||||||
|
#' @param additional_properties additonal properties (optional)
|
||||||
|
#' @param ... Other optional arguments.
|
||||||
|
#' @export
|
||||||
|
initialize = function(
|
||||||
|
`className`, additional_properties = NULL, ...
|
||||||
|
) {
|
||||||
|
if (!missing(`className`)) {
|
||||||
|
stopifnot(is.character(`className`), length(`className`) == 1)
|
||||||
|
self$`className` <- `className`
|
||||||
|
}
|
||||||
|
if (!is.null(additional_properties)) {
|
||||||
|
for (key in names(additional_properties)) {
|
||||||
|
self$additional_properties[[key]] <- additional_properties[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSON = function() {
|
||||||
|
DateObject <- list()
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
DateObject[["className"]] <-
|
||||||
|
self$`className`
|
||||||
|
}
|
||||||
|
for (key in names(self$additional_properties)) {
|
||||||
|
DateObject[[key]] <- self$additional_properties[[key]]
|
||||||
|
}
|
||||||
|
|
||||||
|
DateObject
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSON = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
if (!is.null(this_object$`className`)) {
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
}
|
||||||
|
# process additional properties/fields in the payload
|
||||||
|
for (key in names(this_object)) {
|
||||||
|
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
|
||||||
|
self$additional_properties[[key]] <- this_object[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' To JSON string
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To JSON String
|
||||||
|
#'
|
||||||
|
#' @return Date in JSON format
|
||||||
|
#' @export
|
||||||
|
toJSONString = function() {
|
||||||
|
jsoncontent <- c(
|
||||||
|
if (!is.null(self$`className`)) {
|
||||||
|
sprintf(
|
||||||
|
'"className":
|
||||||
|
"%s"
|
||||||
|
',
|
||||||
|
self$`className`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
jsoncontent <- paste(jsoncontent, collapse = ",")
|
||||||
|
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
|
||||||
|
json_obj <- jsonlite::fromJSON(json_string)
|
||||||
|
for (key in names(self$additional_properties)) {
|
||||||
|
json_obj[[key]] <- self$additional_properties[[key]]
|
||||||
|
}
|
||||||
|
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
|
||||||
|
},
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Deserialize JSON string into an instance of Date
|
||||||
|
#'
|
||||||
|
#' @param input_json the JSON input
|
||||||
|
#' @return the instance of Date
|
||||||
|
#' @export
|
||||||
|
fromJSONString = function(input_json) {
|
||||||
|
this_object <- jsonlite::fromJSON(input_json)
|
||||||
|
self$`className` <- this_object$`className`
|
||||||
|
# process additional properties/fields in the payload
|
||||||
|
for (key in names(this_object)) {
|
||||||
|
if (!(key %in% self$`_field_list`)) { # json key not in list of fields
|
||||||
|
self$additional_properties[[key]] <- this_object[[key]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self
|
||||||
|
},
|
||||||
|
#' Validate JSON input with respect to Date
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Validate JSON input with respect to Date 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 Date: the required field `className` is missing."))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' To string (JSON format)
|
||||||
|
#'
|
||||||
|
#' @return String representation of Date
|
||||||
|
#' @export
|
||||||
|
toString = function() {
|
||||||
|
self$toJSONString()
|
||||||
|
},
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return true if the values in all fields are valid.
|
||||||
|
#'
|
||||||
|
#' @return true if the values in all fields are valid.
|
||||||
|
#' @export
|
||||||
|
isValid = function() {
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
return(FALSE)
|
||||||
|
}
|
||||||
|
|
||||||
|
TRUE
|
||||||
|
},
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Return a list of invalid fields (if any).
|
||||||
|
#'
|
||||||
|
#' @return A list of invalid fields (if any).
|
||||||
|
#' @export
|
||||||
|
getInvalidFields = function() {
|
||||||
|
invalid_fields <- list()
|
||||||
|
# check if the required `className` is null
|
||||||
|
if (is.null(self$`className`)) {
|
||||||
|
invalid_fields["className"] <- "Non-nullable required field `className` cannot be null."
|
||||||
|
}
|
||||||
|
|
||||||
|
invalid_fields
|
||||||
|
},
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @description
|
||||||
|
#' Print the object
|
||||||
|
#'
|
||||||
|
#' @export
|
||||||
|
print = function() {
|
||||||
|
print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
invisible(self)
|
||||||
|
}),
|
||||||
|
# Lock the class to prevent modifications to the method or field
|
||||||
|
lock_class = TRUE
|
||||||
|
)
|
||||||
|
## Uncomment below to unlock the class to allow modifications of the method or field
|
||||||
|
#Date$unlock()
|
||||||
|
#
|
||||||
|
## Below is an example to define the print fnuction
|
||||||
|
#Date$set("public", "print", function(...) {
|
||||||
|
# print(jsonlite::prettify(self$toJSONString()))
|
||||||
|
# invisible(self)
|
||||||
|
#})
|
||||||
|
## Uncomment below to lock the class to prevent modifications to the method or field
|
||||||
|
#Date$lock()
|
||||||
|
|
@ -98,6 +98,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [CatAllOf](docs/CatAllOf.md)
|
- [CatAllOf](docs/CatAllOf.md)
|
||||||
- [Category](docs/Category.md)
|
- [Category](docs/Category.md)
|
||||||
- [DanishPig](docs/DanishPig.md)
|
- [DanishPig](docs/DanishPig.md)
|
||||||
|
- [Date](docs/Date.md)
|
||||||
- [Dog](docs/Dog.md)
|
- [Dog](docs/Dog.md)
|
||||||
- [DogAllOf](docs/DogAllOf.md)
|
- [DogAllOf](docs/DogAllOf.md)
|
||||||
- [Mammal](docs/Mammal.md)
|
- [Mammal](docs/Mammal.md)
|
||||||
|
10
samples/client/petstore/R/docs/Date.md
Normal file
10
samples/client/petstore/R/docs/Date.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# petstore::Date
|
||||||
|
|
||||||
|
to test the model name `Date`
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**className** | **character** | |
|
||||||
|
|
||||||
|
|
13
samples/client/petstore/R/tests/testthat/test_date.R
Normal file
13
samples/client/petstore/R/tests/testthat/test_date.R
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
||||||
|
# Please update as you see appropriate
|
||||||
|
|
||||||
|
context("Test Date")
|
||||||
|
|
||||||
|
model_instance <- Date$new()
|
||||||
|
|
||||||
|
test_that("className", {
|
||||||
|
# tests for the property `className` (character)
|
||||||
|
|
||||||
|
# uncomment below to test the property
|
||||||
|
#expect_equal(model.instance$`className`, "EXPECTED_RESULT")
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user