Skip to content

Commit 151e090

Browse files
committed
Patches for jobId fields
1 parent 843d942 commit 151e090

2 files changed

Lines changed: 216 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
--- src/main/java/uniregistrar/openapi/model/RegistrarRequestJobId.java 2026-01-19 14:00:12.159445907 +0100
2+
+++ src/main/java/uniregistrar/openapi/model/RegistrarRequestJobId.java.changed 2026-01-19 14:04:24.063072670 +0100
3+
@@ -86,31 +86,31 @@
4+
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
5+
int match = 0;
6+
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
7+
- // deserialize Object
8+
+ // deserialize Map<String, Object>
9+
try {
10+
boolean attemptParsing = true;
11+
// ensure that we respect type coercion as set on the client ObjectMapper
12+
- if (Object.class.equals(Integer.class) || Object.class.equals(Long.class) || Object.class.equals(Float.class) || Object.class.equals(Double.class) || Object.class.equals(Boolean.class) || Object.class.equals(String.class)) {
13+
+ if (Map.class.equals(Integer.class) || Map.class.equals(Long.class) || Map.class.equals(Float.class) || Map.class.equals(Double.class) || Map.class.equals(Boolean.class) || Map.class.equals(String.class)) {
14+
attemptParsing = typeCoercion;
15+
if (!attemptParsing) {
16+
- attemptParsing |= ((Object.class.equals(Integer.class) || Object.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
17+
- attemptParsing |= ((Object.class.equals(Float.class) || Object.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
18+
- attemptParsing |= (Object.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
19+
- attemptParsing |= (Object.class.equals(String.class) && token == JsonToken.VALUE_STRING);
20+
+ attemptParsing |= ((Map.class.equals(Integer.class) || Map.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
21+
+ attemptParsing |= ((Map.class.equals(Float.class) || Map.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
22+
+ attemptParsing |= (Map.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
23+
+ attemptParsing |= (Map.class.equals(String.class) && token == JsonToken.VALUE_STRING);
24+
attemptParsing |= (token == JsonToken.VALUE_NULL);
25+
}
26+
}
27+
if (attemptParsing) {
28+
- deserialized = tree.traverse(jp.getCodec()).readValueAs(Object.class);
29+
+ deserialized = tree.traverse(jp.getCodec()).readValueAs(Map.class);
30+
// TODO: there is no validation against JSON schema constraints
31+
// (min, max, enum, pattern...), this does not perform a strict JSON
32+
// validation, which means the 'match' count may be higher than it should be.
33+
match++;
34+
- log.log(Level.FINER, "Input data matches schema 'Object'");
35+
+ log.log(Level.FINER, "Input data matches schema 'Map<String, Object>'");
36+
}
37+
} catch (Exception e) {
38+
// deserialization failed, continue
39+
- log.log(Level.FINER, "Input data does not match schema 'Object'", e);
40+
+ log.log(Level.FINER, "Input data does not match schema 'Map<String, Object>'", e);
41+
}
42+
43+
// deserialize String
44+
@@ -175,7 +175,7 @@
45+
}
46+
47+
static {
48+
- schemas.put("Object", Object.class);
49+
+ schemas.put("Map<String, Object>", Map.class);
50+
schemas.put("String", String.class);
51+
JSON.registerDescendants(RegistrarRequestJobId.class, Collections.unmodifiableMap(schemas));
52+
}
53+
@@ -200,7 +200,7 @@
54+
return;
55+
}
56+
57+
- if (JSON.isInstanceOf(Object.class, instance, new HashSet<Class<?>>())) {
58+
+ if (JSON.isInstanceOf(Map.class, instance, new HashSet<Class<?>>())) {
59+
super.setActualInstance(instance);
60+
return;
61+
}
62+
@@ -210,14 +210,14 @@
63+
return;
64+
}
65+
66+
- throw new RuntimeException("Invalid instance type. Must be Object, String");
67+
+ throw new RuntimeException("Invalid instance type. Must be Map<String, Object>, String");
68+
}
69+
70+
/**
71+
* Get the actual instance, which can be the following:
72+
- * Object, String
73+
+ * Map<String, Object></String,>, String
74+
*
75+
- * @return The actual instance (Object, String)
76+
+ * @return The actual instance (Map<String, Object></String,>, String)
77+
*/
78+
@Override
79+
public Object getActualInstance() {
80+
@@ -225,14 +225,14 @@
81+
}
82+
83+
/**
84+
- * Get the actual instance of `Object`. If the actual instance is not `Object`,
85+
+ * Get the actual instance of `Map<String, Object>`. If the actual instance is not `Map<String, Object>`,
86+
* the ClassCastException will be thrown.
87+
*
88+
- * @return The actual instance of `Object`
89+
- * @throws ClassCastException if the instance is not `Object`
90+
+ * @return The actual instance of `Map<String, Object>`
91+
+ * @throws ClassCastException if the instance is not `Map<String, Object>`
92+
*/
93+
- public Object getObject() throws ClassCastException {
94+
- return (Object)super.getActualInstance();
95+
+ public Map<String, Object> getMap() throws ClassCastException {
96+
+ return (Map<String, Object>)super.getActualInstance();
97+
}
98+
99+
/**
100+
@@ -286,7 +286,7 @@
101+
}
102+
return joiner.toString();
103+
}
104+
- if (getActualInstance() instanceof Object) {
105+
+ if (getActualInstance() instanceof Map) {
106+
if (getActualInstance() != null) {
107+
joiner.add(String.format(java.util.Locale.ROOT, "%sone_of_1%s=%s", prefix, suffix, ApiClient.urlEncode(String.valueOf(getActualInstance()))));
108+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
--- src/main/java/uniregistrar/openapi/model/RegistrarStateJobId.java 2026-01-19 14:00:12.159445907 +0100
2+
+++ src/main/java/uniregistrar/openapi/model/RegistrarStateJobId.java.changed 2026-01-19 14:04:24.063072670 +0100
3+
@@ -86,31 +86,31 @@
4+
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
5+
int match = 0;
6+
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
7+
- // deserialize Object
8+
+ // deserialize Map<String, Object>
9+
try {
10+
boolean attemptParsing = true;
11+
// ensure that we respect type coercion as set on the client ObjectMapper
12+
- if (Object.class.equals(Integer.class) || Object.class.equals(Long.class) || Object.class.equals(Float.class) || Object.class.equals(Double.class) || Object.class.equals(Boolean.class) || Object.class.equals(String.class)) {
13+
+ if (Map.class.equals(Integer.class) || Map.class.equals(Long.class) || Map.class.equals(Float.class) || Map.class.equals(Double.class) || Map.class.equals(Boolean.class) || Map.class.equals(String.class)) {
14+
attemptParsing = typeCoercion;
15+
if (!attemptParsing) {
16+
- attemptParsing |= ((Object.class.equals(Integer.class) || Object.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
17+
- attemptParsing |= ((Object.class.equals(Float.class) || Object.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
18+
- attemptParsing |= (Object.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
19+
- attemptParsing |= (Object.class.equals(String.class) && token == JsonToken.VALUE_STRING);
20+
+ attemptParsing |= ((Map.class.equals(Integer.class) || Map.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
21+
+ attemptParsing |= ((Map.class.equals(Float.class) || Map.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
22+
+ attemptParsing |= (Map.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
23+
+ attemptParsing |= (Map.class.equals(String.class) && token == JsonToken.VALUE_STRING);
24+
attemptParsing |= (token == JsonToken.VALUE_NULL);
25+
}
26+
}
27+
if (attemptParsing) {
28+
- deserialized = tree.traverse(jp.getCodec()).readValueAs(Object.class);
29+
+ deserialized = tree.traverse(jp.getCodec()).readValueAs(Map.class);
30+
// TODO: there is no validation against JSON schema constraints
31+
// (min, max, enum, pattern...), this does not perform a strict JSON
32+
// validation, which means the 'match' count may be higher than it should be.
33+
match++;
34+
- log.log(Level.FINER, "Input data matches schema 'Object'");
35+
+ log.log(Level.FINER, "Input data matches schema 'Map<String, Object>'");
36+
}
37+
} catch (Exception e) {
38+
// deserialization failed, continue
39+
- log.log(Level.FINER, "Input data does not match schema 'Object'", e);
40+
+ log.log(Level.FINER, "Input data does not match schema 'Map<String, Object>'", e);
41+
}
42+
43+
// deserialize String
44+
@@ -175,7 +175,7 @@
45+
}
46+
47+
static {
48+
- schemas.put("Object", Object.class);
49+
+ schemas.put("Map<String, Object>", Map.class);
50+
schemas.put("String", String.class);
51+
JSON.registerDescendants(RegistrarStateJobId.class, Collections.unmodifiableMap(schemas));
52+
}
53+
@@ -200,7 +200,7 @@
54+
return;
55+
}
56+
57+
- if (JSON.isInstanceOf(Object.class, instance, new HashSet<Class<?>>())) {
58+
+ if (JSON.isInstanceOf(Map.class, instance, new HashSet<Class<?>>())) {
59+
super.setActualInstance(instance);
60+
return;
61+
}
62+
@@ -210,14 +210,14 @@
63+
return;
64+
}
65+
66+
- throw new RuntimeException("Invalid instance type. Must be Object, String");
67+
+ throw new RuntimeException("Invalid instance type. Must be Map<String, Object>, String");
68+
}
69+
70+
/**
71+
* Get the actual instance, which can be the following:
72+
- * Object, String
73+
+ * Map<String, Object>, String
74+
*
75+
- * @return The actual instance (Object, String)
76+
+ * @return The actual instance (Map<String, Object>, String)
77+
*/
78+
@Override
79+
public Object getActualInstance() {
80+
@@ -225,14 +225,14 @@
81+
}
82+
83+
/**
84+
- * Get the actual instance of `Object`. If the actual instance is not `Object`,
85+
+ * Get the actual instance of `Map<String, Object>`. If the actual instance is not `Map<String, Object>`,
86+
* the ClassCastException will be thrown.
87+
*
88+
- * @return The actual instance of `Object`
89+
- * @throws ClassCastException if the instance is not `Object`
90+
+ * @return The actual instance of `Map<String, Object>`
91+
+ * @throws ClassCastException if the instance is not `Map<String, Object>`
92+
*/
93+
- public Object getObject() throws ClassCastException {
94+
- return (Object)super.getActualInstance();
95+
+ public Map<String, Object> getMap() throws ClassCastException {
96+
+ return (Map<String, Object>)super.getActualInstance();
97+
}
98+
99+
/**
100+
@@ -286,7 +286,7 @@
101+
}
102+
return joiner.toString();
103+
}
104+
- if (getActualInstance() instanceof Object) {
105+
+ if (getActualInstance() instanceof Map) {
106+
if (getActualInstance() != null) {
107+
joiner.add(String.format(java.util.Locale.ROOT, "%sone_of_1%s=%s", prefix, suffix, ApiClient.urlEncode(String.valueOf(getActualInstance()))));
108+
}

0 commit comments

Comments
 (0)