Skip to content

Commit 9397d8c

Browse files
fix(specs): add secrets payload for updates (generated)
algolia/api-clients-automation#4061 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 5771148 commit 9397d8c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

algoliasearch/src/main/java/com/algolia/model/ingestion/AuthInputPartial.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,44 @@
66
import com.algolia.exceptions.AlgoliaRuntimeException;
77
import com.fasterxml.jackson.annotation.*;
88
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.type.TypeReference;
910
import com.fasterxml.jackson.databind.*;
1011
import com.fasterxml.jackson.databind.annotation.*;
1112
import java.io.IOException;
13+
import java.util.Map;
1214
import java.util.logging.Logger;
1315

1416
/** AuthInputPartial */
1517
@JsonDeserialize(using = AuthInputPartial.Deserializer.class)
1618
public interface AuthInputPartial {
19+
// AuthInputPartial as Map<String, String> wrapper.
20+
static AuthInputPartial of(Map<String, String> value) {
21+
return new MapOfStringStringWrapper(value);
22+
}
23+
24+
// AuthInputPartial as Map<String, String> wrapper.
25+
@JsonSerialize(using = MapOfStringStringWrapper.Serializer.class)
26+
class MapOfStringStringWrapper implements AuthInputPartial {
27+
28+
private final Map<String, String> value;
29+
30+
MapOfStringStringWrapper(Map<String, String> value) {
31+
this.value = value;
32+
}
33+
34+
public Map<String, String> getValue() {
35+
return value;
36+
}
37+
38+
static class Serializer extends JsonSerializer<MapOfStringStringWrapper> {
39+
40+
@Override
41+
public void serialize(MapOfStringStringWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
42+
gen.writeObject(value.getValue());
43+
}
44+
}
45+
}
46+
1747
class Deserializer extends JsonDeserializer<AuthInputPartial> {
1848

1949
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
@@ -81,6 +111,16 @@ public AuthInputPartial deserialize(JsonParser jp, DeserializationContext ctxt)
81111
);
82112
}
83113
}
114+
// deserialize Map<String, String>
115+
if (tree.isObject()) {
116+
try (JsonParser parser = tree.traverse(jp.getCodec())) {
117+
Map<String, String> value = parser.readValueAs(new TypeReference<Map<String, String>>() {});
118+
return new AuthInputPartial.MapOfStringStringWrapper(value);
119+
} catch (Exception e) {
120+
// deserialization failed, continue
121+
LOGGER.finest("Failed to deserialize oneOf Map<String, String> (error: " + e.getMessage() + ") (type: Map<String, String>)");
122+
}
123+
}
84124
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
85125
}
86126

0 commit comments

Comments
 (0)