Skip to content

Commit

Permalink
jaxrs-cxf-cdi: fix outer enum (#131)
Browse files Browse the repository at this point in the history
* jaxrs-cxf-cdi: fix model enum

* Fix script 'bin/jaxrs-cxf-cdi-petstore-server.sh'

See #124

* Run 'bin/jaxrs-cxf-cdi-petstore-server.sh'
  • Loading branch information
jmini authored and jimschubert committed May 22, 2018
1 parent 8df3e54 commit b73ab02
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/jaxrs-cxf-cdi-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
="generate -t modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf-cdi -o samples/server/petstore/jaxrs-cxf-cdi -DhideGenerationTimestamp=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf-cdi -o samples/server/petstore/jaxrs-cxf-cdi -DhideGenerationTimestamp=true $@"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@XmlType(name="{{datatypeWithEnum}}")
@XmlEnum({{dataType}}.class)
public enum {{datatypeWithEnum}} {
public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}@XmlEnumValue({{{value}}}) {{name}}({{dataType}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
Expand All @@ -9,7 +9,7 @@ public enum {{datatypeWithEnum}} {

private {{dataType}} value;

{{datatypeWithEnum}} ({{dataType}} v) {
{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{dataType}} v) {
value = v;
}

Expand All @@ -22,7 +22,7 @@ public enum {{datatypeWithEnum}} {
return String.valueOf(value);
}

public static {{datatypeWithEnum}} fromValue(String v) {
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String v) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(v)) {
return b;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;

{{>enumClass}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.validation.constraints.*;
/**
* {{description}}
**/{{/description}}
{{#isEnum}}{{>enumClass}}{{/isEnum}}
{{#isEnum}}{{>enumOuterClass}}{{/isEnum}}
{{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}}
{{/models}}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum StatusEnum {

private String value;

StatusEnum (String v) {
StatusEnum(String v) {
value = v;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum StatusEnum {

private String value;

StatusEnum (String v) {
StatusEnum(String v) {
value = v;
}

Expand Down

0 comments on commit b73ab02

Please # to comment.