Skip to content

Commit 32dd655

Browse files
committed
add targeted sample spec to demonstrate duplicated equivalent refs
1 parent 0ab2e8a commit 32dd655

File tree

215 files changed

+5026
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+5026
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,21 @@ public void testRelativePath2() {
19531953
Assert.assertEquals(readResult.getOpenAPI().getPaths().get("/pet/findByTags").getGet().getResponses().get("default").getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/ErrorModel");
19541954
}
19551955

1956+
@Test
1957+
public void testExternalRefsNormalization() throws Exception {
1958+
ParseOptions options = new ParseOptions();
1959+
options.setResolve(true);
1960+
SwaggerParseResult result = new OpenAPIV3Parser()
1961+
.readLocation("src/test/resources/oas3.fetched/openapi3.yaml", null, options);
1962+
1963+
OpenAPI openAPI = result.getOpenAPI();
1964+
Schema originalModel = openAPI.getComponents().getSchemas().get("Event");
1965+
Schema duplicateModel = openAPI.getComponents().getSchemas().get("Event_1");
1966+
System.out.println("component schemas found: " + openAPI.getComponents().getSchemas().keySet());
1967+
assertNull(duplicateModel);
1968+
assertNotNull(originalModel);
1969+
}
1970+
19561971
private OpenAPI doRelativeFileTest(String location) {
19571972
OpenAPIV3Parser parser = new OpenAPIV3Parser();
19581973
ParseOptions options = new ParseOptions();
@@ -3298,4 +3313,4 @@ public void testIssue2081() {
32983313
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getRequired().size(), 1);
32993314
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getProperties().size(), 2);
33003315
}
3301-
}
3316+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
properties:
2+
address:
3+
type: string
4+
address2:
5+
type: string
6+
city:
7+
type: string
8+
coordinates:
9+
$ref: './Coordinates.yaml'
10+
country:
11+
type: string
12+
state:
13+
type: string
14+
zip_code:
15+
type: string
16+
required:
17+
- address
18+
- zip_code
19+
- country
20+
type: object
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
properties:
2+
namespace:
3+
readOnly: true
4+
type: string
5+
description: Attribute namespace
6+
created_at:
7+
readOnly: true
8+
type: string
9+
format: date-time
10+
description: Datetime when the block was created.
11+
updated_at:
12+
readOnly: true
13+
type: string
14+
format: date-time
15+
description: Datetime when the block was updated.
16+
data:
17+
$ref: "./AttributeData.yaml"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
properties:
2+
latest:
3+
readOnly: true
4+
type: boolean
5+
description: Boolean flag to know if the firmware set is the latest for the model and vendor
6+
model:
7+
readOnly: true
8+
type: string
9+
description: Model on which this firmware set can be applied
10+
vendor:
11+
readOnly: true
12+
type: string
13+
description: Vendor on which this firmware set can be applied
14+
plan:
15+
readOnly: true
16+
type: string
17+
description: Plan where the firmware set can be applied
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
properties:
2+
created_at:
3+
format: date-time
4+
type: string
5+
description:
6+
description: Available only for API keys
7+
type: string
8+
id:
9+
format: uuid
10+
type: string
11+
project:
12+
allOf:
13+
- $ref: './Project.yaml'
14+
- description: Available only for project tokens
15+
read_only:
16+
type: boolean
17+
token:
18+
type: string
19+
updated_at:
20+
format: date-time
21+
type: string
22+
user:
23+
allOf:
24+
- $ref: './User.yaml'
25+
- description: Available only for user tokens
26+
type: object
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
properties:
2+
description:
3+
type: string
4+
read_only:
5+
type: boolean
6+
type: object
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
properties:
2+
api_keys:
3+
items:
4+
$ref: './AuthToken.yaml'
5+
type: array
6+
type: object
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
properties:
2+
address_family:
3+
description: Address family for BGP session.
4+
enum:
5+
- ipv4
6+
- ipv6
7+
example: ipv4
8+
type: string
9+
default_route:
10+
default: false
11+
description: Set the default route policy.
12+
type: boolean
13+
type: object
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
properties:
2+
created_at:
3+
format: date-time
4+
type: string
5+
devices:
6+
items:
7+
$ref: './Href.yaml'
8+
type: array
9+
error_messages:
10+
items:
11+
type: string
12+
type: array
13+
id:
14+
format: uuid
15+
type: string
16+
project:
17+
$ref: './Href.yaml'
18+
quantity:
19+
type: integer
20+
state:
21+
type: string
22+
updated_at:
23+
format: date-time
24+
type: string
25+
type: object
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
properties:
2+
batches:
3+
items:
4+
$ref: './Batch.yaml'
5+
type: array
6+
type: object

0 commit comments

Comments
 (0)