From 61e6ec31d497e06b6272d664afded93db8dfee62 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 24 Oct 2024 16:57:50 -0400 Subject: [PATCH] Added editorial style guide checking. (#620) * Added editorial style guide checking. Signed-off-by: dblock Signed-off-by: Theo N. Truong Co-authored-by: Theo N. Truong --- .cspell | 13 ++ .../styles/OpenSearch/AcronymParentheses.yml | 75 +++++++++ .github/vale/styles/OpenSearch/Ampersand.yml | 6 + .github/vale/styles/OpenSearch/Cyber.yml | 5 + .../vale/styles/OpenSearch/DashSpacing.yml | 9 + .../styles/OpenSearch/DirectionAboveBelow.yml | 22 +++ .../styles/OpenSearch/DirectionTopBottom.yml | 16 ++ .../vale/styles/OpenSearch/Exclamation.yml | 6 + .../vale/styles/OpenSearch/FailoverNoun.yml | 7 + .../vale/styles/OpenSearch/FailoverVerb.yml | 7 + .../vale/styles/OpenSearch/FutureTense.yml | 7 + .github/vale/styles/OpenSearch/Inclusive.yml | 15 ++ .../OpenSearch/LatinismsElimination.yml | 10 ++ .../OpenSearch/LatinismsSubstitution.yml | 15 ++ .github/vale/styles/OpenSearch/LoginNoun.yml | 7 + .github/vale/styles/OpenSearch/LoginVerb.yml | 7 + .github/vale/styles/OpenSearch/LogoutNoun.yml | 7 + .github/vale/styles/OpenSearch/LogoutVerb.yml | 7 + .../vale/styles/OpenSearch/OxfordComma.yml | 7 + .../vale/styles/OpenSearch/PassiveVoice.yml | 45 +++++ .github/vale/styles/OpenSearch/Please.yml | 9 + .github/vale/styles/OpenSearch/Range.yml | 7 + .github/vale/styles/OpenSearch/Repetition.yml | 6 + .../vale/styles/OpenSearch/RolloverNoun.yml | 7 + .../vale/styles/OpenSearch/RolloverVerb.yml | 7 + .github/vale/styles/OpenSearch/SetupNoun.yml | 7 + .github/vale/styles/OpenSearch/SetupVerb.yml | 7 + .../vale/styles/OpenSearch/SignatureV4.yml | 11 ++ .github/vale/styles/OpenSearch/Simple.yml | 10 ++ .../styles/OpenSearch/SpacingPunctuation.yml | 9 + .../vale/styles/OpenSearch/SpacingSlash.yml | 6 + .../vale/styles/OpenSearch/SpacingWords.yml | 6 + .github/vale/styles/OpenSearch/Spelling.yml | 5 + .../styles/OpenSearch/SubstitutionsError.yml | 52 ++++++ .../OpenSearch/SubstitutionsSuggestion.yml | 16 ++ .../vale/styles/OpenSearch/TimeoutNoun.yml | 7 + .../vale/styles/OpenSearch/TimeoutVerb.yml | 7 + .github/vale/styles/OpenSearch/UnitsNames.yml | 12 ++ .../vale/styles/OpenSearch/UnitsSpacing.yml | 8 + .github/vale/styles/OpenSearch/Version.yml | 6 + .../OpenSearch/acronyms/accept.txt | 1 + .../OpenSearch/acronyms/reject.txt | 1 + .../OpenSearch/plugins/accept.txt | 30 ++++ .../OpenSearch/plugins/reject.txt | 1 + .../OpenSearch/products/accept.txt | 100 +++++++++++ .../OpenSearch/products/reject.txt | 1 + .../vocabularies/OpenSearch/words/accept.txt | 155 ++++++++++++++++++ .../vocabularies/OpenSearch/words/reject.txt | 1 + .github/workflows/lint.yml | 4 +- .github/workflows/style.yml | 31 ++++ .vale.ini | 49 ++++++ CHANGELOG.md | 1 + DEVELOPER_GUIDE.md | 93 ++++++----- package-lock.json | 1 + package.json | 4 +- .../src/prepare-for-vale/KeepDescriptions.ts | 55 +++++++ .../src/prepare-for-vale/prepare-for-vale.ts | 27 +++ .../prepare-for-vale/KeepDescriptions.test.ts | 43 +++++ .../tests/prepare-for-vale/fixtures/spec.txt | 26 +++ .../tests/prepare-for-vale/fixtures/spec.yaml | 26 +++ .../prepare-for-vale/prepare-for-vale.test.ts | 22 +++ 61 files changed, 1125 insertions(+), 45 deletions(-) create mode 100644 .github/vale/styles/OpenSearch/AcronymParentheses.yml create mode 100644 .github/vale/styles/OpenSearch/Ampersand.yml create mode 100644 .github/vale/styles/OpenSearch/Cyber.yml create mode 100644 .github/vale/styles/OpenSearch/DashSpacing.yml create mode 100644 .github/vale/styles/OpenSearch/DirectionAboveBelow.yml create mode 100644 .github/vale/styles/OpenSearch/DirectionTopBottom.yml create mode 100644 .github/vale/styles/OpenSearch/Exclamation.yml create mode 100644 .github/vale/styles/OpenSearch/FailoverNoun.yml create mode 100644 .github/vale/styles/OpenSearch/FailoverVerb.yml create mode 100644 .github/vale/styles/OpenSearch/FutureTense.yml create mode 100644 .github/vale/styles/OpenSearch/Inclusive.yml create mode 100644 .github/vale/styles/OpenSearch/LatinismsElimination.yml create mode 100644 .github/vale/styles/OpenSearch/LatinismsSubstitution.yml create mode 100644 .github/vale/styles/OpenSearch/LoginNoun.yml create mode 100644 .github/vale/styles/OpenSearch/LoginVerb.yml create mode 100644 .github/vale/styles/OpenSearch/LogoutNoun.yml create mode 100644 .github/vale/styles/OpenSearch/LogoutVerb.yml create mode 100644 .github/vale/styles/OpenSearch/OxfordComma.yml create mode 100644 .github/vale/styles/OpenSearch/PassiveVoice.yml create mode 100644 .github/vale/styles/OpenSearch/Please.yml create mode 100644 .github/vale/styles/OpenSearch/Range.yml create mode 100644 .github/vale/styles/OpenSearch/Repetition.yml create mode 100644 .github/vale/styles/OpenSearch/RolloverNoun.yml create mode 100644 .github/vale/styles/OpenSearch/RolloverVerb.yml create mode 100644 .github/vale/styles/OpenSearch/SetupNoun.yml create mode 100644 .github/vale/styles/OpenSearch/SetupVerb.yml create mode 100644 .github/vale/styles/OpenSearch/SignatureV4.yml create mode 100644 .github/vale/styles/OpenSearch/Simple.yml create mode 100644 .github/vale/styles/OpenSearch/SpacingPunctuation.yml create mode 100644 .github/vale/styles/OpenSearch/SpacingSlash.yml create mode 100644 .github/vale/styles/OpenSearch/SpacingWords.yml create mode 100644 .github/vale/styles/OpenSearch/Spelling.yml create mode 100644 .github/vale/styles/OpenSearch/SubstitutionsError.yml create mode 100644 .github/vale/styles/OpenSearch/SubstitutionsSuggestion.yml create mode 100644 .github/vale/styles/OpenSearch/TimeoutNoun.yml create mode 100644 .github/vale/styles/OpenSearch/TimeoutVerb.yml create mode 100644 .github/vale/styles/OpenSearch/UnitsNames.yml create mode 100644 .github/vale/styles/OpenSearch/UnitsSpacing.yml create mode 100644 .github/vale/styles/OpenSearch/Version.yml create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/acronyms/accept.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/acronyms/reject.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/plugins/accept.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/plugins/reject.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/products/accept.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/products/reject.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/words/accept.txt create mode 100644 .github/vale/styles/config/vocabularies/OpenSearch/words/reject.txt create mode 100644 .github/workflows/style.yml create mode 100644 .vale.ini create mode 100644 tools/src/prepare-for-vale/KeepDescriptions.ts create mode 100644 tools/src/prepare-for-vale/prepare-for-vale.ts create mode 100644 tools/tests/prepare-for-vale/KeepDescriptions.test.ts create mode 100644 tools/tests/prepare-for-vale/fixtures/spec.txt create mode 100644 tools/tests/prepare-for-vale/fixtures/spec.yaml create mode 100644 tools/tests/prepare-for-vale/prepare-for-vale.test.ts diff --git a/.cspell b/.cspell index 005f91cd5..274d2da09 100644 --- a/.cspell +++ b/.cspell @@ -51,10 +51,14 @@ fragmenter Fragmenter freqs generateonbehalfoftoken +geodistance geohash geohex Geohex geoip +geopoint +geoshape +geospatial geotile gsub Gsub @@ -65,6 +69,7 @@ homoscedastic hotthreads huggingface hybridfs +ignorecase integ internalusers Intertransport @@ -111,6 +116,7 @@ niofs nmslib nodeattrs nodesdn +nonword noops nori Nori @@ -128,7 +134,11 @@ Oversample performanceanalyzer permissionsinfo pipefail +preconfigure +preconfigured prefilter +pretrain +pretrained prirep rawfile readingform @@ -186,11 +196,13 @@ tfidf Tfidf thomaseizinger Tika +timeframe tlbr tokenfilters translog Translog trbl +truststore tubone Undeploys unigrams @@ -203,6 +215,7 @@ urldecode vectory whoamiprotected wordnet +yber Yrtsd جامد جامدات \ No newline at end of file diff --git a/.github/vale/styles/OpenSearch/AcronymParentheses.yml b/.github/vale/styles/OpenSearch/AcronymParentheses.yml new file mode 100644 index 000000000..a3deecc01 --- /dev/null +++ b/.github/vale/styles/OpenSearch/AcronymParentheses.yml @@ -0,0 +1,75 @@ +extends: conditional +message: "'%s': Spell out acronyms the first time that you use them on a page and follow them with the acronym in parentheses. Subsequently, use the acronym alone." +link: 'https://github.com/opensearch-project/documentation-website/blob/main/STYLE_GUIDE.md#acronyms' +level: warning +scope: summary +ignorecase: false +# Ensures that the existence of 'first' implies the existence of 'second'. +first: '\b((? -* [Developer Guide](#developer-guide) - * [Getting Started](#getting-started) - * [Specification](#specification) - * [File Structure](#file-structure) - * [Grouping Operations](#grouping-operations) - * [Grouping Schemas](#grouping-schemas) - * [Superseded Operations](#superseded-operations) - * [Global Parameters](#global-parameters) - * [OpenAPI Extensions](#openapi-extensions) - * [Writing Spec Tests](#writing-spec-tests) - * [Tools](#tools) - * [Setup](#setup) - * [Spec Merger](#spec-merger) - * [Arguments](#arguments) - * [Example](#example) - * [Spec Linter](#spec-linter) - * [Arguments](#arguments-1) - * [Example](#example-1) - * [Spec Tester](#spec-tester) - * [Dump Cluster Spec](#dump-cluster-spec) - * [Arguments](#arguments-2) - * [Example](#example-2) - * [Coverage](#coverage) - * [Arguments](#arguments-3) - * [Example](#example-3) - * [Tools Testing](#tools-testing) - * [Tools Linting](#tools-linting) - * [Workflows](#workflows) - * [Analyze PR Changes](#analyze-pr-changes) - * [Build](#build) - * [Deploy GitHub Pages](#deploy-github-pages) - * [Comment on PR](#comment-on-pr) - * [Test Tools (Unit)](#test-tools--unit-) - * [Test Tools (Integration)](#test-tools--integration-) - * [Validate Spec](#validate-spec) +- [Developer Guide](#developer-guide) + - [Getting Started](#getting-started) + - [Specification](#specification) + - [File Structure](#file-structure) + - [Grouping Operations](#grouping-operations) + - [Grouping Schemas](#grouping-schemas) + - [Superseded Operations](#superseded-operations) + - [Global Parameters](#global-parameters) + - [OpenAPI Extensions](#openapi-extensions) + - [Writing Spec Tests](#writing-spec-tests) + - [Tools](#tools) + - [Setup](#setup) + - [Spec Merger](#spec-merger) + - [Spec Linter](#spec-linter) + - [Spec Tester](#spec-tester) + - [Spec Style](#spec-style) + - [Dump Cluster Spec](#dump-cluster-spec) + - [Coverage](#coverage) + - [Tools Testing](#tools-testing) + - [Tools Linting](#tools-linting) + - [Workflows](#workflows) + - [Analyze PR Changes](#analyze-pr-changes) + - [Build](#build) + - [Deploy GitHub Pages](#deploy-github-pages) + - [Comment on PR](#comment-on-pr) + - [Test Tools (Unit)](#test-tools-unit) + - [Test Tools (Integration)](#test-tools-integration) + - [Validate Spec](#validate-spec) # Developer Guide @@ -173,13 +166,13 @@ npm run merge -- --help The merger tool merges the multi-file OpenSearch spec into a single file for programmatic use. -#### Arguments +**Arguments** - `--source `: The path to the root folder of the multi-file spec, defaults to `/spec`. - `--output `: The path to write the final merged spec to, defaults to `/build/opensearch-openapi.yaml`. - `--opensearch-version`: An optional target version of OpenSearch, checking values of `x-version-added` and `x-version-removed`. -#### Example +**Example** We can take advantage of the default values and simply merge the specification via: ```bash @@ -200,11 +193,11 @@ npm run lint:spec -- --help The linter tool validates the OpenSearch multi-file spec, and will print out all the errors and warnings in it. -#### Arguments +**Arguments** - `--source `: The path to the root folder of the multi-file spec, defaults to `/spec`. -#### Example +**Example** We can take advantage of the default values and simply lint the specification via: ```bash @@ -219,6 +212,20 @@ npm run test:spec -- --help The spec test framework validates the OpenSearch spec against a running OpenSearch cluster. As you modify the spec, you should add or update the spec test stories in the [./tests](tests) directory. For information on this topic, see [TESTING_GUIDE.md](TESTING_GUIDE.md). +### Spec Style + +This repo runs [Vale](https://github.com/errata-ai/vale) on the text contents of the spec, such as descriptions. + +The [Style prepare tool](tools/src/prepare-for-vale/) clears YAML files from all markup and leaves text in-place in the [style workflow](.github/workflows/style.yml), allowing for comments to appear in pull requests on GitHub. + +```bash +npm run style:prepare -- --help +``` + +**Arguments** + +- `--source `: The path to the root folder of the multi-file spec, defaults to `/spec`. + ### [Dump Cluster Spec](tools/src/dump-cluster-spec) ```bash @@ -227,7 +234,7 @@ npm run dump-cluster-spec -- --help The dump-cluster-spec tool connects to an OpenSearch cluster which has the [opensearch-api plugin](https://github.com/dblock/opensearch-api) installed and dumps the skeleton OpenAPI specification it provides to a file. -#### Arguments +**Arguments** - `--opensearch-url `: The URL at which the cluster is accessible, defaults to `https://localhost:9200`. - `--opensearch-insecure`: Disable SSL/TLS certificate verification, defaults to performing verification. @@ -235,7 +242,7 @@ The dump-cluster-spec tool connects to an OpenSearch cluster which has the [open - `--opensearch-password `: The password to authenticate with the cluster, also settable via the `OPENSEARCH_PASSWORD` environment variable. - `--output `: The path to write the dumped spec to, defaults to `/build/opensearch-openapi-CLUSTER.yaml`. -#### Example +**Example** You can use this repo's [docker image which includes the opensearch-api plugin](coverage/Dockerfile) to spin up a local development cluster with a self-signed certificate (e.g. `https://localhost:9200`) and security enabled, to then dump the skeleton specification: ```bash @@ -264,13 +271,13 @@ npm run coverage:spec -- --help The coverage tool determines which APIs from the OpenSearch cluster's reference skeleton specification (dumped by the [dump-cluster-spec tool](#dump-cluster-spec)) are covered by this specification (as built by the [merger tool](#merger)). -#### Arguments +**Arguments** - `--cluster `: The path to the cluster's reference skeleton specification, as dumped by [dump-cluster-spec](#dump-cluster-spec), defaults to `/build/opensearch-openapi-CLUSTER.yaml`. - `--specification `: The path to the merged specification, as built by [merger](#merger), defaults to `/build/opensearch-openapi.yaml`. - `--output `: The path to write the coverage data to, defaults to `/build/coverage.json`. -#### Example +**Example** Assuming you've already followed the previous examples to build the merged specification with the [merger](#example) and dump the cluster's specification with [dump-cluster-spec](#example-2), you can then calculate the API coverage: ```bash diff --git a/package-lock.json b/package-lock.json index a6dae5581..7e903482a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-yml": "^1.14.0", + "fast-glob": "^3.3.2", "globals": "^15.0.0", "json-diff-ts": "^4.0.1", "json-schema-to-typescript": "^14.0.4", diff --git a/package.json b/package.json index 5244756f3..a0715e2a2 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "lint": "eslint . --report-unused-disable-directives", "lint--fix": "eslint . --fix --report-unused-disable-directives", "merge": "ts-node tools/src/merger/merge.ts", + "style:prepare": "ts-node tools/src/prepare-for-vale/prepare-for-vale.ts", "test": "npm run test:unit && npm run test:integ", "jest": "jest", "test:unit": "jest --testMatch='**/*.test.ts' --testPathIgnorePatterns=/integ/", @@ -34,12 +35,12 @@ "@types/titlecase": "^1.1.2", "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^6.21.0", - "axios-mock-adapter": "^2.0.0", "ajv": "^8.13.0", "ajv-errors": "^3.0.0", "ajv-formats": "^3.0.1", "aws4-axios": "^3.3.7", "axios": "^1.7.5", + "axios-mock-adapter": "^2.0.0", "cbor": "^9.0.2", "commander": "^12.0.0", "eslint": "^8.57.0", @@ -51,6 +52,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-yml": "^1.14.0", + "fast-glob": "^3.3.2", "globals": "^15.0.0", "json-diff-ts": "^4.0.1", "json-schema-to-typescript": "^14.0.4", diff --git a/tools/src/prepare-for-vale/KeepDescriptions.ts b/tools/src/prepare-for-vale/KeepDescriptions.ts new file mode 100644 index 000000000..6d6da3ae2 --- /dev/null +++ b/tools/src/prepare-for-vale/KeepDescriptions.ts @@ -0,0 +1,55 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import fs from 'fs' +import fg from 'fast-glob' +import { Logger } from '../Logger' + +/** + * Keeps only description: field values. + */ +export default class KeepDescriptions { + root_folder: string + logger: Logger + + constructor (root_folder: string, logger: Logger = new Logger()) { + this.logger = logger + this.root_folder = fs.realpathSync(root_folder) + } + + process(): void { + this.root_folder + const files = fg.globSync([`${this.root_folder}/**/*.yaml`]) + files.forEach((path) => { + this.logger.log(path) + this.process_file(path) + }) + } + + process_file(filename: string): void { + const contents = fs.readFileSync(filename, 'utf-8') + var writer = fs.openSync(filename, 'w+') + + var inside_description = false + contents.split(/\r?\n/).forEach((line) => { + if (line.match(/^[\s]+(description: \|)/)) { + inside_description = true + } else if (line.match(/^[\s]+(description:)[\s]+/)) { + fs.writeSync(writer, line.replace("description:", " ")) + } else if (inside_description && line.match(/^[\s]*[\w]*:/)) { + inside_description = false + } else if (inside_description) { + fs.writeSync(writer, line) + } + if (line.length > 0) { + fs.writeSync(writer, "\n") + } + }) + } +} diff --git a/tools/src/prepare-for-vale/prepare-for-vale.ts b/tools/src/prepare-for-vale/prepare-for-vale.ts new file mode 100644 index 000000000..9c6c3ceb0 --- /dev/null +++ b/tools/src/prepare-for-vale/prepare-for-vale.ts @@ -0,0 +1,27 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import { Command, Option } from '@commander-js/extra-typings' +import { Logger, LogLevel } from '../Logger' +import { resolve } from 'path' +import KeepDescriptions from './KeepDescriptions' + +const command = new Command() + .description('Convert YAML files to text.') + .addOption(new Option('-s, --source ', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../../spec'))) + .addOption(new Option('--verbose', 'show merge details').default(false)) + .allowExcessArguments(false) + .parse() + +const opts = command.opts() +const logger = new Logger(opts.verbose ? LogLevel.info : LogLevel.warn) +const keep_descriptions = new KeepDescriptions(opts.source, logger) +logger.log(`Preparing ${opts.source} ...`) +keep_descriptions.process() +logger.log('Done.') diff --git a/tools/tests/prepare-for-vale/KeepDescriptions.test.ts b/tools/tests/prepare-for-vale/KeepDescriptions.test.ts new file mode 100644 index 000000000..0c595299b --- /dev/null +++ b/tools/tests/prepare-for-vale/KeepDescriptions.test.ts @@ -0,0 +1,43 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import KeepDescriptions from 'prepare-for-vale/KeepDescriptions' +import fs from 'fs' +import fg from 'fast-glob' +import tmp from 'tmp' + +describe('KeepDescriptions', () => { + var temp: tmp.DirResult + var fixture_path: string = './tools/tests/prepare-for-vale/fixtures' + var fixtures = fg.globSync(`${fixture_path}/**/*.yaml`) + + describe('defaults', () => { + beforeAll(() => { + temp = tmp.dirSync() + fs.cpSync(fixture_path, temp.name, { recursive: true }) + new KeepDescriptions(temp.name).process() + }) + + afterAll(() => { + temp.removeCallback() + }) + + describe('converts files to text in-place', () => { + fixtures.forEach((filename) => { + test(filename, () => { + const processed_yaml = filename.replace(fixture_path, temp.name) + const filename_txt = processed_yaml.replace(".yaml", ".txt") + expect(fs.readFileSync(processed_yaml, 'utf8')).toEqual(fs.readFileSync(filename_txt, 'utf8')) + fs.rmSync(processed_yaml) + fs.rmSync(filename_txt) + }) + }) + }) + }) +}) \ No newline at end of file diff --git a/tools/tests/prepare-for-vale/fixtures/spec.txt b/tools/tests/prepare-for-vale/fixtures/spec.txt new file mode 100644 index 000000000..a54608e03 --- /dev/null +++ b/tools/tests/prepare-for-vale/fixtures/spec.txt @@ -0,0 +1,26 @@ + + + + A description that is preserved. + + + + + + + + For a successful response, this value is always true. On failure, an exception is returned instead. + + + + The item level REST category class codes during indexing. + + + + Line one + Line two + + + + Line one + Line with a description: that describes itself. diff --git a/tools/tests/prepare-for-vale/fixtures/spec.yaml b/tools/tests/prepare-for-vale/fixtures/spec.yaml new file mode 100644 index 000000000..8801c55e2 --- /dev/null +++ b/tools/tests/prepare-for-vale/fixtures/spec.yaml @@ -0,0 +1,26 @@ +openapi: 3.1.0 +info: + title: A title that is preserved. + description: A description that is preserved. + version: 1.0.0 +components: + schemas: + ObjectWithDescription: + type: object + properties: + acknowledged: + description: For a successful response, this value is always true. On failure, an exception is returned instead. + type: boolean + ObjectWithMultilineDescriptionOneLine: + description: |- + The item level REST category class codes during indexing. + type: object + ObjectWithMultilineDescriptionTwoLines: + description: |- + Line one + Line two + ObjectWithAColonInDescription: + type: object + description: |- + Line one + Line with a description: that describes itself. diff --git a/tools/tests/prepare-for-vale/prepare-for-vale.test.ts b/tools/tests/prepare-for-vale/prepare-for-vale.test.ts new file mode 100644 index 000000000..c46fc7340 --- /dev/null +++ b/tools/tests/prepare-for-vale/prepare-for-vale.test.ts @@ -0,0 +1,22 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import { spawnSync } from 'child_process' + +const spec = (args: string[]): any => { + const start = spawnSync('ts-node', ['tools/src/prepare-for-vale/prepare-for-vale.ts'].concat(args)) + return { + stdout: start.stdout?.toString(), + stderr: start.stderr?.toString() + } +} + +test('--help', () => { + expect(spec(['--help']).stdout).toContain('Usage: prepare-for-vale [options]') +})