Skip to content

Commit

Permalink
[codegen] Fix ErrorCause and MultiSearchItem
Browse files Browse the repository at this point in the history
Fixes #80, fixes #110
  • Loading branch information
swallez committed Jan 25, 2022
1 parent 30ed36e commit 2b1f460
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
public class ErrorCause implements JsonpSerializable {
private final Map<String, JsonData> metadata;

@Nullable
private final String type;

private final String reason;
Expand All @@ -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;
Expand All @@ -97,10 +98,11 @@ public final Map<String, JsonData> metadata() {
}

/**
* Required - The type of error
* The type of error
* <p>
* API name: {@code type}
*/
@Nullable
public final String type() {
return this.type;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -233,6 +237,7 @@ public final Builder metadata(String key, JsonData value) {
return this;
}

@Nullable
private String type;

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

/**
* Required - The type of error
* The type of error
* <p>
* API name: {@code type}
*/
public final Builder type(String value) {
public final Builder type(@Nullable String value) {
this.type = value;
return this;
}
Expand Down Expand Up @@ -389,6 +394,7 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer<ErrorCause.
}
builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper));
});
op.shortcutProperty("reason");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Integer;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable;

// typedef: _global.msearch.MultiSearchItem

Expand All @@ -47,14 +47,15 @@
*/

public class MultiSearchItem<TDocument> extends SearchResponse<TDocument> {
private final int status;
@Nullable
private final Integer status;

// ---------------------------------------------------------------------------------------------

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

this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status");
this.status = builder.status;

}

Expand All @@ -64,17 +65,21 @@ public static <TDocument> MultiSearchItem<TDocument> 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);

}

}

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

/**
* Required - API name: {@code status}
* API name: {@code status}
*/
public final Builder<TDocument> status(int value) {
public final Builder<TDocument> status(@Nullable Integer value) {
this.status = value;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'_global.mget.Request': '_global/mget/MultiGetRequest.ts#L25-L92',
'_global.mget.Response': '_global/mget/MultiGetResponse.ts#L22-L26',
'_global.mget.ResponseItem': '_global/mget/types.ts#L59-L62',
'_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',
Expand Down Expand Up @@ -2274,10 +2274,10 @@
if (hash.length > 1) {
hash = hash.substring(1);
}
window.location = "https://github.com/elastic/elasticsearch-specification/tree/f6472508a71ccdfd9608bb0eb3afd12da8747c49/specification/" + (paths[hash] || "");
window.location = "https://github.com/elastic/elasticsearch-specification/tree/9dcdca6513e3f03f2ca566de236c43772242aaca/specification/" + (paths[hash] || "");
</script>
</head>
<body>
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/f6472508a71ccdfd9608bb0eb3afd12da8747c49/specification/">Elasticsearch API specification</a>.
Please see the <a href="https://github.com/elastic/elasticsearch-specification/tree/9dcdca6513e3f03f2ca566de236c43772242aaca/specification/">Elasticsearch API specification</a>.
</body>
</html>

0 comments on commit 2b1f460

Please sign in to comment.