@@ -267,21 +267,26 @@ public class OpenAPIDeserializer {
267
267
private final Set <String > operationIDs = new HashSet <>();
268
268
private Map <String ,String > localSchemaRefs = new HashMap <>();
269
269
270
- public SwaggerParseResult deserialize (JsonNode rootNode ) {
271
- return deserialize (rootNode , null );
270
+ public SwaggerParseResult deserialize (JsonNode rootNode ) {
271
+ return deserialize (rootNode , null , false );
272
272
}
273
273
274
274
public SwaggerParseResult deserialize (JsonNode rootNode , String path ) {
275
275
return deserialize (rootNode ,path , new ParseOptions ());
276
276
}
277
277
278
278
public SwaggerParseResult deserialize (JsonNode rootNode , String path , ParseOptions options ) {
279
+ return deserialize (rootNode ,path , new ParseOptions (), false );
280
+ }
281
+
282
+ public SwaggerParseResult deserialize (JsonNode rootNode , String path , ParseOptions options , boolean isOaiAuthor ) {
279
283
basePath = path ;
280
284
this .rootNode = rootNode ;
281
285
rootMap = new ObjectMapper ().convertValue (rootNode , Map .class );
282
286
SwaggerParseResult result = new SwaggerParseResult ();
283
287
try {
284
288
ParseResult rootParse = new ParseResult ();
289
+ rootParse .setOaiAuthor (isOaiAuthor );
285
290
rootParse .setAllowEmptyStrings (options .isAllowEmptyString ());
286
291
rootParse .setValidateInternalRefs (options .isValidateInternalRefs ());
287
292
OpenAPI api = parseRoot (rootNode , rootParse , path );
@@ -390,7 +395,11 @@ public OpenAPI parseRoot(JsonNode node, ParseResult result, String path) {
390
395
if (result .isOpenapi31 ()) {
391
396
value = getString ("jsonSchemaDialect" , rootNode , false , location , result );
392
397
if (value != null ) {
393
- openAPI .setJsonSchemaDialect (value );
398
+ if (isValidURL (value )) {
399
+ openAPI .setJsonSchemaDialect (value );
400
+ }else {
401
+ result .warning (location ,"jsonSchemaDialect. Invalid url: " + value );
402
+ }
394
403
}
395
404
}
396
405
@@ -413,12 +422,11 @@ public OpenAPI parseRoot(JsonNode node, ParseResult result, String path) {
413
422
result .invalid ();
414
423
return null ;
415
424
}
416
-
417
425
return openAPI ;
418
426
}
419
427
420
428
private void validateReservedKeywords (Map <String , Set <String >> specKeys , String key , String location , ParseResult result ) {
421
- if (result .isOpenapi31 () && specKeys .get ("RESERVED_KEYWORDS" ).stream ()
429
+ if (! result . isOaiAuthor () && result .isOpenapi31 () && specKeys .get ("RESERVED_KEYWORDS" ).stream ()
422
430
.filter (rk -> key .startsWith (rk ))
423
431
.findAny ()
424
432
.orElse (null ) != null ){
@@ -2246,9 +2254,9 @@ public SecurityScheme getSecurityScheme(ObjectNode node, String location, ParseR
2246
2254
}
2247
2255
2248
2256
boolean descriptionRequired , bearerFormatRequired , nameRequired , inRequired , schemeRequired , flowsRequired ,
2249
- openIdConnectRequired , mutualTLSRequired ;
2257
+ openIdConnectRequired ;
2250
2258
descriptionRequired = bearerFormatRequired = nameRequired = inRequired = schemeRequired = flowsRequired =
2251
- openIdConnectRequired = mutualTLSRequired = false ;
2259
+ openIdConnectRequired = false ;
2252
2260
2253
2261
String value = getString ("type" , node , true , location , result );
2254
2262
if ((result .isAllowEmptyStrings () && value != null ) || (!result .isAllowEmptyStrings () && !StringUtils .isBlank (value ))) {
@@ -2266,7 +2274,6 @@ public SecurityScheme getSecurityScheme(ObjectNode node, String location, ParseR
2266
2274
openIdConnectRequired = true ;
2267
2275
}else if (result .isOpenapi31 () && SecurityScheme .Type .MUTUALTLS .toString ().equals (value )) {
2268
2276
securityScheme .setType (SecurityScheme .Type .MUTUALTLS );
2269
- mutualTLSRequired = true ;
2270
2277
} else {
2271
2278
result .invalidType (location + ".type" , "type" , "http|apiKey|oauth2|openIdConnect|mutualTLS " , node );
2272
2279
}
@@ -2493,7 +2500,6 @@ public Discriminator getDiscriminator(ObjectNode node, String location, ParseRes
2493
2500
if (extensions != null && extensions .size () > 0 ) {
2494
2501
discriminator .setExtensions (extensions );
2495
2502
}
2496
- //validateReservedKeywords(keys,key, location, result);
2497
2503
}
2498
2504
}
2499
2505
}
@@ -2927,11 +2933,8 @@ at the moment path passed as string (basePath) from upper components can be both
2927
2933
if (!specKeys .get ("SCHEMA_KEYS" ).contains (key ) && !key .startsWith ("x-" )) {
2928
2934
result .extra (location , key , node .get (key ));
2929
2935
}
2930
- validateReservedKeywords (specKeys , key , location , result );
2931
2936
}
2932
-
2933
2937
return schema ;
2934
-
2935
2938
}
2936
2939
2937
2940
@@ -4042,6 +4045,7 @@ public static class ParseResult {
4042
4045
private boolean validateInternalRefs ;
4043
4046
4044
4047
private boolean openapi31 = false ;
4048
+ private boolean oaiAuthor = false ;
4045
4049
4046
4050
public ParseResult () {
4047
4051
}
@@ -4108,11 +4112,23 @@ public ParseResult openapi31(boolean openapi31) {
4108
4112
this .openapi31 = openapi31 ;
4109
4113
return this ;
4110
4114
}
4111
-
4112
4115
public boolean isOpenapi31 () {
4113
4116
return this .openapi31 ;
4114
4117
}
4115
4118
4119
+ public boolean isOaiAuthor () {
4120
+ return this .oaiAuthor ;
4121
+ }
4122
+
4123
+ public void setOaiAuthor (boolean oaiAuthor ) {
4124
+ this .oaiAuthor = oaiAuthor ;
4125
+ }
4126
+
4127
+ public ParseResult oaiAuthor (boolean oaiAuthor ) {
4128
+ this .oaiAuthor = oaiAuthor ;
4129
+ return this ;
4130
+ }
4131
+
4116
4132
public List <String > getMessages () {
4117
4133
List <String > messages = new ArrayList <String >();
4118
4134
for (Location l : extra .keySet ()) {
@@ -4152,7 +4168,7 @@ public List<String> getMessages() {
4152
4168
}
4153
4169
for (Location l : reserved ) {
4154
4170
String location = l .location .equals ("" ) ? "" : l .location + "." ;
4155
- String message = "attribute " + location + l .key + " is reserved by The OpenAPI Iniciative " ;
4171
+ String message = "attribute " + location + l .key + " is reserved by The OpenAPI Initiative " ;
4156
4172
messages .add (message );
4157
4173
}
4158
4174
return messages ;
0 commit comments