forked from loafle/openapi-generator-original
Ignore null fields in model serialization
in Java clients. Closes #1413
This commit is contained in:
parent
7f5cdba606
commit
214e0186e8
@ -12,12 +12,13 @@ public class JSON {
|
|||||||
|
|
||||||
public JSON() {
|
public JSON() {
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize the given Java object into JSON string.
|
* Serialize the given Java object into JSON string.
|
||||||
|
@ -23,10 +23,9 @@ public class JSON {
|
|||||||
public JSON(ApiClient apiClient) {
|
public JSON(ApiClient apiClient) {
|
||||||
this.apiClient = apiClient;
|
this.apiClient = apiClient;
|
||||||
gson = new GsonBuilder()
|
gson = new GsonBuilder()
|
||||||
.serializeNulls()
|
|
||||||
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
|
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gson getGson() {
|
public Gson getGson() {
|
||||||
return gson;
|
return gson;
|
||||||
|
@ -6,18 +6,19 @@ import com.fasterxml.jackson.datatype.joda.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@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-21T11:55:29.717+08:00")
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
public JSON() {
|
public JSON() {
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize the given Java object into JSON string.
|
* Serialize the given Java object into JSON string.
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@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-21T11:55:29.717+08:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
@ -272,7 +266,7 @@ public class PetApi {
|
|||||||
};
|
};
|
||||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
String[] authNames = new String[] { "api_key" };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import io.swagger.client.model.Order;
|
import io.swagger.client.model.Order;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@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-21T11:55:29.717+08:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.User;
|
import io.swagger.client.model.User;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@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-21T11:55:29.717+08:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -6,18 +6,19 @@ import com.fasterxml.jackson.datatype.joda.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:29:47.599-07:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:20.020+08:00")
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
public JSON() {
|
public JSON() {
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize the given Java object into JSON string.
|
* Serialize the given Java object into JSON string.
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:29:47.599-07:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:20.020+08:00")
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
@ -243,7 +237,7 @@ public class PetApi {
|
|||||||
};
|
};
|
||||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
String[] authNames = new String[] { "api_key" };
|
||||||
|
|
||||||
|
|
||||||
TypeRef returnType = new TypeRef<Pet>() {};
|
TypeRef returnType = new TypeRef<Pet>() {};
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import io.swagger.client.model.Order;
|
import io.swagger.client.model.Order;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:29:47.599-07:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:20.020+08:00")
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -6,18 +6,12 @@ import io.swagger.client.Configuration;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
import io.swagger.client.TypeRef;
|
import io.swagger.client.TypeRef;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.User;
|
import io.swagger.client.model.User;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:29:47.599-07:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:20.020+08:00")
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
|
||||||
|
@ -23,10 +23,9 @@ public class JSON {
|
|||||||
public JSON(ApiClient apiClient) {
|
public JSON(ApiClient apiClient) {
|
||||||
this.apiClient = apiClient;
|
this.apiClient = apiClient;
|
||||||
gson = new GsonBuilder()
|
gson = new GsonBuilder()
|
||||||
.serializeNulls()
|
|
||||||
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
|
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gson getGson() {
|
public Gson getGson() {
|
||||||
return gson;
|
return gson;
|
||||||
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
|||||||
import io.swagger.client.Configuration;
|
import io.swagger.client.Configuration;
|
||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import com.squareup.okhttp.Call;
|
import com.squareup.okhttp.Call;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import java.io.File;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class PetApi {
|
public class PetApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
@ -297,7 +290,7 @@ public class PetApi {
|
|||||||
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
final String contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
headerParams.put("Content-Type", contentType);
|
headerParams.put("Content-Type", contentType);
|
||||||
|
|
||||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
String[] authNames = new String[] { "api_key" };
|
||||||
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
|||||||
import io.swagger.client.Configuration;
|
import io.swagger.client.Configuration;
|
||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import com.squareup.okhttp.Call;
|
import com.squareup.okhttp.Call;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import io.swagger.client.model.Order;
|
import io.swagger.client.model.Order;
|
||||||
|
|
||||||
import java.io.File;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class StoreApi {
|
public class StoreApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
@ -6,22 +6,15 @@ import io.swagger.client.ApiException;
|
|||||||
import io.swagger.client.Configuration;
|
import io.swagger.client.Configuration;
|
||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
import io.swagger.client.model.*;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import com.squareup.okhttp.Call;
|
import com.squareup.okhttp.Call;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import io.swagger.client.model.User;
|
import io.swagger.client.model.User;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class UserApi {
|
public class UserApi {
|
||||||
private ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user