Skip to content

Commit 611531f

Browse files
committed
failing test for issues 901-913
1 parent b3e3908 commit 611531f

File tree

9 files changed

+188
-0
lines changed

9 files changed

+188
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,41 @@ public class OpenAPIV3ParserTest {
5757
protected WireMockServer wireMockServer;
5858

5959

60+
@Test
61+
public void testIssue913() {
62+
OpenAPIV3Parser parser = new OpenAPIV3Parser();
63+
ParseOptions options = new ParseOptions();
64+
options.setResolve(true);
65+
final OpenAPI openAPI = parser.readLocation("issue-913/BS/ApiSpecification.yaml", null, options).getOpenAPI();
66+
Yaml.prettyPrint(openAPI);
67+
Assert.assertNotNull(openAPI);
68+
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("indicatorType"));
69+
Assert.assertEquals(openAPI.getComponents().getSchemas().get("indicatorType").getProperties().size(),1);
70+
}
71+
72+
@Test
73+
public void testIssue901_2() {
74+
ParseOptions options = new ParseOptions();
75+
options.setResolve(true);
76+
OpenAPI openAPI = new OpenAPIV3Parser().readLocation("issue-901/spec2.yaml",null,options).getOpenAPI();
77+
assertNotNull(openAPI);
78+
String internalRef = openAPI.getPaths().get("/test").getPut().getResponses().get("200").getContent().get("application/json").getSchema().get$ref();
79+
assertEquals(internalRef,"#/components/schemas/Test.Definition");
80+
assertNotNull(openAPI.getComponents());
81+
82+
}
83+
84+
@Test
85+
public void testIssue901() {
86+
ParseOptions options = new ParseOptions();
87+
options.setResolve(true);
88+
OpenAPI openAPI = new OpenAPIV3Parser().readLocation("issue-901/spec.yaml",null,options).getOpenAPI();
89+
assertNotNull(openAPI);
90+
String internalRef = openAPI.getPaths().get("/test").getPut().getResponses().get("200").getContent().get("application/json").getSchema().get$ref();
91+
assertEquals(internalRef,"#/components/schemas/Test.Definition");
92+
assertNotNull(openAPI.getComponents());
93+
}
94+
6095
@Test
6196
public void testIssue853() {
6297
ParseOptions options = new ParseOptions();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Domains, a place to put your reusable components
2+
3+
4+
info:
5+
title: "aa"
6+
description: "swos552"
7+
version: '1.0.0'
8+
9+
components:
10+
schemas:
11+
Test.Definition:
12+
type: object
13+
properties:
14+
stuff:
15+
type: array
16+
items:
17+
$ref: '#/components/schemas/TESTTHING'
18+
TESTTHING:
19+
type: object
20+
properties:
21+
prop:
22+
type: string
23+
pathitems:
24+
path-test:
25+
put:
26+
description: test ref
27+
operationId: test
28+
responses:
29+
'200':
30+
description: successful operation
31+
content:
32+
application/json:
33+
schema:
34+
$ref: '#/components/schemas/Test.Definition'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Domains, a place to put your reusable components
2+
3+
4+
info:
5+
title: "aa"
6+
description: "swos55"
7+
version: '1.0.0'
8+
9+
components:
10+
schemas:
11+
Test.Definition:
12+
type: object
13+
properties:
14+
stuff:
15+
type: array
16+
items:
17+
$ref: '#/components/schemas/TEST.THING.OUT.Stuff'
18+
TEST.THING.OUT.Stuff:
19+
type: object
20+
properties:
21+
prop:
22+
type: string
23+
pathitems:
24+
path-test:
25+
put:
26+
description: test ref
27+
operationId: test
28+
responses:
29+
'200':
30+
description: successful operation
31+
content:
32+
application/json:
33+
schema:
34+
$ref: '#/components/schemas/Test.Definition'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: 3.0.1
2+
info:
3+
title: testswos55
4+
description: testswos55
5+
version: "1.01"
6+
servers:
7+
- url: ///test
8+
paths:
9+
/test:
10+
$ref: ref.yaml/#/pathitems/path-test
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: 3.0.1
2+
info:
3+
title: testswos55
4+
description: testswos55
5+
version: "1.01"
6+
servers:
7+
- url: ///test
8+
paths:
9+
/test:
10+
$ref: ref2.yaml/#/pathitems/path-test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"properties": {
3+
"indicatorType": {
4+
"type": "object",
5+
"properties": {
6+
"indicator": {
7+
"type": "boolean"
8+
}
9+
}
10+
}
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"properties": {
3+
"details": {
4+
"type": "object",
5+
"properties": {
6+
"confirmationCodeRequired": {
7+
"$ref": "../Common/BasicComponents.json#/properties/indicatorType"
8+
}
9+
}
10+
}
11+
}
12+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Service Model
4+
version: 2.4.0
5+
paths:
6+
/networkAccessProfile:
7+
get:
8+
tags:
9+
- AccessProfile
10+
operationId: getList
11+
parameters:
12+
- name: id
13+
in: query
14+
schema:
15+
type: string
16+
responses:
17+
'200':
18+
description: OK
19+
content:
20+
application/json:
21+
schema:
22+
type: array
23+
items:
24+
$ref: '#/components/schemas/accessProfileBO'
25+
servers:
26+
- url: 'https://api.com/{access}/accessProfileAPI'
27+
variables:
28+
access:
29+
default: unknown
30+
components:
31+
parameters:
32+
fields:
33+
name: fields
34+
in: query
35+
schema:
36+
type: string
37+
schemas:
38+
accessProfileBO:
39+
$ref: ../BO/Resource/ApiSpecificationBO.json

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44

5+
import io.swagger.v3.core.util.Yaml;
56
import io.swagger.v3.oas.models.Components;
67
import io.swagger.v3.oas.models.OpenAPI;
78
import io.swagger.v3.oas.models.media.ArraySchema;
@@ -460,4 +461,5 @@ public void testIssue879() {
460461
.get$ref();
461462
assertEquals(ref, "#/components/callbacks/callbackEvent");
462463
}
464+
463465
}

0 commit comments

Comments
 (0)