oneOf) {
- if (oneOf.size() == 2) {
- var first = oneOf.get(0);
- var second = oneOf.get(1);
+ if (isOneOfSingleAndArray(oneOf)) {
+ return mapType(oneOf.get(1));
+ }
- if (isOneOfSingleAndArray(oneOf)) {
- return mapType(second);
- }
+ var types = oneOf.stream().map(OpenApiSchema::determineTypes).flatMap(Set::stream).collect(Collectors.toSet());
- if ((first.isString() && (second.isString() || second.isNumber())) || (first.isNumber() && second.isString())) {
- return Types.Java.Lang.String;
- }
-
- if (first.isBoolean() && second.isString()) {
- return Types.Primitive.Boolean;
- }
+ if (types.size() == 2
+ && types.contains(OpenApiSchemaType.String)
+ && (types.contains(OpenApiSchemaType.Boolean) || types.contains(OpenApiSchemaType.Number))) {
+ return Types.Java.Lang.String;
}
throw new UnsupportedOperationException("Can not get type name for oneOf: " + oneOf);
diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/HttpStatusCode.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/HttpStatusCode.java
index 709d0f1d53..bf69e82fcf 100644
--- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/HttpStatusCode.java
+++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/HttpStatusCode.java
@@ -14,8 +14,10 @@
public enum HttpStatusCode {
Ok("200"),
+ Created("201"),
BadRequest("400"),
Forbidden("403"),
+ NotFound("404"),
InternalServerError("500"),
NotImplemented("501");
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache
index 56d73c16c1..47f7ce70dd 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache
@@ -3,7 +3,7 @@
*/
public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {
{{#fields}}
- @{{TYPES.Javax.Annotation.Nullable}} private {{type.boxed}} {{name}};
+ {{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}private {{type.boxed}} {{name}};
{{/fields}}
{{#fields}}
@@ -74,4 +74,4 @@
return new {{className}}(this);
}
- }
+ }
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/Basic.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/Basic.mustache
index c09290663b..cd2f155d34 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/Basic.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/Basic.mustache
@@ -1,5 +1,3 @@
/**
-
{{>ObjectShape/FieldDoc/BasicInner}}
-
*/
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache
index 89f13ae78e..332d7bfb4a 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache
@@ -1,5 +1 @@
-{{#description}}
-* {{#required}}Required - {{/required}}{{.}}
-{{/description}}
-
-* API name: {@code {{wireName}}}
\ No newline at end of file
+* {{#required}}Required - {{/required}}{{#description}}{{.}}
{{/description}}API name: {@code {{wireName}}}
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache
index d8720ba088..65cb2a3aa7 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache
@@ -1,5 +1,4 @@
/**
{{>ObjectShape/FieldDoc/BasicInner}}
-
* Adds one or more values to {{name}}
.
*/
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache
index 2894d9549d..9f38e2fdba 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache
@@ -1,5 +1,4 @@
/**
{{>ObjectShape/FieldDoc/BasicInner}}
-
* Adds all elements of list
to {{name}}
.
*/
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache
index 867d0eca28..72123b3e31 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache
@@ -1,5 +1,4 @@
/**
{{>ObjectShape/FieldDoc/BasicInner}}
-
* Adds a value to {{name}}
using a builder lambda.
*/
\ No newline at end of file
diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache
index 913277c480..9137af0758 100644
--- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache
+++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache
@@ -1,4 +1,13 @@
{{>ObjectShape/ClassDeclaration}} {
+ {{#canBeSingleton}}
+ public {{className}}() {}
+
+ /**
+ * Singleton instance for {@link {{className}}}.
+ */
+ public static final {{className}} _INSTANCE = new {{className}}();
+ {{/canBeSingleton}}
+ {{^canBeSingleton}}
{{>ObjectShape/Fields}}
// ---------------------------------------------------------------------------------------------
@@ -19,6 +28,7 @@
// ---------------------------------------------------------------------------------------------
{{>ObjectShape/Deserialize}}{{/hasRequestBody}}
+ {{/canBeSingleton}}
// ---------------------------------------------------------------------------------------------
@@ -29,11 +39,21 @@
// Request method
request -> {{#quoted}}{{httpMethod}}{{/quoted}},
// Request path
- request -> {
+ request ->
{{#hasSinglePath}}
- {{#firstPath}}{{>RequestShape/HttpPathBuilder}}{{/firstPath}}
+ {{#firstPath}}
+ {{#hasParams}}
+ {
+ {{>RequestShape/HttpPathBuilder}}
+ }
+ {{/hasParams}}
+ {{^hasParams}}
+ {{#quoted}}{{this}}{{/quoted}}
+ {{/hasParams}}
+ {{/firstPath}}
{{/hasSinglePath}}
{{^hasSinglePath}}
+ {
{{#indexedPathParams}}
final int _{{left}} = 1 << {{right}};
{{/indexedPathParams}}
@@ -51,8 +71,8 @@
{{/httpPaths}}
throw {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.noPathTemplateFound("path");
- {{/hasSinglePath}}
- },
+ }
+ {{/hasSinglePath}},
// Request parameters
{{#hasQueryParams}}
request -> {