Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Dec 9, 2024
1 parent d2a5949 commit cc65c7b
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public final Boolean includeDefaults() {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To target
* all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand Down Expand Up @@ -414,8 +414,8 @@ public final Builder includeDefaults(@Nullable Boolean value) {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To
* target all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand All @@ -431,8 +431,8 @@ public final Builder index(List<String> list) {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To
* target all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public final Time masterTimeout() {
}

/**
* Comma-separated list of index template names used to limit the request. Wildcard (<code><em></code>) expressions are supported. To
* return all index templates, omit this parameter or use a value of <code>_all</code> or <code></em></code>.
* Comma-separated list of index template names used to limit the request. Wildcard (<code>*</code>) expressions are supported. To
* return all index templates, omit this parameter or use a value of <code>_all</code> or <code>*</code>.
* <p>
* API name: {@code name}
* </p>
Expand Down Expand Up @@ -278,8 +278,8 @@ public final Builder masterTimeout(Function<Time.Builder, ObjectBuilder<Time>> f
}

/**
* Comma-separated list of index template names used to limit the request. Wildcard (<code><em></code>) expressions are supported.
* To return all index templates, omit this parameter or use a value of <code>_all</code> or <code></em></code>.
* Comma-separated list of index template names used to limit the request. Wildcard (<code>*</code>) expressions are supported. To
* return all index templates, omit this parameter or use a value of <code>_all</code> or <code>*</code>.
* <p>
* API name: {@code name}
* </p>
Expand All @@ -295,8 +295,8 @@ public final Builder name(List<String> list) {
}

/**
* Comma-separated list of index template names used to limit the request. Wildcard (<code><em></code>) expressions are supported.
* To return all index templates, omit this parameter or use a value of <code>_all</code> or <code></em></code>.
* Comma-separated list of index template names used to limit the request. Wildcard (<code>*</code>) expressions are supported. To
* return all index templates, omit this parameter or use a value of <code>_all</code> or <code>*</code>.
* <p>
* API name: {@code name}
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.ExpandWildcard;
import org.opensearch.client.opensearch._types.RequestBase;
Expand All @@ -65,9 +67,11 @@
/**
* Updates the index settings.
*/
@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class PutIndicesSettingsRequest extends RequestBase
implements
PlainJsonSerializable,
ToCopyableBuilder<PutIndicesSettingsRequest.Builder, PutIndicesSettingsRequest> {

@Nullable
Expand Down Expand Up @@ -179,8 +183,8 @@ public final Boolean ignoreUnavailable() {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To target
* all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand Down Expand Up @@ -409,8 +413,8 @@ public final Builder ignoreUnavailable(@Nullable Boolean value) {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To
* target all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand All @@ -426,8 +430,8 @@ public final Builder index(List<String> list) {
}

/**
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code><em></code>). To
* target all data streams and indexes, omit this parameter or use <code></em></code> or <code>_all</code>.
* Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (<code>*</code>). To
* target all data streams and indexes, omit this parameter or use <code>*</code> or <code>_all</code>.
* <p>
* API name: {@code index}
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,6 @@ protected static void setupPutTemplateRequestDeserializer(ObjectDeserializer<Put
if (request.masterTimeout != null) {
params.put("master_timeout", request.masterTimeout._toJsonString());
}
if (request.order != null) {
params.put("order", request.order._toJsonString());
}
return params;
},
SimpleEndpoint.emptyMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Time;
Expand All @@ -62,9 +64,11 @@
/**
* Simulate resolving the given template name or body.
*/
@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class SimulateTemplateRequest extends RequestBase
implements
PlainJsonSerializable,
ToCopyableBuilder<SimulateTemplateRequest.Builder, SimulateTemplateRequest> {

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ public void deserialize_validFieldsIncluded_RequestIsBuilt() throws JsonProcessi
final Map<String, Object> indexTemplateMap = new HashMap<>();
indexTemplateMap.put("name", "test");
indexTemplateMap.put("index_patterns", "*");
indexTemplateMap.put("create", true);
indexTemplateMap.put("order", 1);

final String indexTemplate = new ObjectMapper().writeValueAsString(indexTemplateMap);
final JsonParser parser = mapper.jsonProvider().createParser(new StringReader(indexTemplate));

final PutTemplateRequest putTemplateRequest = PutTemplateRequest._DESERIALIZER.deserialize(parser, mapper);

assertEquals(putTemplateRequest.name(), "test");
assertEquals(putTemplateRequest.indexPatterns(), Collections.singletonList("*"));
assertEquals((int) putTemplateRequest.order(), 1);
assertEquals(putTemplateRequest.create(), true);
assertEquals("test", putTemplateRequest.name());
assertEquals(Collections.singletonList("*"), putTemplateRequest.indexPatterns());
assertEquals((Integer) 1, putTemplateRequest.order());
}
}
2 changes: 1 addition & 1 deletion java-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ dependencies {
implementation("org.semver4j", "semver4j", "5.3.0")

// BSD-2-Clause
implementation("org.commonmark", "commonmark", "0.23.0")
implementation("org.commonmark", "commonmark", "0.24.0")

// EPL-2.0
testImplementation(platform("org.junit:junit-bom:5.11.3"))
Expand Down
3 changes: 2 additions & 1 deletion java-codegen/opensearch-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20855,7 +20855,8 @@ components:
Templates with lower 'order' values are merged first. Templates with higher
'order' values are merged later, overriding templates with lower values.
schema:
type: number
type: integer
format: int32
style: form
indices.recovery___path.index:
in: path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private Field(@Nonnull Builder builder) {
}
this.type = Objects.requireNonNull(builder.type, "type must not be null");
this.required = builder.required;
this.description = builder.description != null ? Markdown.toJavaDocHtml(builder.description) : null;
this.description = builder.description;
this.deprecation = builder.deprecation;
this.aliases = builder.aliases;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public Builder withRequired(boolean required) {

@Nonnull
public Builder withDescription(@Nullable String description) {
this.description = description;
this.description = description != null ? Markdown.toJavaDocHtml(description) : null;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public Collection<Field> getFieldsToDeserialize() {
return fields.values();
}

@Override
public boolean hasFieldsToSerialize() {
return hasRequestBody();
}

public boolean hasRequestBody() {
return hasDelegatedBodyField() || !getBodyFields().isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.NotImplementedException;
Expand Down Expand Up @@ -214,12 +215,6 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr
shape.addPathParam(entry.getValue().toBuilder().withRequired(requiredPathParams.contains(entry.getKey())).build());
}

variants.stream()
.flatMap(v -> v.getAllRelevantParameters(In.Query).stream())
.filter(p -> !p.isGlobal())
.map(this::visit)
.forEachOrdered(shape::addQueryParam);

variants.stream()
.map(OpenApiOperation::getRequestBody)
.flatMap(Optional::stream)
Expand All @@ -237,6 +232,16 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr
}
});

var bodyFieldNames = (shape.hasDelegatedBodyField()
? (ObjectShapeBase) shape.getDelegatedBodyField().getType().getTargetShape().orElseThrow()
: shape).getBodyFields().stream().map(Field::getWireName).collect(Collectors.toSet());

variants.stream()
.flatMap(v -> v.getAllRelevantParameters(In.Query).stream())
.filter(p -> !p.isGlobal() && !bodyFieldNames.contains(p.getName().orElseThrow()))
.map(this::visit)
.forEachOrdered(shape::addQueryParam);

if (shape.getExtendsType() == null) {
shape.setExtendsType(Types.Client.OpenSearch._Types.RequestBase);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{{#type.isString}}
{{value}}
{{/type.isString}}
{{^type.isString}}
{{#type.isList}}
{{#type.listValueType.isString}}
String.join(",", {{value}})
{{/type.listValueType.isString}}
{{^type.listValueType.isString}}
{{value}}
.stream()
.map(v -> {{#type.listValueType.queryParamify}}v{{/type.listValueType.queryParamify}})
.collect({{TYPES.Java.Util.Stream.Collectors}}.joining(","))
{{/type.listValueType.isString}}
{{/type.isList}}
{{^type.isList}}
{{#type.isEnum}}
{{value}}.jsonValue()
{{/type.isEnum}}
Expand All @@ -10,20 +18,17 @@
String.valueOf({{value}})
{{/type.isPotentiallyBoxedPrimitive}}
{{^type.isPotentiallyBoxedPrimitive}}
{{#type.isList}}
{{#type.listValueType.isString}}
String.join(",", {{value}})
{{/type.listValueType.isString}}
{{^type.listValueType.isString}}
{{#type.isNumber}}
String.valueOf({{value}})
{{/type.isNumber}}
{{^type.isNumber}}
{{#type.isString}}
{{value}}
.stream()
.map(v -> {{#type.listValueType.queryParamify}}v{{/type.listValueType.queryParamify}})
.collect({{TYPES.Java.Util.Stream.Collectors}}.joining(","))
{{/type.listValueType.isString}}
{{/type.isList}}
{{^type.isList}}
{{value}}._toJsonString()
{{/type.isList}}
{{/type.isString}}
{{^type.isString}}
{{value}}._toJsonString()
{{/type.isString}}
{{/type.isNumber}}
{{/type.isPotentiallyBoxedPrimitive}}
{{/type.isEnum}}
{{/type.isString}}
{{/type.isList}}

0 comments on commit cc65c7b

Please sign in to comment.