forked from loafle/openapi-generator-original
Merge branch 'issues/91' of git://github.com/RobBlairInq/swagger-codegen into RobBlairInq-issues/91
This commit is contained in:
commit
7f35b875a4
@ -12,6 +12,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
|
||||
import com.sun.jersey.api.client.filter.LoggingFilter;
|
||||
import com.sun.jersey.api.client.WebResource.Builder;
|
||||
|
||||
import javax.ws.rs.core.Response.Status.Family;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import java.util.Map;
|
||||
@ -123,7 +124,7 @@ public class ApiInvoker {
|
||||
else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
if(response.getClientResponseStatus() == ClientResponse.Status.OK) {
|
||||
if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||
return (String) response.getEntity(String.class);
|
||||
}
|
||||
else {
|
||||
|
@ -10,6 +10,7 @@ public class Order {
|
||||
private Integer quantity = null;
|
||||
/* Status of the order */
|
||||
private String status = null;
|
||||
//public enum statusEnum { placed, approved, delivered, };
|
||||
/* Date shipped, only if it has been */
|
||||
private Date shipDate = null;
|
||||
public Long getId() {
|
||||
|
@ -16,6 +16,7 @@ public class Pet {
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
/* pet status in the store */
|
||||
private String status = null;
|
||||
//public enum statusEnum { available, pending, sold, };
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class User {
|
||||
private String phone = null;
|
||||
/* User Status */
|
||||
private Integer userStatus = null;
|
||||
//public enum userStatusEnum { 1-registered, 2-active, 3-closed, };
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -10,6 +10,12 @@ public class {{classname}} {
|
||||
{{#description}}/* {{{description}}} */
|
||||
{{/description}}
|
||||
private {{{datatype}}} {{name}} = {{{defaultValue}}};
|
||||
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}
|
||||
{{/min}}
|
||||
//{{^min}}public enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };
|
||||
{{/min}}
|
||||
{{/allowableValues}}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
|
@ -188,6 +188,19 @@ class Codegen(config: CodegenConfig) {
|
||||
(srcName, engine -> template)
|
||||
}
|
||||
|
||||
def rawAllowableValuesToString(v: AllowableValues) = {
|
||||
v match {
|
||||
case av: AllowableListValues => {
|
||||
av
|
||||
}
|
||||
case av: AllowableRangeValues => {
|
||||
av
|
||||
}
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def allowableValuesToString(v: AllowableValues) = {
|
||||
v match {
|
||||
case av: AllowableListValues => {
|
||||
@ -306,6 +319,11 @@ class Codegen(config: CodegenConfig) {
|
||||
case _ => requiredParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||
}
|
||||
|
||||
headerParams.size match {
|
||||
case 0 =>
|
||||
case _ => headerParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||
}
|
||||
|
||||
queryParams.size match {
|
||||
case 0 =>
|
||||
case _ => queryParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||
@ -466,6 +484,7 @@ class Codegen(config: CodegenConfig) {
|
||||
"defaultValue" -> config.toDeclaration(propertyDocSchema)._2,
|
||||
"description" -> propertyDocSchema.description,
|
||||
"notes" -> propertyDocSchema.description,
|
||||
"allowableValues" -> rawAllowableValuesToString(propertyDocSchema.allowableValues),
|
||||
(if(propertyDocSchema.required) "required" else "isNotRequired") -> "true",
|
||||
"getter" -> config.toGetter(prop._1, config.toDeclaration(propertyDocSchema)._1),
|
||||
"setter" -> config.toSetter(prop._1, config.toDeclaration(propertyDocSchema)._1),
|
||||
|
@ -347,10 +347,16 @@ object SwaggerSerializers {
|
||||
else {
|
||||
val min = (json \ "min") match {
|
||||
case e: JObject => e.extract[String]
|
||||
case e: JString => e.s
|
||||
case e: JInt => e.num.toString
|
||||
case e: JDouble => e.num.toString
|
||||
case _ => ""
|
||||
}
|
||||
val max = (json \ "max") match {
|
||||
case e: JObject => e.extract[String]
|
||||
case e: JString => e.s
|
||||
case e: JInt => e.num.toString
|
||||
case e: JDouble => e.num.toString
|
||||
case _ => ""
|
||||
}
|
||||
if(min != "" && max != "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user