@@ -446,6 +446,8 @@ private void addDefaultValueAndDescriptionAndConstraintIfAvailable(Property prop
446
446
addFormat (property , propertySchema );
447
447
addUniqueItems (property , propertySchema );
448
448
addInjections (property , propertySchema );
449
+ addTitle (property , propertySchema );
450
+ addPropertyOrder (property , propertySchema );
449
451
}
450
452
451
453
private void addDefaultValue (Property property , Map <String , Object > propertySchema ) {
@@ -523,27 +525,31 @@ private void addConstraint(Property property, Map<String, Object> propertySchema
523
525
524
526
private void addUniqueItems (Property property , Map <String , Object > propertySchema ) {
525
527
try {
526
- var uniqueItems = property .annotationByKey ("vmf:jackson:schema:uniqueItems" ).get ().getValue ();
527
- if (uniqueItems != null ) {
528
- propertySchema .put ("uniqueItems" , Boolean .parseBoolean (uniqueItems ));
528
+ var uniqueItemsOpt = property .annotationByKey ("vmf:jackson:schema:uniqueItems" );
529
+ if (uniqueItemsOpt .isPresent () && uniqueItemsOpt .get ().getValue () != null ) {
530
+ var uniqueItems = uniqueItemsOpt .get ().getValue ();
531
+ if (uniqueItems != null ) {
532
+ propertySchema .put ("uniqueItems" , Boolean .parseBoolean (uniqueItems ));
533
+ }
529
534
}
530
535
} catch (Exception e ) {
531
- // ignore, not possible to get default value
536
+ throw new RuntimeException ( "Failed to parse uniqueItems" , e );
532
537
}
533
538
}
534
539
535
540
private void addInjections (Property property , Map <String , Object > propertySchema ) {
536
541
try {
537
- var injections = property .annotationByKey ("vmf:jackson:schema:inject" ).get ().getValue ();
538
- if (injections != null ) {
539
- System .out .println ("!!!injections: " + injections );
540
- // inject json into schema by parsing it and adding it to the schema
541
- var injectionsMap = new ObjectMapper ().readValue ("{" +injections +"}" , Map .class );
542
- propertySchema .putAll (injectionsMap );
542
+ var injectionsOpt = property .annotationByKey ("vmf:jackson:schema:inject" );
543
+ if (injectionsOpt .isPresent () && injectionsOpt .get ().getValue () != null ) {
544
+ var injections = injectionsOpt .get ().getValue ();
545
+ if (injections != null ) {
546
+ // inject json into schema by parsing it and adding it to the schema
547
+ var injectionsMap = new ObjectMapper ().readValue ("{" + injections + "}" , Map .class );
548
+ propertySchema .putAll (injectionsMap );
549
+ }
543
550
}
544
551
} catch (Exception e ) {
545
- // ignore, not possible to get default value
546
- e .printStackTrace ();
552
+ throw new RuntimeException ("Failed to parse injection JSON" , e );
547
553
}
548
554
}
549
555
@@ -557,4 +563,30 @@ private void addFormat(Property property, Map<String, Object> propertySchema) {
557
563
// ignore, not possible to get default value
558
564
}
559
565
}
566
+
567
+ private void addTitle (Property property , Map <String , Object > propertySchema ) {
568
+ try {
569
+ var title = property .annotationByKey ("vmf:jackson:schema:title" ).get ().getValue ();
570
+ if (title != null ) {
571
+ propertySchema .put ("title" , title );
572
+ }
573
+ } catch (Exception e ) {
574
+ // ignore, not possible to get default value
575
+ }
576
+ }
577
+
578
+ private void addPropertyOrder (Property property , Map <String , Object > propertySchema ) {
579
+ // order is an integer value that specifies the order of the property in the schema
580
+ try {
581
+ var orderOpt = property .annotationByKey ("vmf:jackson:schema:propertyOrder" );
582
+ if (orderOpt .isPresent () && orderOpt .get ().getValue () != null ) {
583
+ var order = orderOpt .get ().getValue ();
584
+ if (order != null ) {
585
+ propertySchema .put ("propertyOrder" , Integer .parseInt (order ));
586
+ }
587
+ }
588
+ } catch (Exception e ) {
589
+ throw new RuntimeException ("Failed to parse property order" , e );
590
+ }
591
+ }
560
592
}
0 commit comments