diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 8c4bbdb2187..586bbcae6ab 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -25656,9 +25656,9 @@ components: WidgetTime: description: Time setting for the widget. oneOf: - - $ref: '#/components/schemas/WidgetLegacyLiveSpan' - $ref: '#/components/schemas/WidgetNewLiveSpan' - $ref: '#/components/schemas/WidgetNewFixedSpan' + - $ref: '#/components/schemas/WidgetLegacyLiveSpan' WidgetTimeWindows: description: Define a time window. enum: diff --git a/src/main/java/com/datadog/api/client/v1/model/WidgetTime.java b/src/main/java/com/datadog/api/client/v1/model/WidgetTime.java index fed3f037846..4ce6d6d8743 100644 --- a/src/main/java/com/datadog/api/client/v1/model/WidgetTime.java +++ b/src/main/java/com/datadog/api/client/v1/model/WidgetTime.java @@ -77,51 +77,6 @@ public WidgetTime deserialize(JsonParser jp, DeserializationContext ctxt) boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); int match = 0; JsonToken token = tree.traverse(jp.getCodec()).nextToken(); - // deserialize WidgetLegacyLiveSpan - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (WidgetLegacyLiveSpan.class.equals(Integer.class) - || WidgetLegacyLiveSpan.class.equals(Long.class) - || WidgetLegacyLiveSpan.class.equals(Float.class) - || WidgetLegacyLiveSpan.class.equals(Double.class) - || WidgetLegacyLiveSpan.class.equals(Boolean.class) - || WidgetLegacyLiveSpan.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((WidgetLegacyLiveSpan.class.equals(Integer.class) - || WidgetLegacyLiveSpan.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((WidgetLegacyLiveSpan.class.equals(Float.class) - || WidgetLegacyLiveSpan.class.equals(Double.class)) - && (token == JsonToken.VALUE_NUMBER_FLOAT - || token == JsonToken.VALUE_NUMBER_INT)); - attemptParsing |= - (WidgetLegacyLiveSpan.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (WidgetLegacyLiveSpan.class.equals(String.class) - && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - tmp = tree.traverse(jp.getCodec()).readValueAs(WidgetLegacyLiveSpan.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - if (!((WidgetLegacyLiveSpan) tmp).unparsed) { - deserialized = tmp; - match++; - } - log.log(Level.FINER, "Input data matches schema 'WidgetLegacyLiveSpan'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'WidgetLegacyLiveSpan'", e); - } - // deserialize WidgetNewLiveSpan try { boolean attemptParsing = true; @@ -210,6 +165,51 @@ public WidgetTime deserialize(JsonParser jp, DeserializationContext ctxt) log.log(Level.FINER, "Input data does not match schema 'WidgetNewFixedSpan'", e); } + // deserialize WidgetLegacyLiveSpan + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (WidgetLegacyLiveSpan.class.equals(Integer.class) + || WidgetLegacyLiveSpan.class.equals(Long.class) + || WidgetLegacyLiveSpan.class.equals(Float.class) + || WidgetLegacyLiveSpan.class.equals(Double.class) + || WidgetLegacyLiveSpan.class.equals(Boolean.class) + || WidgetLegacyLiveSpan.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((WidgetLegacyLiveSpan.class.equals(Integer.class) + || WidgetLegacyLiveSpan.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((WidgetLegacyLiveSpan.class.equals(Float.class) + || WidgetLegacyLiveSpan.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (WidgetLegacyLiveSpan.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (WidgetLegacyLiveSpan.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(WidgetLegacyLiveSpan.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((WidgetLegacyLiveSpan) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'WidgetLegacyLiveSpan'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'WidgetLegacyLiveSpan'", e); + } + WidgetTime ret = new WidgetTime(); if (match == 1) { ret.setActualInstance(deserialized); @@ -238,25 +238,25 @@ public WidgetTime() { super("oneOf", Boolean.FALSE); } - public WidgetTime(WidgetLegacyLiveSpan o) { + public WidgetTime(WidgetNewLiveSpan o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } - public WidgetTime(WidgetNewLiveSpan o) { + public WidgetTime(WidgetNewFixedSpan o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } - public WidgetTime(WidgetNewFixedSpan o) { + public WidgetTime(WidgetLegacyLiveSpan o) { super("oneOf", Boolean.FALSE); setActualInstance(o); } static { - schemas.put("WidgetLegacyLiveSpan", new GenericType() {}); schemas.put("WidgetNewLiveSpan", new GenericType() {}); schemas.put("WidgetNewFixedSpan", new GenericType() {}); + schemas.put("WidgetLegacyLiveSpan", new GenericType() {}); JSON.registerDescendants(WidgetTime.class, Collections.unmodifiableMap(schemas)); } @@ -267,22 +267,22 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: WidgetLegacyLiveSpan, WidgetNewLiveSpan, WidgetNewFixedSpan + * against the oneOf child schemas: WidgetNewLiveSpan, WidgetNewFixedSpan, WidgetLegacyLiveSpan * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). */ @Override public void setActualInstance(Object instance) { - if (JSON.isInstanceOf(WidgetLegacyLiveSpan.class, instance, new HashSet>())) { + if (JSON.isInstanceOf(WidgetNewLiveSpan.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(WidgetNewLiveSpan.class, instance, new HashSet>())) { + if (JSON.isInstanceOf(WidgetNewFixedSpan.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(WidgetNewFixedSpan.class, instance, new HashSet>())) { + if (JSON.isInstanceOf(WidgetLegacyLiveSpan.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } @@ -292,32 +292,21 @@ public void setActualInstance(Object instance) { return; } throw new RuntimeException( - "Invalid instance type. Must be WidgetLegacyLiveSpan, WidgetNewLiveSpan," - + " WidgetNewFixedSpan"); + "Invalid instance type. Must be WidgetNewLiveSpan, WidgetNewFixedSpan," + + " WidgetLegacyLiveSpan"); } /** - * Get the actual instance, which can be the following: WidgetLegacyLiveSpan, WidgetNewLiveSpan, - * WidgetNewFixedSpan + * Get the actual instance, which can be the following: WidgetNewLiveSpan, WidgetNewFixedSpan, + * WidgetLegacyLiveSpan * - * @return The actual instance (WidgetLegacyLiveSpan, WidgetNewLiveSpan, WidgetNewFixedSpan) + * @return The actual instance (WidgetNewLiveSpan, WidgetNewFixedSpan, WidgetLegacyLiveSpan) */ @Override public Object getActualInstance() { return super.getActualInstance(); } - /** - * Get the actual instance of `WidgetLegacyLiveSpan`. If the actual instance is not - * `WidgetLegacyLiveSpan`, the ClassCastException will be thrown. - * - * @return The actual instance of `WidgetLegacyLiveSpan` - * @throws ClassCastException if the instance is not `WidgetLegacyLiveSpan` - */ - public WidgetLegacyLiveSpan getWidgetLegacyLiveSpan() throws ClassCastException { - return (WidgetLegacyLiveSpan) super.getActualInstance(); - } - /** * Get the actual instance of `WidgetNewLiveSpan`. If the actual instance is not * `WidgetNewLiveSpan`, the ClassCastException will be thrown. @@ -339,4 +328,15 @@ public WidgetNewLiveSpan getWidgetNewLiveSpan() throws ClassCastException { public WidgetNewFixedSpan getWidgetNewFixedSpan() throws ClassCastException { return (WidgetNewFixedSpan) super.getActualInstance(); } + + /** + * Get the actual instance of `WidgetLegacyLiveSpan`. If the actual instance is not + * `WidgetLegacyLiveSpan`, the ClassCastException will be thrown. + * + * @return The actual instance of `WidgetLegacyLiveSpan` + * @throws ClassCastException if the instance is not `WidgetLegacyLiveSpan` + */ + public WidgetLegacyLiveSpan getWidgetLegacyLiveSpan() throws ClassCastException { + return (WidgetLegacyLiveSpan) super.getActualInstance(); + } }