Skip to content

Commit da0c7a6

Browse files
Merge branch 'master' into fix-for-mixed-and-upper-case-url
2 parents fdefaeb + 88709d5 commit da0c7a6

File tree

12 files changed

+284
-28
lines changed

12 files changed

+284
-28
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Code scanning - action"
1+
name: "CodeQL scanning - action"
22

33
on:
44
push:
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020
with:
2121
# We must fetch at least the immediate parents so that if this is
2222
# a pull request then we can checkout the head.
@@ -29,15 +29,15 @@ jobs:
2929

3030
# Initializes the CodeQL tools for scanning.
3131
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v1
32+
uses: github/codeql-action/init@v3
3333
# Override language selection by uncommenting this and choosing your languages
3434
with:
3535
languages: java
3636

3737
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3838
# If this step fails, then you should remove it and run the build manually (see below)
3939
- name: Autobuild
40-
uses: github/codeql-action/autobuild@v1
40+
uses: github/codeql-action/autobuild@v3
4141

4242
# ℹ️ Command-line programs to run using the OS shell.
4343
# 📚 https://git.io/JvXDl
@@ -51,4 +51,4 @@ jobs:
5151
# make release
5252

5353
- name: Perform CodeQL Analysis
54-
uses: github/codeql-action/analyze@v1
54+
uses: github/codeql-action/analyze@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
114114
<dependency>
115115
<groupId>io.swagger.parser.v3</groupId>
116116
<artifactId>swagger-parser</artifactId>
117-
<version>2.1.33</version>
117+
<version>2.1.34</version>
118118
</dependency>
119119
```
120120

modules/swagger-parser-cli/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>swagger-parser-project</artifactId>
77
<groupId>io.swagger.parser.v3</groupId>
8-
<version>2.1.34-SNAPSHOT</version>
8+
<version>2.1.35-SNAPSHOT</version>
99
<relativePath>../..</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
@@ -91,7 +91,7 @@
9191
<dependency>
9292
<groupId>io.swagger.parser.v3</groupId>
9393
<artifactId>swagger-parser-v3</artifactId>
94-
<version>2.1.34-SNAPSHOT</version>
94+
<version>2.1.35-SNAPSHOT</version>
9595
<scope>compile</scope>
9696
</dependency>
9797
<dependency>

modules/swagger-parser-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.1.34-SNAPSHOT</version>
6+
<version>2.1.35-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-safe-url-resolver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.swagger.parser.v3</groupId>
88
<artifactId>swagger-parser-project</artifactId>
9-
<version>2.1.34-SNAPSHOT</version>
9+
<version>2.1.35-SNAPSHOT</version>
1010
<relativePath>../../pom.xml</relativePath>
1111

1212
</parent>

modules/swagger-parser-v2-converter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.1.34-SNAPSHOT</version>
6+
<version>2.1.35-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v3/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.1.34-SNAPSHOT</version>
6+
<version>2.1.35-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue>
207207

208208
private SwaggerParseResult resolve(SwaggerParseResult result, List<AuthorizationValue> auth, ParseOptions options,
209209
String location) {
210+
if (location != null) {
211+
location = location.replace('\\', '/');
212+
}
210213
try {
211214
if (options != null) {
212215
if (options.isResolve() || options.isResolveFully()) {
@@ -284,7 +287,7 @@ private ObjectMapper getRightMapper(String data) {
284287
}
285288

286289
private String readContentFromLocation(String location, List<AuthorizationValue> auth) {
287-
final String adjustedLocation = location.replaceAll("\\\\", "/");
290+
final String adjustedLocation = location.replace('\\', '/');
288291
try {
289292
if (adjustedLocation.toLowerCase().startsWith("http")) {
290293
return RemoteUrl.urlToString(adjustedLocation, auth);

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343
public class OpenAPIV3ParserTest {
4444
List<AuthorizationValue> auths = new ArrayList<>();
4545

46+
@Test(description = "Issue 2223: reading 3.1 spec from Windows file path location produces URISyntaxException" )
47+
public void testWindowsFilePathRead() {
48+
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
49+
OpenAPI openAPI = openApiParser.read("\\issue-2223\\openapi.yaml");
50+
assertNotNull(openAPI, "OpenAPI object should not be null (no errors during read())");
51+
}
52+
4653
@Test
4754
public void testFailedToResolveResponseReferences() {
4855
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
@@ -51,7 +58,7 @@ public void testFailedToResolveResponseReferences() {
5158
SwaggerParseResult parseResult = openApiParser.readLocation("issue-2037/openapi.yaml", null, options);
5259
OpenAPI openAPI = parseResult.getOpenAPI();
5360

54-
Assert.assertTrue(openAPI.getPaths().get("/get").get$ref() == null);
61+
assertNull(openAPI.getPaths().get("/get").get$ref());
5562
Assert.assertEquals(openAPI.getPaths().get("/get").getGet().getResponses().get("200").getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/ResponsesRef");
5663
}
5764

@@ -64,13 +71,13 @@ public void testFailedToResolveExternalReferences() {
6471
SwaggerParseResult parseResult = openApiParser.readLocation("resolve-external-ref/failedToResolveExternalRefs.yaml", null, options);
6572
OpenAPI openAPI = parseResult.getOpenAPI();
6673

67-
Assert.assertTrue(openAPI.getPaths().get("/permAssignments").get$ref() == null);
68-
Assert.assertEquals(openAPI.getPaths().get("/permAssignments").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess");
69-
Assert.assertTrue(openAPI.getPaths().get("/permAssignmentChangeRequests").get$ref() == null);
70-
Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChangeRequests").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess");
71-
Assert.assertTrue(openAPI.getPaths().get("/permAssignmentChange").get$ref() == null);
72-
Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("201").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/Error");
73-
Assert.assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("404").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/RemoteError");
74+
assertNull(openAPI.getPaths().get("/permAssignments").get$ref());
75+
assertEquals(openAPI.getPaths().get("/permAssignments").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess");
76+
assertNull(openAPI.getPaths().get("/permAssignmentChangeRequests").get$ref());
77+
assertEquals(openAPI.getPaths().get("/permAssignmentChangeRequests").getGet().getResponses().get("202").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/schemaResponseSuccess");
78+
assertNull(openAPI.getPaths().get("/permAssignmentChange").get$ref());
79+
assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("201").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/Error");
80+
assertEquals(openAPI.getPaths().get("/permAssignmentChange").getGet().getResponses().get("404").getContent().get("application/vnd.api+json").getSchema().get$ref(),"#/components/schemas/RemoteError");
7481

7582
}
7683

@@ -2188,7 +2195,7 @@ public void testIssue393() {
21882195
}
21892196

21902197
@Test
2191-
public void testBadFormat() throws Exception {
2198+
public void testBadFormat() {
21922199
OpenAPIV3Parser parser = new OpenAPIV3Parser();
21932200
final OpenAPI openAPI = parser.read("src/test/resources/bad_format.yaml");
21942201

@@ -3429,4 +3436,4 @@ public void testVersion(){
34293436
SwaggerParseResult parseResult = openApiParser.readLocation("version-missing.yaml", null, options);
34303437
assertEquals(parseResult.getMessages().get(0), "attribute info.version is missing");
34313438
}
3432-
}
3439+
}

0 commit comments

Comments
 (0)