diff --git a/CHANGELOG.md b/CHANGELOG.md index 39ea58ea85..453685d9e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Dependencies ### Changed +- Made InlineGet source field nullable. ([#1042](https://github.com/opensearch-project/opensearch-java/pull/1042)) ### Deprecated diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java index cdebb2c397..fcec13c92c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java @@ -68,6 +68,7 @@ public class InlineGet implements JsonpSerializable { @Nullable private final String routing; + @Nullable private final TDocument source; @Nullable @@ -84,7 +85,7 @@ private InlineGet(Builder builder) { this.seqNo = builder.seqNo; this.primaryTerm = builder.primaryTerm; this.routing = builder.routing; - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + this.source = builder.source; this.tDocumentSerializer = builder.tDocumentSerializer; } @@ -139,8 +140,9 @@ public final String routing() { } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ + @Nullable public final TDocument source() { return this.source; } @@ -191,8 +193,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.routing); } - generator.writeKey("_source"); - JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); + if (this.source != null) { + generator.writeKey("_source"); + JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); + + } } @@ -240,6 +245,7 @@ public final Builder metadata(String key, JsonData value) { @Nullable private String routing; + @Nullable private TDocument source; @Nullable @@ -298,9 +304,9 @@ public final Builder routing(@Nullable String value) { } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ - public final Builder source(TDocument value) { + public final Builder source(@Nullable TDocument value) { this.source = value; return this; }