@@ -401,11 +401,15 @@ private void handlePrimitive(
401
401
Map <String , Object > testOutput ,
402
402
IJsonSchemaValidationProperties spec
403
403
) throws CTSException {
404
- inferDataType (param , null , testOutput );
405
- if (
406
- spec instanceof CodegenParameter && ((CodegenParameter ) spec ).isAnyType
407
- ) {
408
- testOutput .put ("isAnyType" , true );
404
+ if (isPrimitiveType (spec )) {
405
+ transferPrimitiveData (spec , testOutput );
406
+ } else {
407
+ inferDataType (param , null , testOutput );
408
+ if (
409
+ spec instanceof CodegenParameter && ((CodegenParameter ) spec ).isAnyType
410
+ ) {
411
+ testOutput .put ("isAnyType" , true );
412
+ }
409
413
}
410
414
testOutput .put ("value" , param );
411
415
}
@@ -439,6 +443,16 @@ private boolean isEnum(IJsonSchemaValidationProperties param) {
439
443
return false ;
440
444
}
441
445
446
+ private boolean isPrimitiveType (IJsonSchemaValidationProperties param ) {
447
+ if (param instanceof CodegenParameter ) {
448
+ return ((CodegenParameter ) param ).isPrimitiveType ;
449
+ }
450
+ if (param instanceof CodegenProperty ) {
451
+ return ((CodegenProperty ) param ).isPrimitiveType ;
452
+ }
453
+ return false ;
454
+ }
455
+
442
456
private String inferDataType (
443
457
Object param ,
444
458
CodegenParameter spec ,
@@ -472,6 +486,31 @@ private String inferDataType(
472
486
}
473
487
}
474
488
489
+ private void transferPrimitiveData (
490
+ IJsonSchemaValidationProperties spec ,
491
+ Map <String , Object > output
492
+ ) throws CTSException {
493
+ switch (getTypeName (spec )) {
494
+ case "String" :
495
+ output .put ("isString" , true );
496
+ break ;
497
+ case "Integer" :
498
+ output .put ("isInteger" , true );
499
+ break ;
500
+ case "Long" :
501
+ output .put ("isLong" , true );
502
+ break ;
503
+ case "Double" :
504
+ output .put ("isDouble" , true );
505
+ break ;
506
+ case "Boolean" :
507
+ output .put ("isBoolean" , true );
508
+ break ;
509
+ default :
510
+ throw new CTSException ("Unknown primitive: " + getTypeName (spec ));
511
+ }
512
+ }
513
+
475
514
private IJsonSchemaValidationProperties findMatchingOneOf (
476
515
Object param ,
477
516
CodegenModel model
0 commit comments