Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Commit 75fe13e

Browse files
committed
Adapted the comments
1 parent 47fa34a commit 75fe13e

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/OpenAPIDeserializer.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,13 +1968,18 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
19681968
if(location.startsWith("paths")){
19691969
try{
19701970
String components[]=ref.asText().split("#/components");
1971-
String [] childComponents=components[1].split("/");
1972-
String[] newChildComponents = Arrays.copyOfRange(childComponents, 1, childComponents.length);
1973-
boolean isValidComponent= ReferenceValidator.valueOf(newChildComponents[0]).validateComponent(this.components,newChildComponents[1]);
1974-
if(!isValidComponent){
1975-
result.missing(location,ref.asText());
1971+
if((ref.asText().startsWith("#/components"))&&(components.length>1)) {
1972+
String[] childComponents = components[1].split("/");
1973+
String[] newChildComponents = Arrays.copyOfRange(childComponents, 1, childComponents.length);
1974+
boolean isValidComponent = ReferenceValidator.valueOf(newChildComponents[0])
1975+
.validateComponent(this.components,
1976+
newChildComponents[1]);
1977+
if (!isValidComponent) {
1978+
result.missing(location, ref.asText());
1979+
}
19761980
}
19771981
}catch (Exception e){
1982+
result.missing(location, ref.asText());
19781983
}
19791984
}
19801985

modules/swagger-parser/src/test/java/io/swagger/parser/OpenAPIParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void testIssue934() {
100100
SwaggerParseResult result = new OpenAPIParser().readLocation("issue-934.yaml", null, null);
101101

102102
assertNotNull(result);
103-
assertEquals(result.getMessages().size(),2);
103+
assertEquals(result.getMessages().size(),1);
104104
assertNotNull(result.getOpenAPI());
105105
assertEquals(result.getOpenAPI().getOpenapi(), "3.0.1");
106106
}

modules/swagger-parser/src/test/resources/issue-934.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ paths:
5252
content:
5353
application/json:
5454
schema:
55-
$ref: "#/components/schemas/Error"
55+
$ref: "#/components/schemas/Pets"
5656
/pets/{petId}:
5757
get:
5858
summary: Info for a specific pet
@@ -78,7 +78,7 @@ paths:
7878
content:
7979
application/json:
8080
schema:
81-
$ref: "#/components/schemas/secureStrategies"
81+
$ref: './issue749-reference.yaml#/SomeId'
8282
components:
8383
schemas:
8484
Pet:

0 commit comments

Comments
 (0)