Last active
June 15, 2021 18:46
-
-
Save ahjota/e0451393cf469a2aef06350db7ee29be to your computer and use it in GitHub Desktop.
OpenAPI-generated R client with errors related to self as a model property name
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
# R reserved words bug example | |
# | |
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |
# | |
# The version of the OpenAPI document: 0.0.1 | |
# | |
# Generated by: https://openapi-generator.tech | |
#' @docType class | |
#' @title MyObject | |
#' | |
#' @description MyObject Class | |
#' | |
#' @format An \code{R6Class} generator object | |
#' | |
#' @field self character [optional] | |
#' | |
#' @importFrom R6 R6Class | |
#' @importFrom jsonlite fromJSON toJSON | |
#' @export | |
MyObject <- R6::R6Class( | |
'MyObject', | |
public = list( | |
`self` = NULL, | |
initialize = function( | |
`self`=NULL, ... | |
) { | |
local.optional.var <- list(...) | |
if (!is.null(`self`)) { | |
stopifnot(is.character(`self`), length(`self`) == 1) | |
self$`self` <- `self` | |
} | |
}, | |
toJSON = function() { | |
MyObjectObject <- list() | |
if (!is.null(self$`self`)) { | |
MyObjectObject[['self']] <- | |
self$`self` | |
} | |
MyObjectObject | |
}, | |
fromJSON = function(MyObjectJson) { | |
MyObjectObject <- jsonlite::fromJSON(MyObjectJson) | |
if (!is.null(MyObjectObject$`self`)) { | |
self$`self` <- MyObjectObject$`self` | |
} | |
self | |
}, | |
toJSONString = function() { | |
jsoncontent <- c( | |
if (!is.null(self$`self`)) { | |
sprintf( | |
'"self": | |
"%s" | |
', | |
self$`self` | |
)} | |
) | |
jsoncontent <- paste(jsoncontent, collapse = ",") | |
paste('{', jsoncontent, '}', sep = "") | |
}, | |
fromJSONString = function(MyObjectJson) { | |
MyObjectObject <- jsonlite::fromJSON(MyObjectJson) | |
self$`self` <- MyObjectObject$`self` | |
self | |
} | |
) | |
) | |
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
# R reserved words bug example | |
# | |
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |
# | |
# The version of the OpenAPI document: 0.0.1 | |
# | |
# Generated by: https://openapi-generator.tech | |
#' @docType class | |
#' @title MyObject | |
#' | |
#' @description MyObject Class | |
#' | |
#' @format An \code{R6Class} generator object | |
#' | |
#' @field self_ character [optional] | |
#' | |
#' @importFrom R6 R6Class | |
#' @importFrom jsonlite fromJSON toJSON | |
#' @export | |
MyObject <- R6::R6Class( | |
'MyObject', | |
public = list( | |
`self_` = NULL, | |
initialize = function( | |
`self_`=NULL, ... | |
) { | |
local.optional.var <- list(...) | |
if (!is.null(`self_`)) { | |
stopifnot(is.character(`self_`), length(`self_`) == 1) | |
self$`self_` <- `self_` | |
} | |
}, | |
toJSON = function() { | |
MyObjectObject <- list() | |
if (!is.null(self$`self_`)) { | |
MyObjectObject[['self']] <- | |
self$`self_` | |
} | |
MyObjectObject | |
}, | |
fromJSON = function(MyObjectJson) { | |
MyObjectObject <- jsonlite::fromJSON(MyObjectJson) | |
if (!is.null(MyObjectObject$`self`)) { | |
self$`self_` <- MyObjectObject$`self` | |
} | |
self | |
}, | |
toJSONString = function() { | |
jsoncontent <- c( | |
if (!is.null(self$`self_`)) { | |
sprintf( | |
'"self": | |
"%s" | |
', | |
self$`self_` | |
)} | |
) | |
jsoncontent <- paste(jsoncontent, collapse = ",") | |
paste('{', jsoncontent, '}', sep = "") | |
}, | |
fromJSONString = function(MyObjectJson) { | |
MyObjectObject <- jsonlite::fromJSON(MyObjectJson) | |
self$`self_` <- MyObjectObject$`self` | |
self | |
} | |
) | |
) | |
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
openapi: 3.0.3 | |
info: | |
title: R reserved words bug example | |
version: 0.0.1 | |
paths: | |
/example: | |
post: | |
requestBody: | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/MyObject' | |
responses: | |
'200': | |
description: OK | |
components: | |
schemas: | |
MyObject: | |
properties: | |
self: | |
type: string | |
type: object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment