From 60725182ebb5dfad1075fc9adfd7cd2900764248 Mon Sep 17 00:00:00 2001 From: Sylvain Wallez Date: Tue, 25 Jan 2022 17:30:49 +0100 Subject: [PATCH] [codegen] Fix ErrorCause and MultiSearchItem Fixes #80, fixes #110 --- .../elasticsearch/_types/ErrorCause.java | 18 +++++++++----- .../core/msearch/MultiSearchItem.java | 24 ++++++++++++------- .../elasticsearch/doc-files/api-spec.html | 6 ++--- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java index 886eb77bc..5c7382b28 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java @@ -56,6 +56,7 @@ public class ErrorCause implements JsonpSerializable { private final Map metadata; + @Nullable private final String type; private final String reason; @@ -76,7 +77,7 @@ private ErrorCause(Builder builder) { this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.type = builder.type; this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); this.stackTrace = builder.stackTrace; this.causedBy = builder.causedBy; @@ -97,10 +98,11 @@ public final Map metadata() { } /** - * Required - The type of error + * The type of error *

* API name: {@code type} */ + @Nullable public final String type() { return this.type; } @@ -164,9 +166,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } - generator.writeKey("type"); - generator.write(this.type); + if (this.type != null) { + generator.writeKey("type"); + generator.write(this.type); + } generator.writeKey("reason"); generator.write(this.reason); @@ -233,6 +237,7 @@ public final Builder metadata(String key, JsonData value) { return this; } + @Nullable private String type; private String reason; @@ -250,11 +255,11 @@ public final Builder metadata(String key, JsonData value) { private List suppressed; /** - * Required - The type of error + * The type of error *

* API name: {@code type} */ - public final Builder type(String value) { + public final Builder type(@Nullable String value) { this.type = value; return this; } @@ -389,6 +394,7 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer extends SearchResponse { - private final int status; + @Nullable + private final Integer status; // --------------------------------------------------------------------------------------------- private MultiSearchItem(Builder builder) { super(builder); - this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.status = builder.status; } @@ -64,17 +65,21 @@ public static MultiSearchItem of( } /** - * Required - API name: {@code status} + * API name: {@code status} */ - public final int status() { + @Nullable + public final Integer status() { return this.status; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("status"); - generator.write(this.status); + if (this.status != null) { + generator.writeKey("status"); + generator.write(this.status); + + } } @@ -87,12 +92,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends SearchResponse.AbstractBuilder> implements ObjectBuilder> { + @Nullable private Integer status; /** - * Required - API name: {@code status} + * API name: {@code status} */ - public final Builder status(int value) { + public final Builder status(@Nullable Integer value) { this.status = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index 5e063f0a2..50da9e919 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -70,7 +70,7 @@ '_global.mget.Request': '_global/mget/MultiGetRequest.ts#L25-L91', '_global.mget.Response': '_global/mget/MultiGetResponse.ts#L22-L26', '_global.mget.ResponseItem': '_global/mget/types.ts#L57-L60', -'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L71-L73', +'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L71-L74', '_global.msearch.MultiSearchResult': '_global/msearch/types.ts#L61-L64', '_global.msearch.MultisearchBody': '_global/msearch/types.ts#L50-L59', '_global.msearch.MultisearchHeader': '_global/msearch/types.ts#L36-L48', @@ -2351,10 +2351,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/a1d9087193e3f218a57351312ef524f6eaa1e606/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/4cf59cba3d6bbbaca7524792d4fa0a107f607107/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification.