-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[groovy] support enum generation in groovy client (#15619)
* support generation of enums for groovy * add custom json generator for groovy * add nestet enums in groovy templates * add indent for nested Groovy enums & fix compilation errors in Groovy ApiUtils * save auto generated samples&docs for groovy
- Loading branch information
1 parent
358397f
commit 5b5cb1f
Showing
7 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
modules/openapi-generator/src/main/resources/Groovy/ApiUtils.mustache
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
21 changes: 21 additions & 0 deletions
21
modules/openapi-generator/src/main/resources/Groovy/modelClass.mustache
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,21 @@ | ||
@Canonical | ||
class {{classname}} { | ||
{{#vars}} | ||
{{#isEnum}} | ||
|
||
{{^isContainer}} | ||
{{#lambda.indented}} | ||
{{>modelEnum}}{{/lambda.indented}} | ||
{{/isContainer}} | ||
{{#isContainer}} | ||
{{#mostInnerItems}} | ||
{{#lambda.indented}} | ||
{{>modelEnum}}{{/lambda.indented}} | ||
{{/mostInnerItems}} | ||
{{/isContainer}} | ||
|
||
{{/isEnum}} | ||
{{#description}}/* {{{.}}} */{{/description}} | ||
{{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}} | ||
{{/vars}} | ||
} |
25 changes: 25 additions & 0 deletions
25
modules/openapi-generator/src/main/resources/Groovy/modelEnum.mustache
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,25 @@ | ||
enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { | ||
{{#allowableValues}}{{#enumVars}} | ||
{{#enumDescription}} | ||
/** | ||
* {{.}} | ||
*/ | ||
{{/enumDescription}} | ||
{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
|
||
private final {{{dataType}}} value | ||
|
||
{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { | ||
this.value = value | ||
} | ||
|
||
{{{dataType}}} getValue() { | ||
value | ||
} | ||
|
||
@Override | ||
String toString() { | ||
String.valueOf(value) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/ApiUtils.groovy
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