Skip to content

Commit 1cec1b8

Browse files
committed
Add failing test for extra slashes in URL
1 parent 99f1fdd commit 1cec1b8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public class V2ConverterTest {
9090
private static final String ISSUE_768_JSON = "issue-786.json";
9191
private static final String ISSUE_820_YAML = "issue-820.yaml";
9292
private static final String ISSUE_1032_YAML = "issue-1032.yaml";
93+
private static final String ISSUE_1113_YAML = "issue-1113.yaml";
9394

9495
private static final String API_BATCH_PATH = "/api/batch/";
9596
private static final String PETS_PATH = "/pets";
@@ -779,6 +780,16 @@ public void testIssue1032() throws Exception {
779780
assertEquals(INTEGER_TYPE, integerSchema.getType());
780781
assertEquals(INT64_FORMAT, integerSchema.getFormat());
781782
}
783+
784+
@Test(description = "OpenAPI v2 converter - parses URL correctly when no schemas are present")
785+
public void testIssue1113() throws Exception {
786+
final OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_1113_YAML);
787+
assertNotNull(oas);
788+
assertNotNull(oas.getServers());
789+
assertFalse(oas.getServers().isEmpty());
790+
assertNotNull(oas.getServers().get(0));
791+
assertEquals(oas.getServers().get(0).getUrl(), "/test");
792+
}
782793

783794
private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException {
784795
SwaggerConverter converter = new SwaggerConverter();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
swagger: '2.0'
2+
info:
3+
title: Test for Issue 1113
4+
version: 1.0.0
5+
basePath: /test
6+
paths:
7+
/ping:
8+
get:
9+
summary: test
10+
description: 'test'
11+
operationId: pingOp
12+
responses:
13+
'200':
14+
description: OK

0 commit comments

Comments
 (0)