forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swagger-api#3506 from wing328/fix_array_enum
[JaxRS][PHP] Fix issue with enum
- Loading branch information
Showing
69 changed files
with
3,963 additions
and
231 deletions.
There are no files selected for viewing
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
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
32 changes: 24 additions & 8 deletions
32
modules/swagger-codegen/src/main/resources/JavaJaxRS/enumClass.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 |
---|---|---|
@@ -1,17 +1,33 @@ | ||
/** | ||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} | ||
*/ | ||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { | ||
{{#gson}} | ||
{{#allowableValues}} | ||
{{#enumVars}} | ||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) | ||
{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{#-last}};{{/-last}} | ||
{{/enumVars}} | ||
{{/allowableValues}} | ||
{{/gson}} | ||
{{^gson}} | ||
{{#allowableValues}} | ||
{{#enumVars}} | ||
{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{#-last}};{{/-last}} | ||
{{/enumVars}} | ||
{{/allowableValues}} | ||
{{/gson}} | ||
|
||
public enum {{{datatypeWithEnum}}} { | ||
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
private {{{datatype}}} value; | ||
|
||
private String value; | ||
|
||
{{{datatypeWithEnum}}}(String value) { | ||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return value; | ||
return String.valueOf(value); | ||
} | ||
} |
30 changes: 27 additions & 3 deletions
30
modules/swagger-codegen/src/main/resources/JavaJaxRS/enumOuterClass.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 |
---|---|---|
@@ -1,3 +1,27 @@ | ||
public enum {{classname}} { | ||
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}} | ||
} | ||
/** | ||
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} | ||
*/ | ||
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { | ||
{{#gson}} | ||
{{#allowableValues}}{{#enumVars}} | ||
@SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) | ||
{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
{{/gson}} | ||
{{^gson}} | ||
{{#allowableValues}}{{#enumVars}} | ||
{{{name}}}({{{value}}}){{^-last}}, | ||
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} | ||
{{/gson}} | ||
|
||
private {{{dataType}}} value; | ||
|
||
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
} |
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
Oops, something went wrong.