Merge pull request #1471 from wing328/invalid_array_type

Better error handling for invalid array/map type
This commit is contained in:
wing328 2015-11-03 21:46:24 +08:00
commit 1b538f6eaf
26 changed files with 1674 additions and 729 deletions

View File

@ -814,6 +814,7 @@ public class DefaultCodegen {
LOGGER.error("unexpected missing property for name " + name);
return null;
}
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.name = toVarName(name);
@ -1908,6 +1909,12 @@ public class DefaultCodegen {
// encountered so far and hopefully make it easier for others to add more special
// cases in the future.
// better error handling when map/array type is invalid
if (name == null) {
LOGGER.error("String to be sanitized is null. Default to ERROR_UNKNOWN");
return "ERROR_UNKNOWN";
}
// input[] => input
name = name.replaceAll("\\[\\]", "");

View File

@ -6,11 +6,7 @@
<packaging>jar</packaging>
<name>swagger-java-client</name>
<version>1.0.0</version>
<scm>
<connection>scm:git:git@github.com:swagger-api/swagger-mustache.git</connection>
<developerConnection>scm:git:git@github.com:swagger-api/swagger-codegen.git</developerConnection>
<url>https://github.com/swagger-api/swagger-codegen</url>
</scm>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>

View File

@ -3,7 +3,7 @@ package io.swagger.client;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();

View File

@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*;
import java.io.IOException;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class JSON {
private ObjectMapper mapper;

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Pair {
private String name = "";
private String value = "";

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -3,7 +3,7 @@ package io.swagger.client;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class TypeRef<T> {
private final Type type;

View File

@ -11,7 +11,7 @@ import java.io.File;
import java.util.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class PetApi {
private ApiClient apiClient;

View File

@ -11,7 +11,7 @@ import io.swagger.client.model.Order;
import java.util.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class StoreApi {
private ApiClient apiClient;

View File

@ -11,7 +11,7 @@ import java.util.*;
import java.util.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class UserApi {
private ApiClient apiClient;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public interface Authentication {
/** Apply authentication settings to header and query params. */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.io.UnsupportedEncodingException;
import javax.xml.bind.DatatypeConverter;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class HttpBasicAuth implements Authentication {
private String username;
private String password;

View File

@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Category {
private Long id = null;

View File

@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Order {
private Long id = null;

View File

@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Pet {
private Long id = null;

View File

@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class Tag {
private Long id = null;

View File

@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00")
public class User {
private Long id = null;

View File

@ -100,6 +100,10 @@
float: left;
}
.param-enum {
margin-left: 20px;
}
.section-header {
border-bottom: 2px;
font-weight: bold;

View File

@ -4,12 +4,14 @@
<ul class="parameter">
<li class="param-required-">id : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">name : String
<br/>
</li>
</ul>

View File

@ -4,36 +4,54 @@
<ul class="parameter">
<li class="param-required-">id : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">petId : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">quantity : Integer
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">shipDate : Date
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">status : String
<br/>Order Status
<dl class="param-enum">
<dt>Enum:
<dd>placed</dd>
<dd>approved</dd>
<dd>delivered</dd>
</dt>
</dl>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">complete : Boolean
<br/>
</li>
</ul>

View File

@ -4,36 +4,54 @@
<ul class="parameter">
<li class="param-required-">id : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">category : Category
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-true">name : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-true">photoUrls : List
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">tags : List
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">status : String
<br/>pet status in the store
<dl class="param-enum">
<dt>Enum:
<dd>available</dd>
<dd>pending</dd>
<dd>sold</dd>
</dt>
</dl>
</li>
</ul>

View File

@ -4,12 +4,14 @@
<ul class="parameter">
<li class="param-required-">id : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">name : String
<br/>
</li>
</ul>

View File

@ -4,48 +4,56 @@
<ul class="parameter">
<li class="param-required-">id : Long
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">username : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">firstName : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">lastName : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">email : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">password : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">phone : String
<br/>
</li>
</ul>
<ul class="parameter">
<li class="param-required-">userStatus : Integer
<br/>User Status
</li>
</ul>

File diff suppressed because it is too large Load Diff