From 7097d88f5e7ad39ae65240aa84d9dc0128e9ba15 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 13 Aug 2024 12:41:31 -0400 Subject: [PATCH] Undo semver satisfies changes. Signed-off-by: dblock --- DEVELOPER_GUIDE.md | 2 +- tools/src/_utils/semver.ts | 2 +- tools/src/tester/StoryEvaluator.ts | 8 ++------ tools/src/tester/TestRunner.ts | 2 +- tools/src/types.ts | 4 ++-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index f719b10ef..43c30d7f3 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -149,7 +149,7 @@ This repository includes several OpenAPI Specification Extensions to fill in any - `x-distributions-included`: Contains a list of distributions known to include the API. - `x-distributions-excluded`: Contains a list of distributions known to exclude the API. -Use `opensearch.org` for the official distribution in `x-distributions-*`, `amazon-opensearch` for Amazon Managed OpenSearch, and `amazon-serverless` for Amazon OpenSearch Serverless. +Use `opensearch.org` for the official distribution in `x-distributions-*`, `amazon-managed` for Amazon Managed OpenSearch, and `amazon-serverless` for Amazon OpenSearch Serverless. ## Writing Spec Tests diff --git a/tools/src/_utils/semver.ts b/tools/src/_utils/semver.ts index 7f431001c..836c802ea 100644 --- a/tools/src/_utils/semver.ts +++ b/tools/src/_utils/semver.ts @@ -10,7 +10,7 @@ import * as semver from 'semver' export function coerce(version?: string): undefined | string { - if (version == undefined) return undefined + if (version === undefined) return undefined return semver.coerce(version)?.toString() ?? version } diff --git a/tools/src/tester/StoryEvaluator.ts b/tools/src/tester/StoryEvaluator.ts index 6bb89e1cf..3f396a3c6 100644 --- a/tools/src/tester/StoryEvaluator.ts +++ b/tools/src/tester/StoryEvaluator.ts @@ -27,7 +27,7 @@ export default class StoryEvaluator { } async evaluate({ story, display_path, full_path }: StoryFile, version?: string, distribution?: string, dry_run: boolean = false): Promise { - if (version !== undefined && story.version !== undefined && !StoryEvaluator.#semver_satisfies(version, story.version)) { + if (version !== undefined && story.version !== undefined && !semver.satisfies(version, story.version)) { return { result: Result.SKIPPED, display_path, @@ -92,7 +92,7 @@ export default class StoryEvaluator { if (dry_run) { const title = chapter.synopsis || `${chapter.method} ${chapter.path}` evaluations.push({ title, overall: { result: Result.SKIPPED, message: 'Dry Run', error: undefined } }) - } else if (version != undefined && chapter.version !== undefined && !StoryEvaluator.#semver_satisfies(version, chapter.version)) { + } else if (version != undefined && chapter.version !== undefined && !semver.satisfies(version, chapter.version)) { const title = chapter.synopsis || `${chapter.method} ${chapter.path}` evaluations.push({ title, overall: { result: Result.SKIPPED, message: `Skipped because version ${version} does not satisfy ${chapter.version}.`, error: undefined } }) } else if (distribution != undefined && chapter.distributions !== undefined && !chapter.distributions.includes(distribution)) { @@ -236,8 +236,4 @@ export default class StoryEvaluator { static #failed_evaluation(title: string, message: string): ChapterEvaluation { return { title, overall: { result: Result.FAILED, message } } } - - static #semver_satisfies(version: string, range: string): boolean { - return _.every(range.split(','), (portion) => semver.satisfies(version, portion)) - } } diff --git a/tools/src/tester/TestRunner.ts b/tools/src/tester/TestRunner.ts index 7432fe0b4..dc880f946 100644 --- a/tools/src/tester/TestRunner.ts +++ b/tools/src/tester/TestRunner.ts @@ -40,7 +40,7 @@ export default class TestRunner { const results: StoryEvaluations = { evaluations: [] } if (!dry_run) { - if (distribution === 'aoss') { + if (distribution === 'amazon-serverless') { // TODO: Fetch OpenSearch version when Amazon Serverless OpenSearch supports multiple. version = '2.1' } else { diff --git a/tools/src/types.ts b/tools/src/types.ts index d40726b5f..b6871d022 100644 --- a/tools/src/types.ts +++ b/tools/src/types.ts @@ -16,8 +16,8 @@ export interface OperationSpec extends OpenAPIV3.OperationObject { 'x-version-deprecated'?: string 'x-deprecation-message'?: string 'x-ignorable'?: boolean - 'x-distributions-included'?: string - 'x-distributions-excluded'?: string + 'x-distributions-included'?: string[] + 'x-distributions-excluded'?: string[] parameters?: OpenAPIV3.ReferenceObject[] requestBody?: OpenAPIV3.ReferenceObject