Skip to content

Commit 10e73d1

Browse files
committed
Revert "Merge pull request #79 from tjprescott/FixInheritanceChain"
This reverts commit 3fbeb14, reversing changes made to 5f5aa1e.
1 parent 3fbeb14 commit 10e73d1

File tree

7 files changed

+468
-621
lines changed

7 files changed

+468
-621
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# @azure-tools/rest-api-diff
22

3+
## 0.2.2 (2025-04-14)
4+
5+
- Reverted change for inheritance chains. This will be fixed in a future release.
6+
- Removed `--group-violations`. Now violations will always be grouped.
7+
38
## 0.2.1 (2025-04-09)
49

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

813
## 0.2.0 (2025-03-11)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-tools/rest-api-diff",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"author": "Microsoft Corporation",
55
"description": "Compares two Swagger definitions to identify relevant differences.",
66
"license": "MIT",

pnpm-lock.yaml

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

src/definitions.ts

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export class DefinitionRegistry {
120120
this.currentPath = [];
121121
this.client = client;
122122
this.#gatherDefinitions(map);
123-
this.#expandInheritanceChains();
124123
this.#expandReferences();
125124
}
126125

@@ -204,7 +203,7 @@ export class DefinitionRegistry {
204203

205204
#expandAllOf(base: any): any {
206205
const allOf = base.allOf;
207-
206+
delete base.allOf;
208207
if (allOf === undefined) {
209208
return base;
210209
}
@@ -418,31 +417,9 @@ export class DefinitionRegistry {
418417
this.data.securityDefinitions.add(path, name, data);
419418
}
420419
}
421-
}
422-
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-
*/
444-
#expandInheritanceChains() {
445-
for (const [ref, derived_set] of this.polymorphicMap.entries()) {
420+
// ensure each base class has a list of derived classes for use
421+
// when interpretting allOf.
422+
for (const [ref, set] of this.polymorphicMap.entries()) {
446423
const refResult = parseReference(ref);
447424
if (!refResult) {
448425
throw new Error(`Could not parse reference: ${ref}`);
@@ -452,17 +429,7 @@ export class DefinitionRegistry {
452429
this.logUnresolvedReference(ref);
453430
continue;
454431
}
455-
// check if refKey also has derived classes and combine them
456-
for (const derived of derived_set) {
457-
const derivedRef = parseReference(derived)!.expandedRef;
458-
const match = this.polymorphicMap.get(derivedRef);
459-
if (match !== undefined) {
460-
for (const item of match) {
461-
derived_set.add(item);
462-
}
463-
}
464-
}
465-
baseClass["$derivedClasses"] = Array.from(derived_set);
432+
baseClass["$derivedClasses"] = Array.from(set);
466433
}
467434
}
468435

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.1";
1+
export const VERSION = "0.2.2";

test/definition-registry.test.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,3 @@ it("should ignore example references", async () => {
158158
expect(ref.includes("examples")).toBe(false);
159159
}
160160
});
161-
162-
it("expands inheritance chains", async () => {
163-
const config: DiffClientConfig = {
164-
lhs: ["test/files/inheritanceChain.json"],
165-
rhs: ["test/files/inheritanceChain.json"],
166-
args: {},
167-
rules: getApplicableRules({}),
168-
};
169-
const client = await TestableDiffClient.create(config);
170-
client.parse();
171-
const [parser, _] = client.getParsers();
172-
const defRegistry = getDefinitionRegistry(parser).getCollection(
173-
RegistryKind.Definition
174-
);
175-
let filePath = Object.keys(defRegistry)[0];
176-
let quad = defRegistry[filePath].get("D");
177-
let expected_properties = ["aProp", "bProp", "cProp", "dProp"];
178-
for (const prop of expected_properties) {
179-
expect(quad.properties).toHaveProperty(prop);
180-
}
181-
});

test/files/inheritanceChain.json

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)