Skip to content

Commit 6704e6c

Browse files
committed
ref swager-api/swagger-parser #342 checking for empty
1 parent e66b005 commit 6704e6c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.swagger.v3.oas.models.security.SecurityScheme;
1616
import io.swagger.v3.parser.ResolverCache;
1717
import io.swagger.v3.parser.models.RefFormat;
18+
import org.apache.commons.lang3.StringUtils;
1819
import org.slf4j.LoggerFactory;
1920

2021
import java.net.URI;
@@ -97,7 +98,8 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
9798
processRefProperty(prop.getValue(), file);
9899
} else if (prop.getValue() instanceof ArraySchema) {
99100
ArraySchema arrayProp = (ArraySchema) prop.getValue();
100-
if (arrayProp.getItems() != null && arrayProp.getItems().get$ref() != null) {
101+
if (arrayProp.getItems() != null && arrayProp.getItems().get$ref() != null &&
102+
StringUtils.isNotBlank(arrayProp.get$ref())) {
101103
processRefProperty(arrayProp.getItems(), file);
102104
}
103105
} else if (prop.getValue().getAdditionalProperties() != null) {
@@ -106,7 +108,8 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
106108
processRefProperty(mapProp.getAdditionalProperties(), file);
107109
} else if (mapProp.getAdditionalProperties() instanceof ArraySchema &&
108110
((ArraySchema) mapProp.getAdditionalProperties()).getItems()!= null &&
109-
((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref() != null) {
111+
((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref() != null
112+
&& StringUtils.isNotBlank(((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref())) {
110113
processRefProperty(((ArraySchema) mapProp.getAdditionalProperties()).getItems(), file);
111114
}
112115
}
@@ -118,7 +121,8 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
118121
processRefProperty(additionalProperty, file);
119122
} else if (additionalProperty instanceof ArraySchema) {
120123
ArraySchema arrayProp = (ArraySchema) additionalProperty;
121-
if (arrayProp.getItems() != null && arrayProp.getItems().get$ref() != null) {
124+
if (arrayProp.getItems() != null && arrayProp.getItems().get$ref() != null &&
125+
StringUtils.isNotBlank(arrayProp.get$ref())) {
122126
processRefProperty(arrayProp.getItems(), file);
123127
}
124128
} else if (additionalProperty.getAdditionalProperties() != null) {
@@ -127,13 +131,15 @@ public String processRefToExternalSchema(String $ref, RefFormat refFormat) {
127131
processRefProperty(mapProp.getAdditionalProperties(), file);
128132
} else if (mapProp.getAdditionalProperties() instanceof ArraySchema &&
129133
((ArraySchema) mapProp.getAdditionalProperties()).getItems() != null &&
130-
((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref() != null) {
134+
((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref() != null
135+
&& StringUtils.isNotBlank(((ArraySchema) mapProp.getAdditionalProperties()).getItems().get$ref())) {
131136
processRefProperty(((ArraySchema) mapProp.getAdditionalProperties()).getItems(), file);
132137
}
133138
}
134139

135140
}
136-
if (schema instanceof ArraySchema && ((ArraySchema) schema).getItems() != null && ((ArraySchema) schema).getItems().get$ref() != null) {
141+
if (schema instanceof ArraySchema && ((ArraySchema) schema).getItems() != null && ((ArraySchema) schema).getItems().get$ref() != null
142+
&& StringUtils.isNotBlank(((ArraySchema) schema).getItems().get$ref())) {
137143
processRefProperty(((ArraySchema) schema).getItems(), file);
138144
}
139145
}

0 commit comments

Comments
 (0)