Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18141,7 +18141,8 @@ components:
description: "The value of the set action"
oneOf:
- type: string
- format: int64
- format: int32
maximum: 2147483647
type: integer
- type: boolean
CloudWorkloadSecurityAgentRuleActions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,44 +131,45 @@ public CloudWorkloadSecurityAgentRuleActionSetValue deserialize(
log.log(Level.FINER, "Input data does not match schema 'String'", e);
}

// deserialize Long
// deserialize Integer
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (Long.class.equals(Integer.class)
|| Long.class.equals(Long.class)
|| Long.class.equals(Float.class)
|| Long.class.equals(Double.class)
|| Long.class.equals(Boolean.class)
|| Long.class.equals(String.class)) {
if (Integer.class.equals(Integer.class)
|| Integer.class.equals(Long.class)
|| Integer.class.equals(Float.class)
|| Integer.class.equals(Double.class)
|| Integer.class.equals(Boolean.class)
|| Integer.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((Long.class.equals(Integer.class) || Long.class.equals(Long.class))
((Integer.class.equals(Integer.class) || Integer.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((Long.class.equals(Float.class) || Long.class.equals(Double.class))
((Integer.class.equals(Float.class) || Integer.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(Long.class.equals(Boolean.class)
(Integer.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (Long.class.equals(String.class) && token == JsonToken.VALUE_STRING);
attemptParsing |=
(Integer.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(Long.class);
tmp = tree.traverse(jp.getCodec()).readValueAs(Integer.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.
deserialized = tmp;
match++;

log.log(Level.FINER, "Input data matches schema 'Long'");
log.log(Level.FINER, "Input data matches schema 'Integer'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'Long'", e);
log.log(Level.FINER, "Input data does not match schema 'Integer'", e);
}

// deserialize Boolean
Expand Down Expand Up @@ -248,7 +249,7 @@ public CloudWorkloadSecurityAgentRuleActionSetValue(String o) {
setActualInstance(o);
}

public CloudWorkloadSecurityAgentRuleActionSetValue(Long o) {
public CloudWorkloadSecurityAgentRuleActionSetValue(Integer o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
Expand All @@ -260,7 +261,7 @@ public CloudWorkloadSecurityAgentRuleActionSetValue(Boolean o) {

static {
schemas.put("String", new GenericType<String>() {});
schemas.put("Long", new GenericType<Long>() {});
schemas.put("Integer", new GenericType<Integer>() {});
schemas.put("Boolean", new GenericType<Boolean>() {});
JSON.registerDescendants(
CloudWorkloadSecurityAgentRuleActionSetValue.class, Collections.unmodifiableMap(schemas));
Expand All @@ -273,7 +274,7 @@ public Map<String, GenericType> getSchemas() {

/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: String, Long, Boolean
* against the oneOf child schemas: String, Integer, Boolean
*
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
Expand All @@ -284,7 +285,7 @@ public void setActualInstance(Object instance) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(Long.class, instance, new HashSet<Class<?>>())) {
if (JSON.isInstanceOf(Integer.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
Expand All @@ -297,13 +298,13 @@ public void setActualInstance(Object instance) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException("Invalid instance type. Must be String, Long, Boolean");
throw new RuntimeException("Invalid instance type. Must be String, Integer, Boolean");
}

/**
* Get the actual instance, which can be the following: String, Long, Boolean
* Get the actual instance, which can be the following: String, Integer, Boolean
*
* @return The actual instance (String, Long, Boolean)
* @return The actual instance (String, Integer, Boolean)
*/
@Override
public Object getActualInstance() {
Expand All @@ -322,14 +323,14 @@ public String getString() throws ClassCastException {
}

/**
* Get the actual instance of `Long`. If the actual instance is not `Long`, the ClassCastException
* will be thrown.
* Get the actual instance of `Integer`. If the actual instance is not `Integer`, the
* ClassCastException will be thrown.
*
* @return The actual instance of `Long`
* @throws ClassCastException if the instance is not `Long`
* @return The actual instance of `Integer`
* @throws ClassCastException if the instance is not `Integer`
*/
public Long getLong() throws ClassCastException {
return (Long) super.getActualInstance();
public Integer getInteger() throws ClassCastException {
return (Integer) super.getActualInstance();
}

/**
Expand Down
Loading