Skip to content

Commit aef028f

Browse files
authored
Merge pull request #1542 from kaewberg/master
external $ref without / caused exception
2 parents 575fa82 + 59a85a2 commit aef028f

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,21 @@ public void testDiscriminatorSeparateFileExternalMapping() throws Exception {
27542754
Assert.assertNotNull(cat);
27552755
}
27562756

2757+
2758+
// Relative external refs failed on windows due to \ issue
2759+
@Test
2760+
public void testRelativePathIssue1543() {
2761+
OpenAPIV3Parser parser = new OpenAPIV3Parser();
2762+
ParseOptions options = new ParseOptions();
2763+
options.setResolveFully(true);
2764+
options.setResolve(true);
2765+
SwaggerParseResult readResult = parser.readLocation("src/test/resources/issue-1543/openapi.yaml", null, options);
2766+
2767+
if (readResult.getMessages().size() > 0) {
2768+
Assert.assertFalse(readResult.getMessages().get(0).contains("end -1"));
2769+
}
2770+
}
2771+
27572772
@Test
27582773
public void testIssue1540() throws Exception{
27592774
OpenAPI openAPI = new OpenAPIV3Parser().read("./issue-1540/a.json");
@@ -2768,5 +2783,4 @@ public void testIssue1540() throws Exception{
27682783
Assert.assertNotNull(testPutExtensions.get("x-order"));
27692784
Assert.assertEquals((String)testPutExtensions.get("x-order"),"2147483647");
27702785
}
2771-
27722786
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Innotech API backend
4+
description: >
5+
API for the Innotech backend
6+
version: 1.0.0
7+
8+
paths:
9+
10+
## Miscellaneous ###################################################################
11+
"/misc/ping":
12+
get:
13+
tags:
14+
- Ping
15+
operationId: getPing
16+
parameters:
17+
- in: query
18+
name: param
19+
schema:
20+
type: string
21+
maxLength: 255
22+
required: true
23+
responses:
24+
"200":
25+
description: Ping response
26+
content:
27+
application/json:
28+
schema:
29+
$ref: "schemas/_index.yaml#/pingResponse"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# schemas/PingResponse.yaml
2+
type: object
3+
properties:
4+
answer:
5+
type: string
6+
maxLength: 255
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# schemas/_index.yaml
2+
pingResponse:
3+
$ref: 'PingResponse.yaml'

0 commit comments

Comments
 (0)