Fixing broken enumeration swagger/json types for JaxRS-CXF templates.

This commit is contained in:
oskar 2016-04-06 21:51:17 +02:00
parent c624311cab
commit d45d36d8a2
3 changed files with 23 additions and 11 deletions

View File

@ -3,6 +3,10 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;

View File

@ -1,16 +1,23 @@
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
@XmlType(name="{{classname}}")
@XmlType(name="{{datatypeWithEnum}}")
@XmlEnum
public enum {{classname}} {
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/allowableValues}}
public String value() {
return name();
public enum {{datatypeWithEnum}} {
{{#allowableValues}}
{{#enumVars}}{{name}}({{datatype}}.valueOf("{{value}}")){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}
{{/allowableValues}}
private {{datatype}} value;
{{datatypeWithEnum}} ({{datatype}} v) {
value = v;
}
public static {{classname}} fromValue(String v) {
public String value() {
return value;
}
public static {{datatypeWithEnum}} fromValue(String v) {
return valueOf(v);
}
}

View File

@ -3,9 +3,10 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
{{#hasVars}} @XmlType(name = "{{classn,ame}}", propOrder =
{{#hasVars}} @XmlType(name = "{{classname}}", propOrder =
{ {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}}
}){{/hasVars}}
{{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}}