Skip to content

Commit

Permalink
Add objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false) for Pin…
Browse files Browse the repository at this point in the history
…econeClient to ignore unknown fields by default HamaWhiteGG#122
  • Loading branch information
HamaWhiteGG committed Oct 12, 2023
1 parent aabde92 commit fa3658d
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 fa3658d

Please sign in to comment.