Skip to content

Commit f7d434d

Browse files
committed
Add test for duplicate definition names
1 parent bb4653d commit f7d434d

4 files changed

Lines changed: 98 additions & 0 deletions

File tree

src/test/incompatiblePropertiesTest.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import * as path from "path"
33
import { OpenApiDiff } from ".."
44
import { fileUrl } from "./fileUrl"
55

6+
test("should-allow-different-names", async () => {
7+
const diff = new OpenApiDiff({})
8+
const file = `src/test/specs/incompatible-properties/different-names.json`
9+
const filePath = fileUrl(path.resolve(file))
10+
11+
// expected to pass
12+
await diff.compare(file, file)
13+
})
14+
15+
test("should-allow-duplicate-names", async () => {
16+
const diff = new OpenApiDiff({})
17+
const file = `src/test/specs/incompatible-properties/duplicate-names.json`
18+
const filePath = fileUrl(path.resolve(file))
19+
20+
// expected to pass
21+
await diff.compare(file, file)
22+
})
23+
624
// This test is part of regression test suite for https://github.com/Azure/azure-sdk-tools/issues/5981
725
// Given a property with given type and name
826
// When another property with the same name but an incompatible type is referenced
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "common-types",
5+
"version": "1.0"
6+
},
7+
"paths": {},
8+
"definitions": {
9+
"Bar": {
10+
"type": "object",
11+
"properties": {
12+
"p1": {
13+
"type": "string"
14+
}
15+
}
16+
}
17+
}
18+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "different-names",
5+
"version": "1.0"
6+
},
7+
"paths": {},
8+
"definitions": {
9+
"Foo": {
10+
"type": "object",
11+
"properties": {
12+
"p1": {
13+
"type": "string"
14+
}
15+
},
16+
"allOf": [
17+
{
18+
"$ref": "./common-types.json#/definitions/Bar"
19+
}
20+
]
21+
},
22+
"Baz": {
23+
"type": "object",
24+
"properties": {
25+
"p1": {
26+
"type": "object"
27+
}
28+
}
29+
}
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "duplicate-names",
5+
"version": "1.0"
6+
},
7+
"paths": {},
8+
"definitions": {
9+
"Foo": {
10+
"type": "object",
11+
"properties": {
12+
"p1": {
13+
"type": "string"
14+
}
15+
},
16+
"allOf": [
17+
{
18+
"$ref": "./common-types.json#/definitions/Bar"
19+
}
20+
]
21+
},
22+
"Bar": {
23+
"type": "object",
24+
"properties": {
25+
"p1": {
26+
"type": "object"
27+
}
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)