From d575109bede97b0512e3a1e99b424d7733ebb90b Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 15 May 2025 23:23:53 +0000 Subject: [PATCH 1/6] [spec-model] Public APIs return Map<> instead of Set<> --- .github/shared/src/readme.js | 22 ++--- .github/shared/src/spec-model.js | 63 +++++++------- .github/shared/src/swagger.js | 22 ++--- .github/shared/src/tag.js | 10 ++- .github/shared/test/readme.test.js | 19 +++-- .github/shared/test/spec-model.test.js | 84 +++++++++---------- .../workflows/src/arm-incremental-typespec.js | 5 +- 7 files changed, 110 insertions(+), 115 deletions(-) diff --git a/.github/shared/src/readme.js b/.github/shared/src/readme.js index 9354b9ac0212..a54cf2f3fc1f 100644 --- a/.github/shared/src/readme.js +++ b/.github/shared/src/readme.js @@ -23,7 +23,7 @@ export class Readme { */ #content; - /** @type {{globalConfig: Object, tags: Set} | undefined} */ + /** @type {{globalConfig: Object, tags: Map} | undefined} */ #data; /** @type {import('./logger.js').ILogger | undefined} */ @@ -114,8 +114,8 @@ export class Readme { {}, ); - /** @type {Set} */ - const tags = new Set(); + /** @type {Map} */ + const tags = new Map(); for (const block of yamlBlocks) { const tagName = block.lang?.match(/yaml.*\$\(tag\) ?== ?'([^']*)'/)?.[1] || "default"; @@ -145,7 +145,7 @@ export class Readme { // swaggers means that the previous definition did not have an input-file // key. It's possible that the previous defintion had an `input-file: []` // or something like it. - const existingTag = [...tags].find((t) => t.name == tagName); + const existingTag = tags.get(tagName); if ((existingTag?.inputFiles?.size ?? 0) > 0) { // The tag already exists and has a swagger file. This is an error as // there should only be one definition of input-files per tag. @@ -154,8 +154,8 @@ export class Readme { throw new Error(message); } - /** @type {Set} */ - const inputFiles = new Set(); + /** @type {Map} */ + const inputFiles = new Map(); // It's possible for input-file to be a string or an array const inputFilePaths = Array.isArray(obj["input-file"]) @@ -172,12 +172,12 @@ export class Readme { logger: this.#logger, specModel: this.#specModel, }); - inputFiles.add(swagger); + inputFiles.set(swaggerPathResolved, swagger); } const tag = new Tag(tagName, inputFiles, { logger: this.#logger }); - tags.add(tag); + tags.set(tagName, tag); } this.#data = { globalConfig, tags }; @@ -197,7 +197,7 @@ export class Readme { } /** - * @returns {Promise>} + * @returns {Promise>} */ async getTags() { return (await this.#getData()).tags; @@ -216,7 +216,9 @@ export class Readme { */ async toJSONAsync(options) { const tags = await mapAsync( - [...(await this.getTags())].sort((a, b) => a.name.localeCompare(b.name)), + [...(await this.getTags()).values()].sort((a, b) => + a.name.localeCompare(b.name), + ), async (t) => await t.toJSONAsync(options), ); diff --git a/.github/shared/src/spec-model.js b/.github/shared/src/spec-model.js index e74e8e81b842..2897529c0c45 100644 --- a/.github/shared/src/spec-model.js +++ b/.github/shared/src/spec-model.js @@ -21,7 +21,7 @@ export class SpecModel { /** @type {import('./logger.js').ILogger | undefined} */ #logger; - /** @type {Set | undefined} */ + /** @type {Map | undefined} */ #readmes; /** @@ -43,33 +43,33 @@ export class SpecModel { /** * @param {string} swaggerPath - * @returns {Promise>>} + * @returns {Promise>>} */ async getAffectedReadmeTags(swaggerPath) { const swaggerPathResolved = resolve(swaggerPath); - /** @type {Map>} */ + /** @type {Map>} */ const affectedReadmeTags = new Map(); - for (const readme of await this.getReadmes()) { - for (const tag of await readme.getTags()) { - for (const inputFile of tag.inputFiles) { + for (const readme of (await this.getReadmes()).values()) { + for (const tag of (await readme.getTags()).values()) { + for (const inputFile of tag.inputFiles.values()) { if (inputFile.path === swaggerPathResolved) { - /** @type {Set} */ - const tags = affectedReadmeTags.get(readme) ?? new Set(); - tags.add(tag); - affectedReadmeTags.set(readme, tags); + /** @type {Map} */ + const tags = affectedReadmeTags.get(readme.path) ?? new Map(); + tags.set(tag.name, tag); + affectedReadmeTags.set(readme.path, tags); // No need to check refs if the swagger file is directly referenced continue; } const refs = await inputFile.getRefs(); - if ([...refs].find((r) => r.path === swaggerPathResolved)) { - /** @type {Set} */ - const tags = affectedReadmeTags.get(readme) ?? new Set(); - tags.add(tag); - affectedReadmeTags.set(readme, tags); + if (refs.get(swaggerPathResolved)) { + /** @type {Map} */ + const tags = affectedReadmeTags.get(readme.path) ?? new Map(); + tags.set(tag.name, tag); + affectedReadmeTags.set(readme.path, tags); } } } @@ -82,7 +82,7 @@ export class SpecModel { * Given a swagger file, return the swagger files that are affected by the * changes in the given swagger file. * @param {string} swaggerPath - * @returns {Promise>} + * @returns {Promise>} */ async getAffectedSwaggers(swaggerPath) { const swaggerPathResolved = resolve(swaggerPath); @@ -92,9 +92,9 @@ export class SpecModel { /** @type {Map} */ const affectedSwaggers = new Map(); - for (const readme of await this.getReadmes()) { - for (const tag of await readme.getTags()) { - for (const swagger of tag.inputFiles) { + for (const readme of (await this.getReadmes()).values()) { + for (const tag of (await readme.getTags()).values()) { + for (const swagger of tag.inputFiles.values()) { // readme.md includes swaggerPath if (swagger.path === swaggerPathResolved) { affectedSwaggers.set(swagger.path, swagger); @@ -104,9 +104,7 @@ export class SpecModel { // readme.md includes a.json // a.json references swaggerPath - const refToSwaggerPath = [...refs].find( - (ref) => ref.path === swaggerPathResolved, - ); + const refToSwaggerPath = refs.get(swaggerPathResolved); if (refToSwaggerPath) { // Add the Swagger object for swaggerPath affectedSwaggers.set(refToSwaggerPath.path, refToSwaggerPath); @@ -120,11 +118,9 @@ export class SpecModel { // readme.md includes a.json // a.json references b.json // b.json references swaggerPath - for (const ref of refs) { + for (const ref of refs.values()) { const refRefs = await ref.getRefs(); - const refRefToSwaggerPath = [...refRefs].find( - (ref) => ref.path === swaggerPathResolved, - ); + const refRefToSwaggerPath = refRefs.get(swaggerPathResolved); if (refRefToSwaggerPath) { // Add the Swagger object for swaggerPath affectedSwaggers.set( @@ -160,11 +156,11 @@ export class SpecModel { ); } - return new Set(affectedSwaggers.values()); + return affectedSwaggers; } /** - * @returns {Promise>} + * @returns {Promise>} */ async getReadmes() { if (!this.#readmes) { @@ -179,10 +175,11 @@ export class SpecModel { this.#logger?.debug(`Found ${readmePaths.length} readme files`); - this.#readmes = new Set( - readmePaths.map( - (p) => new Readme(p, { logger: this.#logger, specModel: this }), - ), + this.#readmes = new Map( + readmePaths.map((p) => [ + p, + new Readme(p, { logger: this.#logger, specModel: this }), + ]), ); } @@ -195,7 +192,7 @@ export class SpecModel { */ async toJSONAsync(options) { const readmes = await mapAsync( - [...(await this.getReadmes())].sort((a, b) => + [...(await this.getReadmes()).values()].sort((a, b) => a.path.localeCompare(b.path), ), async (r) => await r.toJSONAsync(options), diff --git a/.github/shared/src/swagger.js b/.github/shared/src/swagger.js index 2f2049a5c8a3..bbebe51d2a8a 100644 --- a/.github/shared/src/swagger.js +++ b/.github/shared/src/swagger.js @@ -16,7 +16,7 @@ export class Swagger { /** @type {string} absolute path */ #path; - /** @type {Set | undefined} */ + /** @type {Map | undefined} */ #refs; /** @type {SpecModel | undefined} backpointer to owning SpecModel */ @@ -35,7 +35,7 @@ export class Swagger { } /** - * @returns {Promise>} + * @returns {Promise>} */ async getRefs() { if (!this.#refs) { @@ -50,14 +50,14 @@ export class Swagger { // Exclude ourself .filter((p) => resolve(p) !== resolve(this.#path)); - this.#refs = new Set( - refPaths.map( - (p) => - new Swagger(p, { - logger: this.#logger, - specModel: this.#specModel, - }), - ), + this.#refs = new Map( + refPaths.map((p) => [ + p, + new Swagger(p, { + logger: this.#logger, + specModel: this.#specModel, + }), + ]), ); } @@ -83,7 +83,7 @@ export class Swagger { : this.#path, refs: options?.includeRefs ? await mapAsync( - [...(await this.getRefs())].sort((a, b) => + [...(await this.getRefs()).values()].sort((a, b) => a.path.localeCompare(b.path), ), async (s) => diff --git a/.github/shared/src/tag.js b/.github/shared/src/tag.js index d7ca3e305dba..1d9a5365125e 100644 --- a/.github/shared/src/tag.js +++ b/.github/shared/src/tag.js @@ -8,7 +8,7 @@ import { mapAsync } from "./array.js"; */ export class Tag { - /** @type {Set} */ + /** @type {Map} */ #inputFiles; /** @type {import('./logger.js').ILogger | undefined} */ @@ -19,7 +19,7 @@ export class Tag { /** * @param {string} name - * @param {Set} inputFiles + * @param {Map} inputFiles * @param {Object} [options] * @param {import('./logger.js').ILogger} [options.logger] */ @@ -30,7 +30,7 @@ export class Tag { } /** - * @returns {Set} + * @returns {Map} */ get inputFiles() { return this.#inputFiles; @@ -51,7 +51,9 @@ export class Tag { return { name: this.#name, inputFiles: await mapAsync( - [...this.#inputFiles].sort(), + [...this.#inputFiles.values()].sort((a, b) => + a.path.localeCompare(b.path), + ), async (s) => await s.toJSONAsync(options), ), }; diff --git a/.github/shared/test/readme.test.js b/.github/shared/test/readme.test.js index 894b55a09579..a428bc664ad1 100644 --- a/.github/shared/test/readme.test.js +++ b/.github/shared/test/readme.test.js @@ -26,26 +26,27 @@ describe("readme", () => { }); const tags = await readme.getTags(); - const tagNames = new Set([...tags].map((t) => t.name)); - const expectedTagNames = new Set([ + const tagNames = [...tags.keys()]; + const expectedTagNames = [ "package-2021-11-01", "package-2021-10-01-preview", - ]); + ]; - expect(tagNames).toEqual(expectedTagNames); + expect(tagNames.sort()).toEqual(expectedTagNames.sort()); - const swaggers = [...tags].flatMap((t) => [...t.inputFiles]); - const swaggerPaths = new Set(swaggers.map((s) => s.path)); + const swaggerPaths = [...tags.values()].flatMap((t) => [ + ...t.inputFiles.keys(), + ]); - const expectedPaths = new Set([ + const expectedPaths = [ resolve(folder, "Microsoft.Contoso/stable/2021-11-01/contoso.json"), resolve( folder, "Microsoft.Contoso/preview/2021-10-01-preview/contoso.json", ), - ]); + ]; - expect(swaggerPaths).toEqual(expectedPaths); + expect(swaggerPaths.sort()).toEqual(expectedPaths.sort()); }); it("can be created with empty content", async () => { diff --git a/.github/shared/test/spec-model.test.js b/.github/shared/test/spec-model.test.js index 85c95d54c4df..0c49bba771f6 100644 --- a/.github/shared/test/spec-model.test.js +++ b/.github/shared/test/spec-model.test.js @@ -31,7 +31,7 @@ describe("SpecModel", () => { expect(specModel.toString()).toContain("SpecModel"); expect(specModel.folder).toBe(folder); - const readmes = [...(await specModel.getReadmes())]; + const readmes = [...(await specModel.getReadmes()).values()]; expect(readmes.length).toBe(1); const readme = readmes[0]; @@ -44,7 +44,7 @@ describe("SpecModel", () => { tag: "package-2021-11-01", }); - const tags = [...(await readme.getTags())].sort((a, b) => + const tags = [...(await readme.getTags()).values()].sort((a, b) => a.name.localeCompare(b.name), ); expect(tags.length).toBe(2); @@ -52,7 +52,7 @@ describe("SpecModel", () => { expect(tags[0].toString()).toContain("Tag"); expect(tags[0].name).toBe("package-2021-10-01-preview"); - const inputFiles0 = [...tags[0].inputFiles]; + const inputFiles0 = [...tags[0].inputFiles.values()]; expect(inputFiles0.length).toBe(1); expect(inputFiles0[0].toString()).toContain("Swagger"); expect(inputFiles0[0].path).toBe( @@ -62,7 +62,7 @@ describe("SpecModel", () => { ), ); - const refs0 = [...(await inputFiles0[0].getRefs())].sort((a, b) => + const refs0 = [...(await inputFiles0[0].getRefs()).values()].sort((a, b) => a.path.localeCompare(b.path), ); @@ -76,7 +76,7 @@ describe("SpecModel", () => { ); expect(tags[1].name).toBe("package-2021-11-01"); - const inputFiles1 = [...tags[1].inputFiles]; + const inputFiles1 = [...tags[1].inputFiles.values()]; expect(inputFiles1.length).toBe(1); expect(inputFiles1[0].path).toBe( resolve(folder, "Microsoft.Contoso/stable/2021-11-01/contoso.json"), @@ -106,7 +106,7 @@ describe("SpecModel", () => { const specModel = new SpecModel(folder, options); - const readme = [...(await specModel.getReadmes())][0]; + const readme = [...(await specModel.getReadmes()).values()][0]; const globalConfig = await readme.getGlobalConfig(); @@ -131,7 +131,7 @@ describe("SpecModel", () => { const readmes = await specModel.getReadmes(); await expect( - mapAsync([...readmes], async (r) => await r.getTags()), + mapAsync([...readmes.values()], async (r) => await r.getTags()), ).rejects.toThrowError(/multiple.*tag/i); }); @@ -149,21 +149,18 @@ describe("SpecModel", () => { "resource-manager/Microsoft.Contoso/stable/2021-11-01/contoso.json", ); - const actual = await specModel.getAffectedReadmeTags(swaggerPath); + const affectedReadmeTags = + await specModel.getAffectedReadmeTags(swaggerPath); - const entries = [...actual]; + expect(affectedReadmeTags.size).toBe(1); - expect(entries.length).toBe(1); + const readmePath = [...affectedReadmeTags.keys()][0]; + expect(readmePath).toBe(resolve(folder, "resource-manager/readme.md")); - const readme = entries[0][0]; - expect(readme.path).toBe(resolve(folder, "resource-manager/readme.md")); + const tagNames = [...[...affectedReadmeTags.values()][0].keys()]; + expect(tagNames.length).toBe(1); - const tags = [...entries[0][1]].sort((a, b) => - a.name.localeCompare(b.name), - ); - expect(tags.length).toBe(1); - - expect(tags[0].name).toBe("package-2021-11-01"); + expect(tagNames[0]).toBe("package-2021-11-01"); }); it("returns affected readme tags for multiple tags", async () => { @@ -176,22 +173,19 @@ describe("SpecModel", () => { const swaggerPath = resolve(folder, "data-plane/shared/shared.json"); - const actual = await specModel.getAffectedReadmeTags(swaggerPath); + const affectedReadmeTags = + await specModel.getAffectedReadmeTags(swaggerPath); - const entries = [...actual]; + expect(affectedReadmeTags.size).toBe(1); - expect(entries.length).toBe(1); + const readmePath = [...affectedReadmeTags.keys()][0]; + expect(readmePath).toBe(resolve(folder, "data-plane/readme.md")); - const readme = entries[0][0]; - expect(readme.path).toBe(resolve(folder, "data-plane/readme.md")); + const tagNames = [...[...affectedReadmeTags.values()][0].keys()].sort(); - const tags = [...entries[0][1]].sort((a, b) => - a.name.localeCompare(b.name), - ); - - expect(tags.length).toBe(2); - expect(tags[0].name).toBe("tag-1"); - expect(tags[1].name).toBe("tag-2"); + expect(tagNames.length).toBe(2); + expect(tagNames[0]).toBe("tag-1"); + expect(tagNames[1]).toBe("tag-2"); }); }); @@ -206,9 +200,9 @@ describe("SpecModel", () => { it("returns directly referenced swagger", async () => { const swaggerPath = resolve(folder, "data-plane/a.json"); - const actual = [...(await specModel.getAffectedSwaggers(swaggerPath))] - .map((s) => s.path) - .sort(); + const actual = [ + ...(await specModel.getAffectedSwaggers(swaggerPath)).keys(), + ].sort(); const expected = ["data-plane/a.json"] .map((p) => resolve(folder, p)) @@ -228,9 +222,9 @@ describe("SpecModel", () => { it("returns correct swaggers for one layer of dependencies", async () => { const swaggerPath = resolve(folder, "data-plane/nesting/b.json"); - const actual = [...(await specModel.getAffectedSwaggers(swaggerPath))] - .map((s) => s.path) - .sort(); + const actual = [ + ...(await specModel.getAffectedSwaggers(swaggerPath)).keys(), + ].sort(); const expected = ["data-plane/a.json", "data-plane/nesting/b.json"] .map((p) => resolve(folder, p)) @@ -242,9 +236,9 @@ describe("SpecModel", () => { it("returns correct swaggers for two layers of dependencies", async () => { const swaggerPath = resolve(folder, "data-plane/c.json"); - const actual = [...(await specModel.getAffectedSwaggers(swaggerPath))] - .map((s) => s.path) - .sort(); + const actual = [ + ...(await specModel.getAffectedSwaggers(swaggerPath)).keys(), + ].sort(); const expected = [ "data-plane/a.json", @@ -260,9 +254,9 @@ describe("SpecModel", () => { it("returns correct swaggers for three layers of dependencies", async () => { const swaggerPath = resolve(folder, "data-plane/d.json"); - const actual = [...(await specModel.getAffectedSwaggers(swaggerPath))] - .map((s) => s.path) - .sort(); + const actual = [ + ...(await specModel.getAffectedSwaggers(swaggerPath)).keys(), + ].sort(); const expected = [ "data-plane/a.json", @@ -279,9 +273,9 @@ describe("SpecModel", () => { it("returns correctly for multiple shared dependencies", async () => { const swaggerPath = resolve(folder, "data-plane/shared/shared.json"); - const actual = [...(await specModel.getAffectedSwaggers(swaggerPath))] - .map((s) => s.path) - .sort(); + const actual = [ + ...(await specModel.getAffectedSwaggers(swaggerPath)).keys(), + ].sort(); const expected = [ "data-plane/a.json", diff --git a/.github/workflows/src/arm-incremental-typespec.js b/.github/workflows/src/arm-incremental-typespec.js index 503891acefb3..44f562134056 100644 --- a/.github/workflows/src/arm-incremental-typespec.js +++ b/.github/workflows/src/arm-incremental-typespec.js @@ -97,9 +97,8 @@ export default async function incrementalTypeSpec({ core }) { logger: options.logger, }); const tags = await readme.getTags(); - const swaggers = [...tags].flatMap((t) => [...t.inputFiles]); - const inputFiles = swaggers.map((s) => - relative(dirname(readme.path), s.path), + const inputFiles = [...tags.values()].flatMap((t) => + [...t.inputFiles.keys()].map((p) => relative(dirname(readme.path), p)), ); inputFiles.forEach((f) => { From 30a2bd3263c42974652f5816b6b7f9b9f02ee9f2 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 16 May 2025 01:12:37 +0000 Subject: [PATCH 2/6] comments --- .github/shared/src/spec-model.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/shared/src/spec-model.js b/.github/shared/src/spec-model.js index 2897529c0c45..2cab49aa8837 100644 --- a/.github/shared/src/spec-model.js +++ b/.github/shared/src/spec-model.js @@ -42,8 +42,9 @@ export class SpecModel { } /** + * Given a swagger file, return all the tags inside readme files that reference the file (directly or indirectly). * @param {string} swaggerPath - * @returns {Promise>>} + * @returns {Promise>>} map of readme paths to (map of tag names to Tag objects) */ async getAffectedReadmeTags(swaggerPath) { const swaggerPathResolved = resolve(swaggerPath); @@ -79,16 +80,14 @@ export class SpecModel { } /** - * Given a swagger file, return the swagger files that are affected by the + * Given a swagger file, return the swagger files that are affected by * changes in the given swagger file. * @param {string} swaggerPath - * @returns {Promise>} + * @returns {Promise>} map of swagger paths to Swagger objects */ async getAffectedSwaggers(swaggerPath) { const swaggerPathResolved = resolve(swaggerPath); - // Use Map instead of Set, to ensure exactly one Swagger object per path is returned - // SpecModel can include multiple Swagger objects pointing to the same path /** @type {Map} */ const affectedSwaggers = new Map(); @@ -160,7 +159,7 @@ export class SpecModel { } /** - * @returns {Promise>} + * @returns {Promise>} map of readme paths to readme Objects */ async getReadmes() { if (!this.#readmes) { From 70d38e9c465ce1b36cfadb454e9d8567e4bd657b Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 16 May 2025 01:15:37 +0000 Subject: [PATCH 3/6] [lint-diff] Update usage of spec-model --- eng/tools/lint-diff/src/processChanges.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eng/tools/lint-diff/src/processChanges.ts b/eng/tools/lint-diff/src/processChanges.ts index fe70b4e1083a..9a2941a52d92 100644 --- a/eng/tools/lint-diff/src/processChanges.ts +++ b/eng/tools/lint-diff/src/processChanges.ts @@ -89,12 +89,12 @@ export async function buildState( const readmeTagMapForChangedFile = await specModels.get(getService(changedSwagger))!.getAffectedReadmeTags(resolve(rootPath, changedSwagger)); - for (const [readmeEntry, tags] of readmeTagMapForChangedFile) { - if (!readmeTags.has(readmeEntry.path)) { - readmeTags.set(readmeEntry.path, new Set()); + for (const [readmePath, tags] of readmeTagMapForChangedFile) { + if (!readmeTags.has(readmePath)) { + readmeTags.set(readmePath, new Set()); } - for (const tag of tags) { - readmeTags.get(readmeEntry.path)?.add(tag.name); + for (const tagName of tags.keys()) { + readmeTags.get(readmePath)?.add(tagName); } } } @@ -123,8 +123,8 @@ export async function buildState( for (const changedSwagger of existingChangedFiles.filter(swagger)) { const service = getService(changedSwagger); const swaggerSet = await specModels.get(service)!.getAffectedSwaggers(resolve(rootPath, changedSwagger)); - for (const swaggerEntry of swaggerSet) { - affectedSwaggers.add(relative(rootPath, swaggerEntry.path)); + for (const swaggerPath of swaggerSet.keys()) { + affectedSwaggers.add(relative(rootPath, swaggerPath)); } } From c92c18a64f2b9a33ef72d505b9c5f4b28f9cfbcc Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 16 May 2025 02:03:46 +0000 Subject: [PATCH 4/6] Ensure map keys match values --- .github/shared/src/readme.js | 4 ++-- .github/shared/src/swagger.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/shared/src/readme.js b/.github/shared/src/readme.js index a54cf2f3fc1f..7dbcfc8f5780 100644 --- a/.github/shared/src/readme.js +++ b/.github/shared/src/readme.js @@ -172,12 +172,12 @@ export class Readme { logger: this.#logger, specModel: this.#specModel, }); - inputFiles.set(swaggerPathResolved, swagger); + inputFiles.set(swagger.path, swagger); } const tag = new Tag(tagName, inputFiles, { logger: this.#logger }); - tags.set(tagName, tag); + tags.set(tag.name, tag); } this.#data = { globalConfig, tags }; diff --git a/.github/shared/src/swagger.js b/.github/shared/src/swagger.js index bbebe51d2a8a..257ded6fb45c 100644 --- a/.github/shared/src/swagger.js +++ b/.github/shared/src/swagger.js @@ -51,13 +51,13 @@ export class Swagger { .filter((p) => resolve(p) !== resolve(this.#path)); this.#refs = new Map( - refPaths.map((p) => [ - p, - new Swagger(p, { + refPaths.map((p) => { + const swagger = new Swagger(p, { logger: this.#logger, specModel: this.#specModel, - }), - ]), + }); + return [swagger.path, swagger]; + }), ); } From 809a3c68dffde610d2edf9520094e47fbcde90c8 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 15 May 2025 19:08:22 -0700 Subject: [PATCH 5/6] Update .github/shared/src/spec-model.js --- .github/shared/src/spec-model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/shared/src/spec-model.js b/.github/shared/src/spec-model.js index 2cab49aa8837..d06912fdd8dd 100644 --- a/.github/shared/src/spec-model.js +++ b/.github/shared/src/spec-model.js @@ -80,7 +80,7 @@ export class SpecModel { } /** - * Given a swagger file, return the swagger files that are affected by + * Given a swagger file, return the swagger files that are affected by the * changes in the given swagger file. * @param {string} swaggerPath * @returns {Promise>} map of swagger paths to Swagger objects From 139fada172b6890dd4c3c13a856d3abb3f51c791 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 16 May 2025 02:10:25 +0000 Subject: [PATCH 6/6] ensure map keys match values --- .github/shared/src/spec-model.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/shared/src/spec-model.js b/.github/shared/src/spec-model.js index d06912fdd8dd..d514a32a82a4 100644 --- a/.github/shared/src/spec-model.js +++ b/.github/shared/src/spec-model.js @@ -175,10 +175,13 @@ export class SpecModel { this.#logger?.debug(`Found ${readmePaths.length} readme files`); this.#readmes = new Map( - readmePaths.map((p) => [ - p, - new Readme(p, { logger: this.#logger, specModel: this }), - ]), + readmePaths.map((p) => { + const readme = new Readme(p, { + logger: this.#logger, + specModel: this, + }); + return [readme.path, readme]; + }), ); }