Skip to content

Commit 2d29d11

Browse files
committed
Update dependencies.
1 parent 04772b5 commit 2d29d11

File tree

8 files changed

+649
-1533
lines changed

8 files changed

+649
-1533
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ jobs:
2727
with:
2828
node-version: ${{ matrix.node-version }}
2929

30+
- name: Install pnpm
31+
run: npm install -g pnpm
32+
3033
- name: Install dependencies
31-
run: npm install
34+
run: pnpm install --frozen-lockfile
3235

3336
- name: List installed packages
3437
run: npm ls -a

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# @azure-tools/rest-api-diff
22

3-
## 0.2.1 (TBD)
3+
## 0.2.1 (2025-04-09)
44

5-
- Added `--suppressions` option to point to a filing containing point suppressions of violations.
5+
- Added `--suppressions` option to point to a file containing point suppressions of violations.
6+
- Fixed issue where inheritance chains were not being properly expanded.
67

78
## 0.2.0 (2025-03-11)
89

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-tools/rest-api-diff",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"author": "Microsoft Corporation",
55
"description": "Compares two Swagger definitions to identify relevant differences.",
66
"license": "MIT",
@@ -31,18 +31,18 @@
3131
"cmd/rest-api-diff.js"
3232
],
3333
"devDependencies": {
34-
"@azure-tools/typespec-azure-resource-manager": ">=0.44.0, <1.0.0",
34+
"@azure-tools/typespec-azure-resource-manager": ">=0.54.0, <1.0.0",
3535
"@azure/avocado": "^0.9.1",
3636
"@types/deep-diff": "^1.0.5",
3737
"@types/diff": "^7.0.0",
3838
"@types/node": "^20.14.7",
3939
"@types/yargs": "^17.0.32",
40-
"@typespec/compiler": ">=0.57.0, <1.0.0",
41-
"@typespec/http": ">=0.57.0, <1.0.0",
42-
"@typespec/openapi": ">=0.57.0, <1.0.0",
43-
"@typespec/openapi3": ">=0.57.0, <1.0.0",
44-
"@typespec/rest": ">=0.57.0, <1.0.0",
45-
"@typespec/versioning": ">=0.57.0, <1.0.0",
40+
"@typespec/compiler": "^1.0.0-0",
41+
"@typespec/http": "^1.0.0-0",
42+
"@typespec/openapi": "^1.0.0-0",
43+
"@typespec/openapi3": "^1.0.0-0",
44+
"@typespec/rest": ">=0.68.0, <1.0.0",
45+
"@typespec/versioning": ">=0.68.0, <1.0.0",
4646
"@vitest/coverage-v8": "^2.1.0",
4747
"openapi-types": "^1.0.0",
4848
"prettier": "~3.2.5",
@@ -53,8 +53,8 @@
5353
"vitest": "^2.1.3"
5454
},
5555
"dependencies": {
56-
"@azure-tools/typespec-autorest": ">=0.44.0, <1.0.0",
57-
"@azure-tools/typespec-azure-core": ">=0.44.0, <1.0.0",
56+
"@azure-tools/typespec-autorest": ">=0.54.0, <1.0.0",
57+
"@azure-tools/typespec-azure-core": ">=0.54.0, <1.0.0",
5858
"acorn": "^8.12.0",
5959
"acorn-walk": "^8.3.3",
6060
"arg": "^4.1.3",

pnpm-lock.yaml

Lines changed: 580 additions & 1494 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/definitions.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class DefinitionRegistry {
204204

205205
#expandAllOf(base: any): any {
206206
const allOf = base.allOf;
207-
delete base.allOf;
207+
208208
if (allOf === undefined) {
209209
return base;
210210
}
@@ -303,7 +303,6 @@ export class DefinitionRegistry {
303303
this.referenceStack = [];
304304
for (const [filepath, values] of collection.data.entries()) {
305305
for (const [key, value] of values.entries()) {
306-
console.log(key);
307306
this.currentPath.push(key);
308307
let expanded = this.#expand(value, key, filepath);
309308
collection.data.get(filepath)!.set(key, expanded);
@@ -421,9 +420,28 @@ export class DefinitionRegistry {
421420
}
422421
}
423422

423+
/**
424+
* Ensures inheritance chains are expanded for polymorphic references in the `polymorphicMap`.
425+
* This is to ensure than an inheritance chain A > B > C is fully expanded to reflect
426+
* that both B and C are derived from A.
427+
*
428+
* This method iterates through all entries in the `polymorphicMap`, which maps references
429+
* to their derived classes. For each key in the map, it:
430+
* 1. Retrieves the base class associated with the reference key.
431+
* 2. Logs an unresolved reference if the base class cannot be found.
432+
* 3. Checks if any derived classes of the reference also have their own derived classes
433+
* and combines them into the current set of derived classes.
434+
* 4. Updates the base class with a `$derivedClasses` property containing the complete
435+
* set of derived classes.
436+
*
437+
* Throws:
438+
* - An `Error` if a reference cannot be parsed.
439+
*
440+
* Side Effects:
441+
* - Updates the `$derivedClasses` property of base classes in the `polymorphicMap`.
442+
* - Logs unresolved references using `logUnresolvedReference`.
443+
*/
424444
#expandInheritanceChains() {
425-
// ensure each base class has a list of derived classes for use
426-
// when interpretting allOf.
427445
for (const [ref, derived_set] of this.polymorphicMap.entries()) {
428446
const refResult = parseReference(ref);
429447
if (!refResult) {

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = "0.2.0";
1+
export const VERSION = "0.2.1";

test/definition-registry.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ it("expands inheritance chains", async () => {
173173
RegistryKind.Definition
174174
);
175175
let filePath = Object.keys(defRegistry)[0];
176-
let quad = defRegistry[filePath].get("Quadrilateral");
177-
let expected_properties = ["length", "width", "sides", "name"];
176+
let quad = defRegistry[filePath].get("D");
177+
let expected_properties = ["aProp", "bProp", "cProp", "dProp"];
178178
for (const prop of expected_properties) {
179179
expect(quad.properties).toHaveProperty(prop);
180180
}

test/files/inheritanceChain.json

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,56 @@
1515
"tags": [],
1616
"paths": {},
1717
"definitions": {
18-
"Polygon": {
18+
"A": {
1919
"type": "object",
2020
"properties": {
21-
"sides": {
22-
"type": "integer",
23-
"format": "int16"
21+
"aProp": {
22+
"type": "string"
23+
}
24+
},
25+
"required": ["aProp"]
26+
},
27+
"B": {
28+
"type": "object",
29+
"properties": {
30+
"bProp": {
31+
"type": "string"
2432
}
2533
},
26-
"required": ["sides"],
34+
"required": ["bProp"],
2735
"allOf": [
2836
{
29-
"$ref": "#/definitions/Shape"
37+
"$ref": "#/definitions/A"
3038
}
3139
]
3240
},
33-
"Quadrilateral": {
41+
"C": {
3442
"type": "object",
3543
"properties": {
36-
"length": {
37-
"type": "integer",
38-
"format": "int16"
39-
},
40-
"width": {
41-
"type": "integer",
42-
"format": "int16"
44+
"cProp": {
45+
"type": "string"
4346
}
4447
},
45-
"required": ["length", "width"],
48+
"required": ["cProp"],
4649
"allOf": [
4750
{
48-
"$ref": "#/definitions/Polygon"
51+
"$ref": "#/definitions/B"
4952
}
5053
]
5154
},
52-
"Shape": {
55+
"D": {
5356
"type": "object",
5457
"properties": {
55-
"name": {
58+
"dProp": {
5659
"type": "string"
5760
}
5861
},
59-
"required": ["name"]
62+
"required": ["dProp"],
63+
"allOf": [
64+
{
65+
"$ref": "#/definitions/C"
66+
}
67+
]
6068
}
6169
},
6270
"parameters": {}

0 commit comments

Comments
 (0)