@@ -138,7 +138,7 @@ public class OpenAPIDeserializer {
138
138
// TODO use a map instead for 3.0 and 3.1. Care about compatibility
139
139
protected static Set <String > ROOT_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("openapi" , "info" , "servers" , "paths" ,
140
140
"components" , "security" , "tags" , "externalDocs" , "webhooks" ));
141
- protected static Set <String > INFO_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("title" , "description" , "termsOfService"
141
+ protected static Set <String > INFO_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("title" ,"summary" , "description" , "termsOfService"
142
142
, "contact" , "license" , "version" ));
143
143
protected static Set <String > CONTACT_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("name" , "url" , "email" ));
144
144
protected static Set <String > LICENSE_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("name" , "url" , "identifier" ));
@@ -163,7 +163,7 @@ public class OpenAPIDeserializer {
163
163
protected static Set <String > SECURITY_SCHEME_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("$ref" , "type" , "name" , "in"
164
164
, "description" , "flows" , "scheme" , "bearerFormat" , "openIdConnectUrl" ));
165
165
protected static Set <String > EXTERNAL_DOCS_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("description" , "url" ));
166
- protected static Set <String > COMPONENTS_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("schemas" , "responses" ,
166
+ protected static Set <String > COMPONENTS_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("schemas" , "responses" , "pathItems" ,
167
167
"parameters" , "examples" , "requestBodies" , "headers" , "securitySchemes" , "links" , "callbacks" ));
168
168
protected static Set <String > SCHEMA_KEYS_31 = new LinkedHashSet <>(Arrays .asList ("$ref" , "title" , "multipleOf" ,
169
169
"maximum" , "format" , "exclusiveMaximum" , "minimum" , "exclusiveMinimum" , "maxLength" , "minLength" ,
@@ -463,6 +463,12 @@ public Components getComponents(ObjectNode obj, String location, ParseResult res
463
463
components .setResponses (getResponses (node , String .format ("%s.%s" , location , "responses" ), result ,
464
464
true ));
465
465
}
466
+ if (result .isOpenapi31 ()){
467
+ node = getObject ("pathItems" , obj , false , location , result );
468
+ if (node != null ) {
469
+ components .setPathItems (getPathItems (node , String .format ("%s.%s" , location , "pathItems" ), result , true ));
470
+ }
471
+ }
466
472
467
473
node = getObject ("parameters" , obj , false , location , result );
468
474
if (node != null ) {
@@ -758,6 +764,29 @@ public Paths getPaths(ObjectNode obj, String location, ParseResult result) {
758
764
return null ;
759
765
}
760
766
767
+ public Map <String , PathItem > getPathItems (ObjectNode node , String location , ParseResult result ,
768
+ boolean underComponents ) {
769
+ if (node == null ) {
770
+ return null ;
771
+ }
772
+ Map <String , PathItem > pathItems = new LinkedHashMap <>();
773
+ Set <String > keys = getKeys (node );
774
+ for (String key : keys ) {
775
+ if (underComponents ) {
776
+ if (!Pattern .matches ("^[a-zA-Z0-9\\ .\\ -_]+$" ,
777
+ key )) {
778
+ result .warning (location , "PathItem key " + key + " doesn't adhere to regular expression " +
779
+ "^[a-zA-Z0-9\\ .\\ -_]+$" );
780
+ }
781
+ }
782
+ PathItem pathItem = getPathItem ((ObjectNode ) node .get (key ), location , result );
783
+ if (pathItem != null ) {
784
+ pathItems .put (key , pathItem );
785
+ }
786
+ }
787
+ return pathItems ;
788
+ }
789
+
761
790
//Webhooks
762
791
public Map <String , PathItem > getWebhooks (ObjectNode obj , String location , ParseResult result ) {
763
792
final Map <String , PathItem > webhooks = new LinkedHashMap <>();
@@ -1104,6 +1133,13 @@ public Info getInfo(ObjectNode node, String location, ParseResult result) {
1104
1133
info .setDescription (value );
1105
1134
}
1106
1135
1136
+ if (result .isOpenapi31 ()) {
1137
+ value = getString ("summary" , node , false , location , result );
1138
+ if (StringUtils .isNotBlank (value )) {
1139
+ info .setSummary (value );
1140
+ }
1141
+ }
1142
+
1107
1143
value = getString ("termsOfService" , node , false , location , result );
1108
1144
if ((result .isAllowEmptyStrings () && value != null ) || (!result .isAllowEmptyStrings () && !StringUtils .isBlank (value ))) {
1109
1145
info .setTermsOfService (value );
@@ -1491,6 +1527,8 @@ private Map<String, String> getLinkParameters(ObjectNode parametersObject, Strin
1491
1527
return linkParameters ;
1492
1528
}
1493
1529
1530
+
1531
+
1494
1532
public Map <String , Callback > getCallbacks (ObjectNode node , String location , ParseResult result ,
1495
1533
boolean underComponents ) {
1496
1534
if (node == null ) {
@@ -1514,6 +1552,7 @@ public Map<String, Callback> getCallbacks(ObjectNode node, String location, Pars
1514
1552
return callbacks ;
1515
1553
}
1516
1554
1555
+
1517
1556
public Callback getCallback (ObjectNode node , String location , ParseResult result ) {
1518
1557
if (node == null ) {
1519
1558
return null ;
@@ -2390,6 +2429,18 @@ public Discriminator getDiscriminator(ObjectNode node, String location, ParseRes
2390
2429
discriminator .setMapping (mapping );
2391
2430
}
2392
2431
2432
+ if (result .isOpenapi31 ()) {
2433
+ Set <String > keys = getKeys (node );
2434
+ for (String key : keys ) {
2435
+ if (key .startsWith ("x-" )) {
2436
+ Map <String , Object > extensions = getExtensions (node );
2437
+ if (extensions != null && extensions .size () > 0 ) {
2438
+ discriminator .setExtensions (extensions );
2439
+ }
2440
+ }
2441
+ }
2442
+ }
2443
+
2393
2444
return discriminator ;
2394
2445
2395
2446
}
0 commit comments