@@ -173,7 +173,7 @@ public class OpenAPIDeserializer {
173
173
"allOf" ,
174
174
"oneOf" , "anyOf" , "not" , "items" , "properties" , "additionalProperties" , "patternProperties" , "description" ,
175
175
"format" , "default" , "discriminator" , "readOnly" , "writeOnly" , "xml" , "externalDocs" , "example" , "deprecated" ,
176
- "const" ));
176
+ "const" , "examples" , "$id" , "$comment" ));
177
177
protected static Set <String > EXAMPLE_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("$ref" , "summary" , "description" ,
178
178
"value" , "externalValue" ));
179
179
protected static Set <String > HEADER_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("$ref" , "name" , "in" , "description" ,
@@ -572,8 +572,6 @@ public Components getComponents(ObjectNode obj, String location, ParseResult res
572
572
validateReservedKeywords (specKeys , key , location , result );
573
573
574
574
}
575
-
576
-
577
575
return components ;
578
576
}
579
577
@@ -2900,12 +2898,6 @@ at the moment path passed as string (basePath) from upper components can be both
2900
2898
}
2901
2899
}
2902
2900
2903
-
2904
- bool = getBoolean ("nullable" , node , false , location , result );
2905
- if (bool != null ) {
2906
- schema .setNullable (bool );
2907
- }
2908
-
2909
2901
bool = getBoolean ("readOnly" , node , false , location , result );
2910
2902
if (bool != null ) {
2911
2903
schema .setReadOnly (bool );
@@ -3420,8 +3412,6 @@ public Operation getOperation(ObjectNode obj, String location, ParseResult resul
3420
3412
}
3421
3413
validateReservedKeywords (specKeys , key , location , result );
3422
3414
}
3423
-
3424
-
3425
3415
return operation ;
3426
3416
}
3427
3417
@@ -3558,7 +3548,6 @@ public RequestBody getRequestBody(ObjectNode node, String location, ParseResult
3558
3548
}
3559
3549
validateReservedKeywords (specKeys , key , location , result );
3560
3550
}
3561
-
3562
3551
return body ;
3563
3552
}
3564
3553
@@ -3852,9 +3841,8 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
3852
3841
result .invalidType (location , "required" , "string" , n );
3853
3842
}
3854
3843
}
3855
- if (requiredList .size () > 0 ) {
3856
- schema .setRequired (requiredList );
3857
- }
3844
+ schema .setRequired (requiredList );
3845
+
3858
3846
}
3859
3847
3860
3848
@@ -3885,18 +3873,12 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
3885
3873
schema .addType (type );
3886
3874
}
3887
3875
}
3888
- if (schema .getTypes () != null &&
3889
- schema .getTypes ().size () == 1 &&
3890
- "array" .equals (schema .getTypes ().toArray ()[0 ]) && schema .getItems () == null ) {
3891
- result .missing (location , "items" );
3892
- }
3893
3876
3894
3877
value = getString ("format" , node , false , location , result );
3895
- if (StringUtils . isNotBlank ( value ) ) {
3878
+ if (value != null ) {
3896
3879
schema .setFormat (value );
3897
3880
}
3898
3881
3899
-
3900
3882
ArrayNode enumArray = getArray ("enum" , node , false , location , result );
3901
3883
if (enumArray != null ) {
3902
3884
for (JsonNode n : enumArray ) {
@@ -4089,48 +4071,6 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
4089
4071
schema .setDescription (value );
4090
4072
}
4091
4073
4092
- //sets default value according to the schema type
4093
- if (node .get ("default" ) != null ) {
4094
- if (!StringUtils .isBlank (schema .getType ())) {
4095
- if (schema .getType ().equals ("array" )) {
4096
- ArrayNode array = getArray ("default" , node , false , location , result );
4097
- if (array != null ) {
4098
- schema .setDefault (array );
4099
- }
4100
- } else if (schema .getType ().equals ("string" )) {
4101
- value = getString ("default" , node , false , location , result );
4102
- if (value != null ) {
4103
- try {
4104
- schema .setDefault (getDecodedObject (schema , value ));
4105
- } catch (ParseException e ) {
4106
- result .invalidType (location , String .format ("default=`%s`" , e .getMessage ()),
4107
- schema .getFormat (), node );
4108
- }
4109
- }
4110
- } else if (schema .getType ().equals ("boolean" )) {
4111
- bool = getBoolean ("default" , node , false , location , result );
4112
- if (bool != null ) {
4113
- schema .setDefault (bool );
4114
- }
4115
- } else if (schema .getType ().equals ("object" )) {
4116
- Object object = getObject ("default" , node , false , location , result );
4117
- if (object != null ) {
4118
- schema .setDefault (object );
4119
- }
4120
- } else if (schema .getType ().equals ("integer" )) {
4121
- Integer number = getInteger ("default" , node , false , location , result );
4122
- if (number != null ) {
4123
- schema .setDefault (number );
4124
- }
4125
- } else if (schema .getType ().equals ("number" )) {
4126
- BigDecimal number = getBigDecimal ("default" , node , false , location , result );
4127
- if (number != null ) {
4128
- schema .setDefault (number );
4129
- }
4130
- }
4131
- }
4132
- }
4133
-
4134
4074
//const is a String
4135
4075
value = getString ("const" , node , false , location , result );
4136
4076
if (value != null ) {
@@ -4228,13 +4168,13 @@ public Schema getJsonSchema(ObjectNode node, String location, ParseResult result
4228
4168
Set <String > schemaKeys = getKeys (node );
4229
4169
Map <String , Set <String >> specKeys = KEYS .get ("openapi31" );
4230
4170
for (String key : schemaKeys ) {
4171
+ validateReservedKeywords (specKeys , key , location , result );
4231
4172
if (!specKeys .get ("SCHEMA_KEYS" ).contains (key ) && !key .startsWith ("x-" )) {
4232
- result .extra (location , key , node .get (key ));
4173
+ extensions .put (key , Json .mapper ().convertValue (node .get (key ), Object .class ));
4174
+ schema .setExtensions (extensions );
4233
4175
}
4234
4176
}
4235
-
4236
4177
return schema ;
4237
-
4238
4178
}
4239
4179
4240
4180
public static class ParseResult {
0 commit comments