-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[R] Enum R6Class Support, closes #3367 #5728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
ff87d33
wip: fix documentation tags
34350d7
update model.mustache
e9bfd30
Merge branch 'master' of github.com:LiNk-NY/openapi-generator
LiNk-NY 0ec4e22
update template for documentation
LiNk-NY 794306c
update mustache templates
LiNk-NY 7270127
Merge branch 'master' of github.com:OpenApiTools/openapi-generator
ab7daee
Merge branch 'master' of github.com:LiNk-NY/openapi-generator
95e9a9f
update mustache templates
456ac6a
run ./bin/r-petstore and update R pkg docs
0cb7abd
use loadNamespace instead of package:pkgName string
LiNk-NY 5958c01
update R package code
LiNk-NY d4d68ff
Merge branch 'master' of github.com:OpenApiTools/openapi-generator
c43852f
Merge branch 'master' of github.com:OpenApiTools/openapi-generator
92e470a
Merge branch 'master' of github.com:LiNk-NY/openapi-generator
7528003
wip: enum
5d7e410
update enum function
231f03f
use httr::content to unwrap response
011ab95
Merge branch 'master' of github.com:OpenAPItools/openapi-generator
LiNk-NY b575f07
Merge branch 'master' of github.com:LiNk-NY/openapi-generator
LiNk-NY e576586
Merge branch 'master' of github.com:LiNk-NY/openapi-generator
LiNk-NY d859042
Merge branch 'enum' of github.com:LiNk-NY/openapi-generator into enum
LiNk-NY 8d78c2f
update enum table and functions
LiNk-NY 9d178a1
include simplifyVector and auto_unbox arguments
LiNk-NY c5a445d
remove mapping and return strings
4ff8abd
Merge remote-tracking branch 'origin/master' into enum
LiNk-NY c419f8c
use triple stash values and update enum class methods
LiNk-NY 595b7ba
remove extra comma
LiNk-NY 90c0dd5
minor: formatting
LiNk-NY 06baee6
Merge remote-tracking branch 'origin/master' into enum
LiNk-NY de05d02
Merge remote-tracking branch 'origin/master' into enum
LiNk-NY 7eec6f6
update and run ./bin/r-petstore.sh
LiNk-NY 168baa7
Merge branch 'master' of https://github.com/openapitools/openapi-gene…
wing328 0580ea7
move helper for template
LiNk-NY b6314c8
update tests based on generator
LiNk-NY 424a97b
Revert "update tests based on generator"
LiNk-NY c703965
Update tests with engine
LiNk-NY 867eced
restore apiResponse
LiNk-NY dafb94f
restore simplifyVector to TRUE value
LiNk-NY 8852f5b
update api.mustache templates
LiNk-NY 5183ecf
fix and add tests to package
LiNk-NY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
48 changes: 48 additions & 0 deletions
48
modules/openapi-generator/src/main/resources/r/modelEnum.mustache
This file contains hidden or 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,48 @@ | ||
| #' @export | ||
| {{#allowableValues}} | ||
| {{classname}} <- R6::R6Class( | ||
| "{{classname}}", | ||
| public = list( | ||
| initialize = function(...) { | ||
| local.optional.var <- list(...) | ||
| val <- unlist(local.optional.var) | ||
| enumvec <- .parse_{{name}}() | ||
|
|
||
| stopifnot(length(val) == 1L) | ||
|
|
||
| if (!val %in% enumvec) | ||
| stop("Use one of the valid values: ", | ||
| paste0(enumvec, collapse = ", ")) | ||
| private$value <- val | ||
| }, | ||
| toJSON = function() { | ||
| jsonlite::toJSON(private$value, auto_unbox = TRUE) | ||
| }, | ||
| fromJSON = function({{classname}}Json) { | ||
| private$value <- jsonlite::fromJSON({{classname}}Json, | ||
| simplifyVector = FALSE) | ||
| self | ||
| }, | ||
| toJSONString = function() { | ||
| as.character(jsonlite::toJSON(private$value, | ||
| auto_unbox = TRUE)) | ||
| }, | ||
| fromJSONString = function({{classname}}Json) { | ||
| private$value <- jsonlite::fromJSON({{classname}}Json, | ||
| simplifyVector = FALSE) | ||
| self | ||
| } | ||
| ), | ||
| private = list( | ||
| value = NULL | ||
| ) | ||
| ) | ||
|
|
||
| # add to utils.R | ||
| .parse_{{name}} <- function(vals) { | ||
| res <- gsub("^\\[|\\]$", "", | ||
| "{{{values}}}" | ||
| ) | ||
| unlist(strsplit(res, ", ")) | ||
| } | ||
| {{/allowableValues}} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.