Skip to content

Commit 6072518

Browse files
committed
[codegen] Fix ErrorCause and MultiSearchItem
Fixes #80, fixes #110
1 parent c55d117 commit 6072518

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
public class ErrorCause implements JsonpSerializable {
5757
private final Map<String, JsonData> metadata;
5858

59+
@Nullable
5960
private final String type;
6061

6162
private final String reason;
@@ -76,7 +77,7 @@ private ErrorCause(Builder builder) {
7677

7778
this.metadata = ApiTypeHelper.unmodifiable(builder.metadata);
7879

79-
this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type");
80+
this.type = builder.type;
8081
this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason");
8182
this.stackTrace = builder.stackTrace;
8283
this.causedBy = builder.causedBy;
@@ -97,10 +98,11 @@ public final Map<String, JsonData> metadata() {
9798
}
9899

99100
/**
100-
* Required - The type of error
101+
* The type of error
101102
* <p>
102103
* API name: {@code type}
103104
*/
105+
@Nullable
104106
public final String type() {
105107
return this.type;
106108
}
@@ -164,9 +166,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
164166

165167
}
166168

167-
generator.writeKey("type");
168-
generator.write(this.type);
169+
if (this.type != null) {
170+
generator.writeKey("type");
171+
generator.write(this.type);
169172

173+
}
170174
generator.writeKey("reason");
171175
generator.write(this.reason);
172176

@@ -233,6 +237,7 @@ public final Builder metadata(String key, JsonData value) {
233237
return this;
234238
}
235239

240+
@Nullable
236241
private String type;
237242

238243
private String reason;
@@ -250,11 +255,11 @@ public final Builder metadata(String key, JsonData value) {
250255
private List<ErrorCause> suppressed;
251256

252257
/**
253-
* Required - The type of error
258+
* The type of error
254259
* <p>
255260
* API name: {@code type}
256261
*/
257-
public final Builder type(String value) {
262+
public final Builder type(@Nullable String value) {
258263
this.type = value;
259264
return this;
260265
}
@@ -389,6 +394,7 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer<ErrorCause.
389394
}
390395
builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
391396
});
397+
op.shortcutProperty("reason");
392398

393399
}
394400

java-client/src/main/java/co/elastic/clients/elasticsearch/core/msearch/MultiSearchItem.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
import co.elastic.clients.json.JsonpMapper;
3030
import co.elastic.clients.json.ObjectBuilderDeserializer;
3131
import co.elastic.clients.json.ObjectDeserializer;
32-
import co.elastic.clients.util.ApiTypeHelper;
3332
import co.elastic.clients.util.ObjectBuilder;
3433
import jakarta.json.stream.JsonGenerator;
3534
import java.lang.Integer;
3635
import java.util.Objects;
3736
import java.util.function.Function;
3837
import java.util.function.Supplier;
38+
import javax.annotation.Nullable;
3939

4040
// typedef: _global.msearch.MultiSearchItem
4141

@@ -47,14 +47,15 @@
4747
*/
4848

4949
public class MultiSearchItem<TDocument> extends SearchResponse<TDocument> {
50-
private final int status;
50+
@Nullable
51+
private final Integer status;
5152

5253
// ---------------------------------------------------------------------------------------------
5354

5455
private MultiSearchItem(Builder<TDocument> builder) {
5556
super(builder);
5657

57-
this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status");
58+
this.status = builder.status;
5859

5960
}
6061

@@ -64,17 +65,21 @@ public static <TDocument> MultiSearchItem<TDocument> of(
6465
}
6566

6667
/**
67-
* Required - API name: {@code status}
68+
* API name: {@code status}
6869
*/
69-
public final int status() {
70+
@Nullable
71+
public final Integer status() {
7072
return this.status;
7173
}
7274

7375
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
7476

7577
super.serializeInternal(generator, mapper);
76-
generator.writeKey("status");
77-
generator.write(this.status);
78+
if (this.status != null) {
79+
generator.writeKey("status");
80+
generator.write(this.status);
81+
82+
}
7883

7984
}
8085

@@ -87,12 +92,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
8792
public static class Builder<TDocument> extends SearchResponse.AbstractBuilder<TDocument, Builder<TDocument>>
8893
implements
8994
ObjectBuilder<MultiSearchItem<TDocument>> {
95+
@Nullable
9096
private Integer status;
9197

9298
/**
93-
* Required - API name: {@code status}
99+
* API name: {@code status}
94100
*/
95-
public final Builder<TDocument> status(int value) {
101+
public final Builder<TDocument> status(@Nullable Integer value) {
96102
this.status = value;
97103
return this;
98104
}

java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
'_global.mget.Request': '_global/mget/MultiGetRequest.ts#L25-L91',
7171
'_global.mget.Response': '_global/mget/MultiGetResponse.ts#L22-L26',
7272
'_global.mget.ResponseItem': '_global/mget/types.ts#L57-L60',
73-
'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L71-L73',
73+
'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L71-L74',
7474
'_global.msearch.MultiSearchResult': '_global/msearch/types.ts#L61-L64',
7575
'_global.msearch.MultisearchBody': '_global/msearch/types.ts#L50-L59',
7676
'_global.msearch.MultisearchHeader': '_global/msearch/types.ts#L36-L48',
@@ -2351,10 +2351,10 @@
23512351
if (hash.length > 1) {
23522352
hash = hash.substring(1);
23532353
}
2354-
window.location = "https://github.com/elastic/elasticsearch-specification/tree/a1d9087193e3f218a57351312ef524f6eaa1e606/specification/" + (paths[hash] || "");
2354+
window.location = "https://github.com/elastic/elasticsearch-specification/tree/4cf59cba3d6bbbaca7524792d4fa0a107f607107/specification/" + (paths[hash] || "");
23552355
</script>
23562356
</head>
23572357
<body>
2358-
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/a1d9087193e3f218a57351312ef524f6eaa1e606/specification/">Elasticsearch API specification</a>.
2358+
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/4cf59cba3d6bbbaca7524792d4fa0a107f607107/specification/">Elasticsearch API specification</a>.
23592359
</body>
23602360
</html>

0 commit comments

Comments
 (0)