@@ -3710,6 +3710,29 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
3710
3710
schema .setAdditionalProperties (additionalProperties );
3711
3711
}
3712
3712
3713
+ Boolean unevaluatedPropertiesBoolean = getBoolean ("unevaluatedProperties" , node , false , location , result );
3714
+
3715
+ ObjectNode unevaluatedPropertiesObject =
3716
+ additionalPropertiesBoolean == null
3717
+ ? getObject ("unevaluatedProperties" , node , false , location , result )
3718
+ : null ;
3719
+
3720
+ Object unevaluatedProperties =
3721
+ unevaluatedPropertiesObject != null
3722
+ ? getSchema (unevaluatedPropertiesObject , location , result )
3723
+ : unevaluatedPropertiesBoolean ;
3724
+
3725
+ if (unevaluatedProperties != null ) {
3726
+ if (schema == null ) {
3727
+ schema =
3728
+ unevaluatedProperties .equals (Boolean .FALSE )
3729
+ ? new ObjectSchema ()
3730
+ : new Schema ();
3731
+ }
3732
+ //TODO change the unevaluatedProperties Field in core oas 3.1
3733
+ // schema.setUnevaluatedProperties(unevaluatedProperties);
3734
+ }
3735
+
3713
3736
if (schema == null ) {
3714
3737
schema = new Schema ();
3715
3738
}
@@ -3827,6 +3850,16 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
3827
3850
schema .setMinProperties (integer );
3828
3851
}
3829
3852
3853
+ integer = getInteger ("minContains" , node , false , location , result );
3854
+ if (integer != null ) {
3855
+ schema .setMinContains (integer );
3856
+ }
3857
+
3858
+ integer = getInteger ("maxContains" , node , false , location , result );
3859
+ if (integer != null ) {
3860
+ schema .setMaxContains (integer );
3861
+ }
3862
+
3830
3863
ArrayNode required = getArray ("required" , node , false , location , result );
3831
3864
if (required != null ) {
3832
3865
List <String > requiredList = new ArrayList <>();
@@ -3912,6 +3945,115 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
3912
3945
}
3913
3946
}
3914
3947
3948
+ ObjectNode contentSchemaObj = getObject ("contentSchema" , node , false , location , result );
3949
+ if (contentSchemaObj != null ) {
3950
+ Schema contentSchema = getJsonSchema (contentSchemaObj , location , result );
3951
+ if (contentSchema != null ) {
3952
+ schema .setContentSchema (contentSchema );
3953
+ }
3954
+ }
3955
+
3956
+ ObjectNode propertyNamesObj = getObject ("propertyNames" , node , false , location , result );
3957
+ if (propertyNamesObj != null ) {
3958
+ Schema propertyNames = getJsonSchema (propertyNamesObj , location , result );
3959
+ if (propertyNames != null ) {
3960
+ schema .setPropertyNames (propertyNames );
3961
+ }
3962
+ }
3963
+
3964
+ ObjectNode ifObj = getObject ("if" , node , false , location , result );
3965
+ if (ifObj != null ) {
3966
+ Schema _if = getJsonSchema (ifObj , location , result );
3967
+ if (_if != null ) {
3968
+ schema .setIf (_if );
3969
+ }
3970
+ }
3971
+
3972
+ ObjectNode thenObj = getObject ("then" , node , false , location , result );
3973
+ if (thenObj != null ) {
3974
+ Schema _then = getJsonSchema (thenObj , location , result );
3975
+ if (_then != null ) {
3976
+ schema .setThen (_then );
3977
+ }
3978
+ }
3979
+
3980
+ ObjectNode elseObj = getObject ("else" , node , false , location , result );
3981
+ if (elseObj != null ) {
3982
+ Schema _else = getJsonSchema (elseObj , location , result );
3983
+ if (_else != null ) {
3984
+ schema .setElse (_else );
3985
+ }
3986
+ }
3987
+
3988
+ Map <String , Schema > dependentRequiredList = new LinkedHashMap <>();
3989
+ ObjectNode dependentRequiredObj = getObject ("dependentRequired" , node , false , location , result );
3990
+ Schema dependentRequired = null ;
3991
+
3992
+ Set <String > dependentRequiredKeys = getKeys (dependentRequiredObj );
3993
+ for (String name : dependentRequiredKeys ) {
3994
+ JsonNode dependentRequiredValue = dependentRequiredObj .get (name );
3995
+ if (!dependentRequiredValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
3996
+ result .invalidType (location , "dependentRequired" , "object" , dependentRequiredValue );
3997
+ } else {
3998
+ if (dependentRequiredObj != null ) {
3999
+ dependentRequired = getJsonSchema ((ObjectNode ) dependentRequiredValue , location , result );
4000
+ if (dependentRequired != null ) {
4001
+ dependentRequiredList .put (name , dependentRequired );
4002
+ }
4003
+ }
4004
+ }
4005
+ }
4006
+ if (dependentRequiredObj != null ) {
4007
+ schema .setDependentRequired (dependentRequiredList );
4008
+ }
4009
+
4010
+ Map <String , Schema > dependentSchemasList = new LinkedHashMap <>();
4011
+ ObjectNode dependentSchemasObj = getObject ("dependentSchemas" , node , false , location , result );
4012
+ Schema dependentSchemas = null ;
4013
+
4014
+ Set <String > dependentSchemasKeys = getKeys (dependentSchemasObj );
4015
+ for (String name : dependentSchemasKeys ) {
4016
+ JsonNode dependentSchemasValue = dependentSchemasObj .get (name );
4017
+ if (!dependentSchemasValue .getNodeType ().equals (JsonNodeType .OBJECT )) {
4018
+ result .invalidType (location , "dependentSchemas" , "object" , dependentSchemasValue );
4019
+ } else {
4020
+ if (dependentSchemasObj != null ) {
4021
+ dependentSchemas = getJsonSchema ((ObjectNode ) dependentSchemasValue , location , result );
4022
+ if (dependentSchemas != null ) {
4023
+ dependentSchemasList .put (name , dependentSchemas );
4024
+ }
4025
+ }
4026
+ }
4027
+ }
4028
+ if (dependentSchemasObj != null ) {
4029
+ schema .setDependentSchemas (dependentSchemasList );
4030
+ }
4031
+
4032
+ //prefixItems
4033
+ ArrayNode prefixItemsArray = getArray ("prefixItems" , node , false , location , result );
4034
+
4035
+ if (prefixItemsArray != null ) {
4036
+ Schema prefixItems = new Schema ();
4037
+
4038
+ List <Schema > prefixItemsList = new ArrayList <>();
4039
+ for (JsonNode n : prefixItemsArray ) {
4040
+ if (n .isObject ()) {
4041
+ prefixItems = getJsonSchema ((ObjectNode ) n , location , result );
4042
+ prefixItemsList .add (prefixItems );
4043
+ }
4044
+ }
4045
+ if (prefixItemsList .size () > 0 ) {
4046
+ schema .setPrefixItems (prefixItemsList );
4047
+ }
4048
+ }
4049
+
4050
+ ObjectNode containsObj = getObject ("contains" , node , false , location , result );
4051
+ if (containsObj != null ) {
4052
+ Schema contains = getJsonSchema (containsObj , location , result );
4053
+ if (contains != null ) {
4054
+ schema .setContains (contains );
4055
+ }
4056
+ }
3915
4057
3916
4058
Map <String , Schema > properties = new LinkedHashMap <>();
3917
4059
ObjectNode propertiesObj = getObject ("properties" , node , false , location , result );
@@ -4052,6 +4194,12 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
4052
4194
schema .setExternalDocs (docs );
4053
4195
}
4054
4196
}
4197
+ //examples
4198
+ ArrayNode examples = getArray ("examples" , node ,false , location , result );
4199
+ List <Example > exampleList = getExampleList (examples , location , result );
4200
+ if (exampleList .size () > 0 ){
4201
+ schema .setExamples (exampleList );
4202
+ }
4055
4203
4056
4204
Object example = getAnyExample ("example" , node , location , result );
4057
4205
if (example != null ) {
0 commit comments