@@ -167,6 +167,51 @@ public SyntheticsAPIStep deserialize(JsonParser jp, DeserializationContext ctxt)
167167 log .log (Level .FINER , "Input data does not match schema 'SyntheticsAPIWaitStep'" , e );
168168 }
169169
170+ // deserialize SyntheticsAPISubtestStep
171+ try {
172+ boolean attemptParsing = true ;
173+ // ensure that we respect type coercion as set on the client ObjectMapper
174+ if (SyntheticsAPISubtestStep .class .equals (Integer .class )
175+ || SyntheticsAPISubtestStep .class .equals (Long .class )
176+ || SyntheticsAPISubtestStep .class .equals (Float .class )
177+ || SyntheticsAPISubtestStep .class .equals (Double .class )
178+ || SyntheticsAPISubtestStep .class .equals (Boolean .class )
179+ || SyntheticsAPISubtestStep .class .equals (String .class )) {
180+ attemptParsing = typeCoercion ;
181+ if (!attemptParsing ) {
182+ attemptParsing |=
183+ ((SyntheticsAPISubtestStep .class .equals (Integer .class )
184+ || SyntheticsAPISubtestStep .class .equals (Long .class ))
185+ && token == JsonToken .VALUE_NUMBER_INT );
186+ attemptParsing |=
187+ ((SyntheticsAPISubtestStep .class .equals (Float .class )
188+ || SyntheticsAPISubtestStep .class .equals (Double .class ))
189+ && (token == JsonToken .VALUE_NUMBER_FLOAT
190+ || token == JsonToken .VALUE_NUMBER_INT ));
191+ attemptParsing |=
192+ (SyntheticsAPISubtestStep .class .equals (Boolean .class )
193+ && (token == JsonToken .VALUE_FALSE || token == JsonToken .VALUE_TRUE ));
194+ attemptParsing |=
195+ (SyntheticsAPISubtestStep .class .equals (String .class )
196+ && token == JsonToken .VALUE_STRING );
197+ }
198+ }
199+ if (attemptParsing ) {
200+ tmp = tree .traverse (jp .getCodec ()).readValueAs (SyntheticsAPISubtestStep .class );
201+ // TODO: there is no validation against JSON schema constraints
202+ // (min, max, enum, pattern...), this does not perform a strict JSON
203+ // validation, which means the 'match' count may be higher than it should be.
204+ if (!((SyntheticsAPISubtestStep ) tmp ).unparsed ) {
205+ deserialized = tmp ;
206+ match ++;
207+ }
208+ log .log (Level .FINER , "Input data matches schema 'SyntheticsAPISubtestStep'" );
209+ }
210+ } catch (Exception e ) {
211+ // deserialization failed, continue
212+ log .log (Level .FINER , "Input data does not match schema 'SyntheticsAPISubtestStep'" , e );
213+ }
214+
170215 SyntheticsAPIStep ret = new SyntheticsAPIStep ();
171216 if (match == 1 ) {
172217 ret .setActualInstance (deserialized );
@@ -205,9 +250,15 @@ public SyntheticsAPIStep(SyntheticsAPIWaitStep o) {
205250 setActualInstance (o );
206251 }
207252
253+ public SyntheticsAPIStep (SyntheticsAPISubtestStep o ) {
254+ super ("oneOf" , Boolean .FALSE );
255+ setActualInstance (o );
256+ }
257+
208258 static {
209259 schemas .put ("SyntheticsAPITestStep" , new GenericType <SyntheticsAPITestStep >() {});
210260 schemas .put ("SyntheticsAPIWaitStep" , new GenericType <SyntheticsAPIWaitStep >() {});
261+ schemas .put ("SyntheticsAPISubtestStep" , new GenericType <SyntheticsAPISubtestStep >() {});
211262 JSON .registerDescendants (SyntheticsAPIStep .class , Collections .unmodifiableMap (schemas ));
212263 }
213264
@@ -218,7 +269,8 @@ public Map<String, GenericType> getSchemas() {
218269
219270 /**
220271 * Set the instance that matches the oneOf child schema, check the instance parameter is valid
221- * against the oneOf child schemas: SyntheticsAPITestStep, SyntheticsAPIWaitStep
272+ * against the oneOf child schemas: SyntheticsAPITestStep, SyntheticsAPIWaitStep,
273+ * SyntheticsAPISubtestStep
222274 *
223275 * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
224276 * composed schema (allOf, anyOf, oneOf).
@@ -233,20 +285,26 @@ public void setActualInstance(Object instance) {
233285 super .setActualInstance (instance );
234286 return ;
235287 }
288+ if (JSON .isInstanceOf (SyntheticsAPISubtestStep .class , instance , new HashSet <Class <?>>())) {
289+ super .setActualInstance (instance );
290+ return ;
291+ }
236292
237293 if (JSON .isInstanceOf (UnparsedObject .class , instance , new HashSet <Class <?>>())) {
238294 super .setActualInstance (instance );
239295 return ;
240296 }
241297 throw new RuntimeException (
242- "Invalid instance type. Must be SyntheticsAPITestStep, SyntheticsAPIWaitStep" );
298+ "Invalid instance type. Must be SyntheticsAPITestStep, SyntheticsAPIWaitStep,"
299+ + " SyntheticsAPISubtestStep" );
243300 }
244301
245302 /**
246303 * Get the actual instance, which can be the following: SyntheticsAPITestStep,
247- * SyntheticsAPIWaitStep
304+ * SyntheticsAPIWaitStep, SyntheticsAPISubtestStep
248305 *
249- * @return The actual instance (SyntheticsAPITestStep, SyntheticsAPIWaitStep)
306+ * @return The actual instance (SyntheticsAPITestStep, SyntheticsAPIWaitStep,
307+ * SyntheticsAPISubtestStep)
250308 */
251309 @ Override
252310 public Object getActualInstance () {
@@ -274,4 +332,15 @@ public SyntheticsAPITestStep getSyntheticsAPITestStep() throws ClassCastExceptio
274332 public SyntheticsAPIWaitStep getSyntheticsAPIWaitStep () throws ClassCastException {
275333 return (SyntheticsAPIWaitStep ) super .getActualInstance ();
276334 }
335+
336+ /**
337+ * Get the actual instance of `SyntheticsAPISubtestStep`. If the actual instance is not
338+ * `SyntheticsAPISubtestStep`, the ClassCastException will be thrown.
339+ *
340+ * @return The actual instance of `SyntheticsAPISubtestStep`
341+ * @throws ClassCastException if the instance is not `SyntheticsAPISubtestStep`
342+ */
343+ public SyntheticsAPISubtestStep getSyntheticsAPISubtestStep () throws ClassCastException {
344+ return (SyntheticsAPISubtestStep ) super .getActualInstance ();
345+ }
277346}
0 commit comments