From 6464577d16cd4196e4839791815f133b278067cb Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 6 Jun 2024 09:17:52 -0400 Subject: [PATCH] Turn on yml/indent. Signed-off-by: dblock --- .github/opensearch-cluster/docker-compose.yml | 2 +- .github/workflows/check-links.yml | 4 +- .github/workflows/deploy-gh-pages.yml | 2 +- .github/workflows/pr-comment.yml | 2 +- .github/workflows/test-spec.yml | 24 ++++---- .github/workflows/test-tools.yml | 12 ++-- CHANGELOG.md | 3 +- DEVELOPER_GUIDE.md | 2 +- eslint.config.mjs | 4 +- json_schemas/test_story.schema.yaml | 16 +++--- .../anonymous_schemas/namespaces/shelter.yaml | 56 +++++++++---------- .../anonymous_schemas/schemas/actions.yaml | 10 ++-- .../anonymous_schemas/schemas/animals.yaml | 16 +++--- .../named_schemas/namespaces/shelter.yaml | 36 ++++++------ .../named_schemas/schemas/actions.yaml | 10 ++-- .../named_schemas/schemas/animals.yaml | 16 +++--- .../fixtures/spec/namespaces/indices.yaml | 56 +++++++++---------- .../fixtures/spec/namespaces/shelter.yaml | 36 ++++++------ .../merger/fixtures/spec/schemas/actions.yaml | 10 ++-- .../merger/fixtures/spec/schemas/animals.yaml | 16 +++--- .../fixtures/evals/error/chapter_error.yaml | 2 +- 21 files changed, 168 insertions(+), 167 deletions(-) diff --git a/.github/opensearch-cluster/docker-compose.yml b/.github/opensearch-cluster/docker-compose.yml index 46738ade5..2f1e4363d 100644 --- a/.github/opensearch-cluster/docker-compose.yml +++ b/.github/opensearch-cluster/docker-compose.yml @@ -7,5 +7,5 @@ services: - "9200:9200" - "9600:9600" environment: - - "discovery.type=single-node" + - discovery.type=single-node - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}" \ No newline at end of file diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml index 907d053b9..20dc5205a 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/check-links.yml @@ -1,8 +1,6 @@ name: Check Links -on: - push: - pull_request: +on: [push, pull_request] jobs: check: diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 8f5112618..2aa5668b1 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -7,7 +7,7 @@ on: - main concurrency: - group: "pages" + group: pages cancel-in-progress: false permissions: diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index ae8109f38..f66217f69 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -35,7 +35,7 @@ jobs: COMMENT_IDENTIFIER=$(jq -r '.comment_identifier' ./pr-comment.json) TEMPLATE_NAME=$(jq -r '.template_name' ./pr-comment.json) TEMPLATE_DATA=$(jq -c '.template_data' ./pr-comment.json) - + vars=( PR_NUMBER COMMENT_IDENTIFIER diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index e49eb534d..4837c221f 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -2,19 +2,19 @@ name: Test Spec on: push: - branches: [ '**' ] - paths: - - 'package*.json' - - 'tsconfig.json' - - 'tools/src/tester/**' - - 'spec/**' + branches: ['**'] + paths: + - 'package*.json' + - tsconfig.json + - 'tools/src/tester/**' + - 'spec/**' pull_request: - branches: [ '**' ] - paths: - - 'package*.json' - - 'tsconfig.json' - - 'tools/src/tester/**' - - 'spec/**' + branches: ['**'] + paths: + - 'package*.json' + - tsconfig.json + - 'tools/src/tester/**' + - 'spec/**' jobs: test-opensearch-spec: diff --git a/.github/workflows/test-tools.yml b/.github/workflows/test-tools.yml index eed811e1d..4c86adcc0 100644 --- a/.github/workflows/test-tools.yml +++ b/.github/workflows/test-tools.yml @@ -5,17 +5,17 @@ on: branches: ['**'] paths: - 'package*.json' - - 'eslint.config.mjs' - - 'jest.config.js' - - 'tsconfig.json' + - eslint.config.mjs + - jest.config.js + - tsconfig.json - 'tools/**' pull_request: branches: ['**'] paths: - 'package*.json' - - 'eslint.config.mjs' - - 'jest.config.js' - - 'tsconfig.json' + - eslint.config.mjs + - jest.config.js + - tsconfig.json - 'tools/**' jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aeadb5bd..43f2a7b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added license headers to TypeScript code ([#311](https://github.com/opensearch-project/opensearch-api-specification/pull/311)) - Added `npm run test:spec -- --dry-run --verbose` ([#303](https://github.com/opensearch-project/opensearch-api-specification/pull/303)) - Added `npm run test:unit` and `test:integ` ([#320](https://github.com/opensearch-project/opensearch-api-specification/pull/320)) - +- Added a YAML linter ([#312](https://github.com/opensearch-project/opensearch-api-specification/pull/312)) + ### Changed - Replaced Smithy with a native OpenAPI spec ([#189](https://github.com/opensearch-project/opensearch-api-specification/issues/189)) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index d8efe265a..7798bba67 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -387,7 +387,7 @@ The test suite contains unit tests and integration tests. Integration tests, suc #### Lints -All code is linted using [ESLint](https://eslint.org/) in combination with [typescript-eslint](https://typescript-eslint.io/). Linting can be run via: +All TypeScript code and YAML files are linted using [ESLint](https://eslint.org/), [typescript-eslint](https://typescript-eslint.io/), and [eslint-plugin-yml](https://ota-meshi.github.io/eslint-plugin-yml/). Linting can be run via: ```bash npm run lint ``` diff --git a/eslint.config.mjs b/eslint.config.mjs index 1f5e42c5a..1f34d6d2b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -72,6 +72,7 @@ export default [ 'new-cap': 'off', 'no-return-assign': 'error', 'object-shorthand': 'error', + 'no-constant-condition': 'off', 'license-header/header': [ 'error', [ @@ -98,7 +99,8 @@ export default [ }, rules: { 'yml/no-empty-document': 'off', - 'yml/quotes': ['error', { prefer: 'single' }] + 'yml/quotes': 'off', + 'yml/plain-scalar': 'off' } } ] diff --git a/json_schemas/test_story.schema.yaml b/json_schemas/test_story.schema.yaml index 55fcb6cc1..c4fc10a20 100644 --- a/json_schemas/test_story.schema.yaml +++ b/json_schemas/test_story.schema.yaml @@ -23,7 +23,7 @@ properties: items: $ref: '#/definitions/Chapter' minItems: 1 -required: [ description, chapters] +required: [description, chapters] additionalProperties: false definitions: @@ -37,7 +37,7 @@ definitions: description: A brief description of the chapter. response: $ref: '#/definitions/ExpectedResponse' - required: [ synopsis ] + required: [synopsis] additionalProperties: false ReadChapter: @@ -47,7 +47,7 @@ definitions: properties: response: $ref: '#/definitions/ActualResponse' - required: [ response ] + required: [response] additionalProperties: false SupplementalChapter: @@ -70,14 +70,14 @@ definitions: type: string method: type: string - enum: [ GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS ] + enum: [GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS] parameters: type: object additionalProperties: $ref: '#/definitions/Parameter' request_body: $ref: '#/definitions/RequestBody' - required: [ path, method ] + required: [path, method] additionalProperties: false @@ -89,7 +89,7 @@ definitions: default: application/json payload: $ref: '#/definitions/Payload' - required: [ payload ] + required: [payload] additionalProperties: false ExpectedResponse: @@ -104,7 +104,7 @@ definitions: default: application/json payload: $ref: '#/definitions/Payload' - required: [ status ] + required: [status] additionalProperties: false ActualResponse: @@ -122,7 +122,7 @@ definitions: error: type: object description: Error object. - required: [ status, content_type, payload ] + required: [status, content_type, payload] additionalProperties: false Payload: diff --git a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml index 9eb26cb84..ef54b0130 100644 --- a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml @@ -24,31 +24,31 @@ paths: '200': $ref: '#/components/responses/adopt@200' components: - requestBodies: - adopt: { - content: { - application/json: { - schema: { - type: object2 - } - } - } - } - parameters: - adopt::path.animal: - name: animal - in: path - schema: - $ref: '../schemas/animals.yaml#/components/schemas/Animal' - adopt::path.docket: - name: docket - in: path - schema: - type: number2 - responses: - adopt@200: - description: '' - content: - application/json: - schema: - type: object2 \ No newline at end of file + requestBodies: + adopt: + content: + application/json: + schema: + type: object2 + + + + + parameters: + adopt::path.animal: + name: animal + in: path + schema: + $ref: '../schemas/animals.yaml#/components/schemas/Animal' + adopt::path.docket: + name: docket + in: path + schema: + type: number2 + responses: + adopt@200: + description: '' + content: + application/json: + schema: + type: object2 \ No newline at end of file diff --git a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/actions.yaml b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/actions.yaml index 89bec0877..66c856d72 100644 --- a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/actions.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/actions.yaml @@ -4,8 +4,8 @@ info: description: OpenSearch API version: 1.0.0 components: - schemas: - Bark: - type: string - Meow: - type: string \ No newline at end of file + schemas: + Bark: + type: string + Meow: + type: string \ No newline at end of file diff --git a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/animals.yaml b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/animals.yaml index bdb82a16f..28db7f11e 100644 --- a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/animals.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/schemas/animals.yaml @@ -10,12 +10,12 @@ components: - $ref: '#/components/schemas/Dog' - $ref: '#/components/schemas/Cat' Dog: - type: object - properties: - bark: - $ref: 'actions.yaml#/components/schemas/Bark' + type: object + properties: + bark: + $ref: 'actions.yaml#/components/schemas/Bark' Cat: - type: object - properties: - meow: - $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file + type: object + properties: + meow: + $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file diff --git a/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml b/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml index 0f1a2970b..4072426cc 100644 --- a/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml @@ -24,22 +24,22 @@ paths: '200': $ref: '#/components/responses/adopt@200' components: - requestBodies: - adopt: {} - parameters: - adopt::path.animal: - name: animal - in: path + requestBodies: + adopt: {} + parameters: + adopt::path.animal: + name: animal + in: path + schema: + $ref: '../schemas/animals.yaml#/components/schemas/Animal' + adopt::path.docket: + name: docket + in: path + schema: + type: number + responses: + adopt@200: + description: '' + application/json: schema: - $ref: '../schemas/animals.yaml#/components/schemas/Animal' - adopt::path.docket: - name: docket - in: path - schema: - type: number - responses: - adopt@200: - description: '' - application/json: - schema: - type: object \ No newline at end of file + type: object \ No newline at end of file diff --git a/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/actions.yaml b/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/actions.yaml index 24dbbb8d6..37996023d 100644 --- a/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/actions.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/actions.yaml @@ -4,8 +4,8 @@ info: description: OpenSearch API version: 1.0.0 components: - schemas: - Bark: - type: bogus - Meow: - type: string \ No newline at end of file + schemas: + Bark: + type: bogus + Meow: + type: string \ No newline at end of file diff --git a/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/animals.yaml b/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/animals.yaml index 6bf0f10f5..567e6261a 100644 --- a/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/animals.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/named_schemas/schemas/animals.yaml @@ -10,12 +10,12 @@ components: - $ref: '#/components/schemas/Dog' - $ref: '#/components/schemas/Cat' Dog: - type: bogus - properties: - bark: - $ref: 'actions.yaml#/components/schemas/Bark' + type: bogus + properties: + bark: + $ref: 'actions.yaml#/components/schemas/Bark' Cat: - type: object - properties: - meow: - $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file + type: object + properties: + meow: + $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file diff --git a/tools/tests/merger/fixtures/spec/namespaces/indices.yaml b/tools/tests/merger/fixtures/spec/namespaces/indices.yaml index f8a7688cd..966038f3f 100644 --- a/tools/tests/merger/fixtures/spec/namespaces/indices.yaml +++ b/tools/tests/merger/fixtures/spec/namespaces/indices.yaml @@ -3,33 +3,33 @@ info: title: Ignored version: 1.0.0 paths: - '/{index}': - post: - parameters: - - $ref: '#/components/parameters/indices.create::path.index' - - $ref: '#/components/parameters/indices.create::query.pretty' - requestBody: - $ref: '#/components/requestBodies/indices.create' - responses: - '200': - $ref: '#/components/responses/indices.create@200' + '/{index}': + post: + parameters: + - $ref: '#/components/parameters/indices.create::path.index' + - $ref: '#/components/parameters/indices.create::query.pretty' + requestBody: + $ref: '#/components/requestBodies/indices.create' + responses: + '200': + $ref: '#/components/responses/indices.create@200' components: - requestBodies: - indices.create: {} - parameters: - indices.create::path.index: - name: index - in: path + requestBodies: + indices.create: {} + parameters: + indices.create::path.index: + name: index + in: path + schema: + type: string + indices.create::query.pretty: + name: pretty + in: query + schema: + type: boolean + responses: + indices.create@200: + description: '' + application/json: schema: - type: string - indices.create::query.pretty: - name: pretty - in: query - schema: - type: boolean - responses: - indices.create@200: - description: '' - application/json: - schema: - type: object \ No newline at end of file + type: object \ No newline at end of file diff --git a/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml b/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml index 0f1a2970b..4072426cc 100644 --- a/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml +++ b/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml @@ -24,22 +24,22 @@ paths: '200': $ref: '#/components/responses/adopt@200' components: - requestBodies: - adopt: {} - parameters: - adopt::path.animal: - name: animal - in: path + requestBodies: + adopt: {} + parameters: + adopt::path.animal: + name: animal + in: path + schema: + $ref: '../schemas/animals.yaml#/components/schemas/Animal' + adopt::path.docket: + name: docket + in: path + schema: + type: number + responses: + adopt@200: + description: '' + application/json: schema: - $ref: '../schemas/animals.yaml#/components/schemas/Animal' - adopt::path.docket: - name: docket - in: path - schema: - type: number - responses: - adopt@200: - description: '' - application/json: - schema: - type: object \ No newline at end of file + type: object \ No newline at end of file diff --git a/tools/tests/merger/fixtures/spec/schemas/actions.yaml b/tools/tests/merger/fixtures/spec/schemas/actions.yaml index 89bec0877..66c856d72 100644 --- a/tools/tests/merger/fixtures/spec/schemas/actions.yaml +++ b/tools/tests/merger/fixtures/spec/schemas/actions.yaml @@ -4,8 +4,8 @@ info: description: OpenSearch API version: 1.0.0 components: - schemas: - Bark: - type: string - Meow: - type: string \ No newline at end of file + schemas: + Bark: + type: string + Meow: + type: string \ No newline at end of file diff --git a/tools/tests/merger/fixtures/spec/schemas/animals.yaml b/tools/tests/merger/fixtures/spec/schemas/animals.yaml index bdb82a16f..28db7f11e 100644 --- a/tools/tests/merger/fixtures/spec/schemas/animals.yaml +++ b/tools/tests/merger/fixtures/spec/schemas/animals.yaml @@ -10,12 +10,12 @@ components: - $ref: '#/components/schemas/Dog' - $ref: '#/components/schemas/Cat' Dog: - type: object - properties: - bark: - $ref: 'actions.yaml#/components/schemas/Bark' + type: object + properties: + bark: + $ref: 'actions.yaml#/components/schemas/Bark' Cat: - type: object - properties: - meow: - $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file + type: object + properties: + meow: + $ref: 'actions.yaml#/components/schemas/Meow' \ No newline at end of file diff --git a/tools/tests/tester/fixtures/evals/error/chapter_error.yaml b/tools/tests/tester/fixtures/evals/error/chapter_error.yaml index 5a3b6977c..2a11f2e54 100644 --- a/tools/tests/tester/fixtures/evals/error/chapter_error.yaml +++ b/tools/tests/tester/fixtures/evals/error/chapter_error.yaml @@ -25,7 +25,7 @@ chapters: status: result: ERROR message: 'Expected status 200, but received 404: application/json. no such index - [undefined]' + [undefined]' error: Request failed with status code 404 payload: result: SKIPPED