Skip to content

Commit

Permalink
Merge pull request HamaWhiteGG#126 from HamaWhiteGG/dev
Browse files Browse the repository at this point in the history
[Improvement] Ignore unknown fields by default for PineconeClient HamaWhiteGG#122
  • Loading branch information
HamaWhiteGG authored Oct 12, 2023
2 parents f5d143d + fa3658d commit 5dbfacf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pinecone-client/src/main/java/com/hw/pinecone/PineconeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.hw.pinecone;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hw.pinecone.entity.index.CreateIndexRequest;
import com.hw.pinecone.entity.index.IndexDescription;
Expand Down Expand Up @@ -127,8 +128,7 @@ public Retrofit createRetrofit(String baseUrl) {
httpClient = httpClientBuilder.build();

// Used for automatic discovery and registration of Jackson modules
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();
ObjectMapper objectMapper = defaultObjectMapper();

return new Retrofit.Builder()
.baseUrl(baseUrl)
Expand All @@ -138,6 +138,15 @@ public Retrofit createRetrofit(String baseUrl) {
.build();
}

public static ObjectMapper defaultObjectMapper() {
// Used for automatic discovery and registration of Jackson modules
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();
// Ignore unknown fields
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}

/**
* Closes the HttpClient connection pool.
*/
Expand Down

0 comments on commit 5dbfacf

Please sign in to comment.