Skip to content

Commit e31007f

Browse files
authored
Merge pull request #1718 from post-luxembourg/bug/issue1169-nosplit-v3
Bug/issue1169 nosplit v3
2 parents 9370bca + 80770b8 commit e31007f

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,12 @@ public Paths getPaths(ObjectNode obj, String location, ParseResult result) {
621621
}
622622
ObjectNode path = (ObjectNode) pathValue;
623623
PathItem pathObj = getPathItem(path, String.format("%s.'%s'", location, pathName), result);
624-
String[] eachPart = pathName.split("[-/.]+");
625-
Arrays.stream(eachPart)
626-
.filter(part -> part.startsWith("{") && part.endsWith("}") && part.length() > 2)
624+
List<String> eachPart = new ArrayList<>();
625+
Matcher m = Pattern.compile("\\{(.+?)\\}").matcher(pathName);
626+
while (m.find()) {
627+
eachPart.add(m.group());
628+
}
629+
eachPart.stream()
627630
.forEach(part -> {
628631
String pathParam = part.substring(1, part.length() - 1);
629632
boolean definedInPathLevel = isPathParamDefined(pathParam,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,18 @@ public void testIssue1169() {
806806
assertNotNull(apispec);
807807
}
808808

809+
@Test
810+
public void testIssue1169noSplit() {
811+
ParseOptions options = new ParseOptions();
812+
options.setResolve(true);
813+
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue1169-noSplit.yaml", null, options);
814+
assertTrue(parseResult.getMessages().size() == 0);
815+
OpenAPI apispec = parseResult.getOpenAPI();
816+
assertNotNull(apispec);
817+
}
818+
819+
820+
809821
@Test
810822
public void testIssue339() throws Exception {
811823
OpenAPIV3Parser openAPIV3Parser = new OpenAPIV3Parser();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Sample title
4+
version: 1.0.0
5+
servers:
6+
- url: /
7+
paths:
8+
/path_{p0}/{p1}{p2}/another-{p3}:
9+
put:
10+
parameters:
11+
- name: p0
12+
in: path
13+
required: true
14+
schema:
15+
type: string
16+
- name: p1
17+
in: path
18+
required: true
19+
schema:
20+
type: string
21+
- name: p2
22+
in: path
23+
required: true
24+
schema:
25+
type: string
26+
- name: p3
27+
in: path
28+
required: true
29+
schema:
30+
type: string
31+
responses:
32+
200:
33+
description: sample desc
34+
content: {}
35+
components: {}

0 commit comments

Comments
 (0)