From 2aa4911fae2d265f9f0e5d63af7e0673e4b4b4fc Mon Sep 17 00:00:00 2001 From: dblock Date: Mon, 13 May 2024 09:56:19 -0400 Subject: [PATCH] Use standard src/tests paths. Signed-off-by: dblock --- .github/workflows/lint.yml | 7 ++----- .github/workflows/tools.yml | 7 ++----- DEVELOPER_GUIDE.md | 4 ++-- jest.config.js | 3 ++- package.json | 4 ++-- {tools => src}/README.md | 0 {tools => src}/helpers.ts | 0 {tools => src}/linter/InlineObjectSchemaValidator.ts | 0 {tools => src}/linter/SchemaRefsValidator.ts | 0 {tools => src}/linter/SpecValidator.ts | 0 {tools => src}/linter/components/InfoFile.ts | 0 {tools => src}/linter/components/NamespaceFile.ts | 0 {tools => src}/linter/components/NamespacesFolder.ts | 0 {tools => src}/linter/components/Operation.ts | 0 {tools => src}/linter/components/OperationGroup.ts | 0 {tools => src}/linter/components/Schema.ts | 0 {tools => src}/linter/components/SchemaFile.ts | 0 {tools => src}/linter/components/SchemasFolder.ts | 0 .../linter/components/SupersededOperationsFile.ts | 0 {tools => src}/linter/components/base/FileValidator.ts | 0 .../linter/components/base/FolderValidator.ts | 0 {tools => src}/linter/components/base/ValidatorBase.ts | 0 {tools => src}/linter/lint.ts | 0 {tools => src}/linter/utils/SpecificationVisitor.ts | 0 {tools => src}/linter/utils/index.ts | 0 {tools => src}/merger/GlobalParamsGenerator.ts | 0 {tools => src}/merger/OpenApiMerger.ts | 0 {tools => src}/merger/OpenDistro.ts | 0 {tools => src}/merger/SupersededOpsGenerator.ts | 0 {tools => src}/merger/merge.ts | 2 +- {tools => src}/types.ts | 0 tests/{tools => }/linter/InfoFile.test.ts | 4 ++-- .../linter/InlineObjectSchemaValidator.test.ts | 8 ++++---- tests/{tools => }/linter/NamespaceFile.test.ts | 0 tests/{tools => }/linter/NamespacesFolder.test.ts | 6 +++--- tests/{tools => }/linter/Operation.test.ts | 0 tests/{tools => }/linter/OperationGroup.test.ts | 0 tests/{tools => }/linter/Schema.test.ts | 0 tests/{tools => }/linter/SchemaFile.test.ts | 0 tests/{tools => }/linter/SchemaRefsValidator.test.ts | 8 ++++---- tests/{tools => }/linter/SpecValidator.test.ts | 4 ++-- .../linter/SupersededOperationsFile.test.ts | 4 ++-- tests/{tools => }/linter/factories/namespace_file.ts | 4 ++-- tests/{tools => }/linter/factories/operation.ts | 4 ++-- tests/{tools => }/linter/factories/operation_group.ts | 2 +- tests/{tools => }/linter/factories/schema.ts | 2 +- tests/{tools => }/linter/factories/schema_file.ts | 4 ++-- tests/{tools => }/linter/fixtures/_info.yaml | 0 .../linter/fixtures/_superseded_operations.yaml | 0 tests/{tools => }/linter/fixtures/empty/_info.yaml | 0 .../linter/fixtures/empty/_superseded_operations.yaml | 0 .../linter/fixtures/empty/namespaces/.gitkeep | 0 .../linter/fixtures/empty/opensearch-openapi.yaml | 0 .../{tools => }/linter/fixtures/empty/schemas/.gitkeep | 0 .../fixtures/file_validators/namespaces/empty.yaml | 0 .../file_validators/namespaces/invalid_components.yaml | 0 .../file_validators/schemas/_common.empty.yaml | 0 .../namespaces/invalid_files/cat.yaml | 0 .../namespaces/invalid_files/dup_path_a.yaml | 0 .../namespaces/invalid_files/dup_path_b.yaml | 0 .../namespaces/invalid_files/dup_path_c.yaml | 0 .../namespaces/invalid_files/indices.txt | 0 .../namespaces/invalid_files/invalid_spec.yaml | 0 .../namespaces/invalid_files/invalid_yaml.yaml | 0 .../namespaces/invalid_folder/cat.yaml | 0 .../namespaces/invalid_folder/dup_path_a.yaml | 0 .../namespaces/invalid_folder/dup_path_b.yaml | 0 .../namespaces/invalid_folder/dup_path_c.yaml | 0 .../inline_object_schema_validator/namespaces/ops.yaml | 0 .../schemas/schemas.yaml | 0 .../schema_refs_validator/namespaces/indices.yaml | 0 .../schema_refs_validator/schemas/animals.yaml | 0 .../fixtures/schema_refs_validator/schemas/others.yaml | 0 tests/merger/OpenApiMerger.test.ts | 10 ++++++++++ tests/{tools => }/merger/fixtures/expected.yaml | 0 .../merger/fixtures/spec/_global_parameters.yaml | 0 tests/{tools => }/merger/fixtures/spec/_info.yaml | 0 .../merger/fixtures/spec/_superseded_operations.yaml | 0 .../merger/fixtures/spec/namespaces/indices.yaml | 0 .../merger/fixtures/spec/namespaces/shelter.yaml | 0 .../merger/fixtures/spec/schemas/actions.yaml | 0 .../merger/fixtures/spec/schemas/animals.yaml | 0 tests/tools/merger/OpenApiMerger.test.ts | 10 ---------- tsconfig.json | 2 +- 84 files changed, 47 insertions(+), 52 deletions(-) rename {tools => src}/README.md (100%) rename {tools => src}/helpers.ts (100%) rename {tools => src}/linter/InlineObjectSchemaValidator.ts (100%) rename {tools => src}/linter/SchemaRefsValidator.ts (100%) rename {tools => src}/linter/SpecValidator.ts (100%) rename {tools => src}/linter/components/InfoFile.ts (100%) rename {tools => src}/linter/components/NamespaceFile.ts (100%) rename {tools => src}/linter/components/NamespacesFolder.ts (100%) rename {tools => src}/linter/components/Operation.ts (100%) rename {tools => src}/linter/components/OperationGroup.ts (100%) rename {tools => src}/linter/components/Schema.ts (100%) rename {tools => src}/linter/components/SchemaFile.ts (100%) rename {tools => src}/linter/components/SchemasFolder.ts (100%) rename {tools => src}/linter/components/SupersededOperationsFile.ts (100%) rename {tools => src}/linter/components/base/FileValidator.ts (100%) rename {tools => src}/linter/components/base/FolderValidator.ts (100%) rename {tools => src}/linter/components/base/ValidatorBase.ts (100%) rename {tools => src}/linter/lint.ts (100%) rename {tools => src}/linter/utils/SpecificationVisitor.ts (100%) rename {tools => src}/linter/utils/index.ts (100%) rename {tools => src}/merger/GlobalParamsGenerator.ts (100%) rename {tools => src}/merger/OpenApiMerger.ts (100%) rename {tools => src}/merger/OpenDistro.ts (100%) rename {tools => src}/merger/SupersededOpsGenerator.ts (100%) rename {tools => src}/merger/merge.ts (90%) rename {tools => src}/types.ts (100%) rename tests/{tools => }/linter/InfoFile.test.ts (60%) rename tests/{tools => }/linter/InlineObjectSchemaValidator.test.ts (78%) rename tests/{tools => }/linter/NamespaceFile.test.ts (100%) rename tests/{tools => }/linter/NamespacesFolder.test.ts (84%) rename tests/{tools => }/linter/Operation.test.ts (100%) rename tests/{tools => }/linter/OperationGroup.test.ts (100%) rename tests/{tools => }/linter/Schema.test.ts (100%) rename tests/{tools => }/linter/SchemaFile.test.ts (100%) rename tests/{tools => }/linter/SchemaRefsValidator.test.ts (75%) rename tests/{tools => }/linter/SpecValidator.test.ts (85%) rename tests/{tools => }/linter/SupersededOperationsFile.test.ts (77%) rename tests/{tools => }/linter/factories/namespace_file.ts (92%) rename tests/{tools => }/linter/factories/operation.ts (94%) rename tests/{tools => }/linter/factories/operation_group.ts (96%) rename tests/{tools => }/linter/factories/schema.ts (92%) rename tests/{tools => }/linter/factories/schema_file.ts (86%) rename tests/{tools => }/linter/fixtures/_info.yaml (100%) rename tests/{tools => }/linter/fixtures/_superseded_operations.yaml (100%) rename tests/{tools => }/linter/fixtures/empty/_info.yaml (100%) rename tests/{tools => }/linter/fixtures/empty/_superseded_operations.yaml (100%) rename tests/{tools => }/linter/fixtures/empty/namespaces/.gitkeep (100%) rename tests/{tools => }/linter/fixtures/empty/opensearch-openapi.yaml (100%) rename tests/{tools => }/linter/fixtures/empty/schemas/.gitkeep (100%) rename tests/{tools => }/linter/fixtures/file_validators/namespaces/empty.yaml (100%) rename tests/{tools => }/linter/fixtures/file_validators/namespaces/invalid_components.yaml (100%) rename tests/{tools => }/linter/fixtures/file_validators/schemas/_common.empty.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml (100%) rename tests/{tools => }/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml (100%) rename tests/{tools => }/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml (100%) rename tests/{tools => }/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml (100%) rename tests/{tools => }/linter/fixtures/schema_refs_validator/namespaces/indices.yaml (100%) rename tests/{tools => }/linter/fixtures/schema_refs_validator/schemas/animals.yaml (100%) rename tests/{tools => }/linter/fixtures/schema_refs_validator/schemas/others.yaml (100%) create mode 100644 tests/merger/OpenApiMerger.test.ts rename tests/{tools => }/merger/fixtures/expected.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/_global_parameters.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/_info.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/_superseded_operations.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/namespaces/indices.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/namespaces/shelter.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/schemas/actions.yaml (100%) rename tests/{tools => }/merger/fixtures/spec/schemas/animals.yaml (100%) delete mode 100644 tests/tools/merger/OpenApiMerger.test.ts diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 82437b9f7..6a516ab36 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,19 +5,16 @@ on: branches: ['**'] paths: - 'spec/**' - - 'tools/linter/**' + - 'src/linter/**' pull_request: branches: ['**'] paths: - 'spec/**' - - 'tools/linter/**' + - 'src/linter/**' jobs: lint-spec: runs-on: ubuntu-latest - defaults: - run: - working-directory: tools steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 12155f9aa..6081f7763 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -4,18 +4,15 @@ on: push: branches: ['**'] paths: - - 'tools/**' + - 'src/**' pull_request: branches: ['**'] paths: - - 'tools/**' + - 'src/**' jobs: tools-tests: runs-on: ubuntu-latest - defaults: - run: - working-directory: tools steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 145d9c2e1..38b7a5832 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -118,7 +118,7 @@ This repository includes several OpenAPI Specification Extensions to fill in any ## Tools -We authored a number of tools to merge and lint specs that live in [tools](tools). All tools have tests (run with `npm run test`) and a linter (run with `npm run lint`). +We authored a number of tools to merge and lint specs that live in [src](./src/). All tools have tests (run with `npm run test`) and a linter (run with `npm run lint`). ### Merger @@ -126,4 +126,4 @@ The spec merger "builds", aka combines all `.yaml` files in a spec folder into a ### Linter -The spec linter that validates every `.yaml` file in the `./spec` folder to assure that they follow the guidelines we have set. Check out the [Linter README](tools/README.md#spec-linter) for more information on how to run it locally. Make sure to run the linter before submitting a PR. +The spec linter that validates every `.yaml` file in the `./spec` folder to assure that they follow the guidelines we have set. Check out the [Linter README](src/README.md#spec-linter) for more information on how to run it locally. Make sure to run the linter before submitting a PR. diff --git a/jest.config.js b/jest.config.js index e5fbf09c0..3382b0b7c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', - testEnvironment: 'node' + testEnvironment: 'node', + moduleDirectories: ['node_modules', 'src'] } diff --git a/package.json b/package.json index 0db15cb31..e81a2d005 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "author": "opensearch-project", "license": "Apache-2.0", "scripts": { - "merge": "ts-node tools/merger/merge.ts", - "lint:spec": "ts-node tools/linter/lint.ts", + "merge": "ts-node src/merger/merge.ts", + "lint:spec": "ts-node src/linter/lint.ts", "lint": "eslint .", "test": "jest" }, diff --git a/tools/README.md b/src/README.md similarity index 100% rename from tools/README.md rename to src/README.md diff --git a/tools/helpers.ts b/src/helpers.ts similarity index 100% rename from tools/helpers.ts rename to src/helpers.ts diff --git a/tools/linter/InlineObjectSchemaValidator.ts b/src/linter/InlineObjectSchemaValidator.ts similarity index 100% rename from tools/linter/InlineObjectSchemaValidator.ts rename to src/linter/InlineObjectSchemaValidator.ts diff --git a/tools/linter/SchemaRefsValidator.ts b/src/linter/SchemaRefsValidator.ts similarity index 100% rename from tools/linter/SchemaRefsValidator.ts rename to src/linter/SchemaRefsValidator.ts diff --git a/tools/linter/SpecValidator.ts b/src/linter/SpecValidator.ts similarity index 100% rename from tools/linter/SpecValidator.ts rename to src/linter/SpecValidator.ts diff --git a/tools/linter/components/InfoFile.ts b/src/linter/components/InfoFile.ts similarity index 100% rename from tools/linter/components/InfoFile.ts rename to src/linter/components/InfoFile.ts diff --git a/tools/linter/components/NamespaceFile.ts b/src/linter/components/NamespaceFile.ts similarity index 100% rename from tools/linter/components/NamespaceFile.ts rename to src/linter/components/NamespaceFile.ts diff --git a/tools/linter/components/NamespacesFolder.ts b/src/linter/components/NamespacesFolder.ts similarity index 100% rename from tools/linter/components/NamespacesFolder.ts rename to src/linter/components/NamespacesFolder.ts diff --git a/tools/linter/components/Operation.ts b/src/linter/components/Operation.ts similarity index 100% rename from tools/linter/components/Operation.ts rename to src/linter/components/Operation.ts diff --git a/tools/linter/components/OperationGroup.ts b/src/linter/components/OperationGroup.ts similarity index 100% rename from tools/linter/components/OperationGroup.ts rename to src/linter/components/OperationGroup.ts diff --git a/tools/linter/components/Schema.ts b/src/linter/components/Schema.ts similarity index 100% rename from tools/linter/components/Schema.ts rename to src/linter/components/Schema.ts diff --git a/tools/linter/components/SchemaFile.ts b/src/linter/components/SchemaFile.ts similarity index 100% rename from tools/linter/components/SchemaFile.ts rename to src/linter/components/SchemaFile.ts diff --git a/tools/linter/components/SchemasFolder.ts b/src/linter/components/SchemasFolder.ts similarity index 100% rename from tools/linter/components/SchemasFolder.ts rename to src/linter/components/SchemasFolder.ts diff --git a/tools/linter/components/SupersededOperationsFile.ts b/src/linter/components/SupersededOperationsFile.ts similarity index 100% rename from tools/linter/components/SupersededOperationsFile.ts rename to src/linter/components/SupersededOperationsFile.ts diff --git a/tools/linter/components/base/FileValidator.ts b/src/linter/components/base/FileValidator.ts similarity index 100% rename from tools/linter/components/base/FileValidator.ts rename to src/linter/components/base/FileValidator.ts diff --git a/tools/linter/components/base/FolderValidator.ts b/src/linter/components/base/FolderValidator.ts similarity index 100% rename from tools/linter/components/base/FolderValidator.ts rename to src/linter/components/base/FolderValidator.ts diff --git a/tools/linter/components/base/ValidatorBase.ts b/src/linter/components/base/ValidatorBase.ts similarity index 100% rename from tools/linter/components/base/ValidatorBase.ts rename to src/linter/components/base/ValidatorBase.ts diff --git a/tools/linter/lint.ts b/src/linter/lint.ts similarity index 100% rename from tools/linter/lint.ts rename to src/linter/lint.ts diff --git a/tools/linter/utils/SpecificationVisitor.ts b/src/linter/utils/SpecificationVisitor.ts similarity index 100% rename from tools/linter/utils/SpecificationVisitor.ts rename to src/linter/utils/SpecificationVisitor.ts diff --git a/tools/linter/utils/index.ts b/src/linter/utils/index.ts similarity index 100% rename from tools/linter/utils/index.ts rename to src/linter/utils/index.ts diff --git a/tools/merger/GlobalParamsGenerator.ts b/src/merger/GlobalParamsGenerator.ts similarity index 100% rename from tools/merger/GlobalParamsGenerator.ts rename to src/merger/GlobalParamsGenerator.ts diff --git a/tools/merger/OpenApiMerger.ts b/src/merger/OpenApiMerger.ts similarity index 100% rename from tools/merger/OpenApiMerger.ts rename to src/merger/OpenApiMerger.ts diff --git a/tools/merger/OpenDistro.ts b/src/merger/OpenDistro.ts similarity index 100% rename from tools/merger/OpenDistro.ts rename to src/merger/OpenDistro.ts diff --git a/tools/merger/SupersededOpsGenerator.ts b/src/merger/SupersededOpsGenerator.ts similarity index 100% rename from tools/merger/SupersededOpsGenerator.ts rename to src/merger/SupersededOpsGenerator.ts diff --git a/tools/merger/merge.ts b/src/merger/merge.ts similarity index 90% rename from tools/merger/merge.ts rename to src/merger/merge.ts index 0bb218f07..6db2f0f9a 100644 --- a/tools/merger/merge.ts +++ b/src/merger/merge.ts @@ -5,7 +5,7 @@ import { resolve } from 'path' const command = new Command() .description('Merges the multi-file OpenSearch spec into a single file for programmatic use.') .addOption(new Option('-s, --source ', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../spec'))) - .addOption(new Option('-o, --output ', 'output file name').default(resolve(__dirname, '.././build/opensearch-openapi.yaml'))) + .addOption(new Option('-o, --output ', 'output file name').default(resolve(__dirname, '../../build/opensearch-openapi.yaml'))) .allowExcessArguments(false) .parse() diff --git a/tools/types.ts b/src/types.ts similarity index 100% rename from tools/types.ts rename to src/types.ts diff --git a/tests/tools/linter/InfoFile.test.ts b/tests/linter/InfoFile.test.ts similarity index 60% rename from tests/tools/linter/InfoFile.test.ts rename to tests/linter/InfoFile.test.ts index 2fdf3fb4d..bd342603c 100644 --- a/tests/tools/linter/InfoFile.test.ts +++ b/tests/linter/InfoFile.test.ts @@ -1,7 +1,7 @@ -import InfoFile from '../../../tools/linter/components/InfoFile' +import InfoFile from 'linter/components/InfoFile' test('validate()', () => { - const validator = new InfoFile('./tests/tools/linter/fixtures/_info.yaml') + const validator = new InfoFile('./tests/linter/fixtures/_info.yaml') expect(validator.validate()).toEqual([ { file: 'fixtures/_info.yaml', diff --git a/tests/tools/linter/InlineObjectSchemaValidator.test.ts b/tests/linter/InlineObjectSchemaValidator.test.ts similarity index 78% rename from tests/tools/linter/InlineObjectSchemaValidator.test.ts rename to tests/linter/InlineObjectSchemaValidator.test.ts index 502275655..cbd7ec95a 100644 --- a/tests/tools/linter/InlineObjectSchemaValidator.test.ts +++ b/tests/linter/InlineObjectSchemaValidator.test.ts @@ -1,9 +1,9 @@ -import SchemasFolder from '../../../tools/linter/components/SchemasFolder' -import NamespacesFolder from '../../../tools/linter/components/NamespacesFolder' -import InlineObjectSchemaValidator from '../../../tools/linter/InlineObjectSchemaValidator' +import SchemasFolder from 'linter/components/SchemasFolder' +import NamespacesFolder from 'linter/components/NamespacesFolder' +import InlineObjectSchemaValidator from 'linter/InlineObjectSchemaValidator' test('validate()', () => { - const root_folder = './tests/tools/linter/fixtures/inline_object_schema_validator' + const root_folder = './tests/linter/fixtures/inline_object_schema_validator' const namespaces_folder = new NamespacesFolder(`${root_folder}/namespaces`) const schemas_folder = new SchemasFolder(`${root_folder}/schemas`) const validator = new InlineObjectSchemaValidator(namespaces_folder, schemas_folder) diff --git a/tests/tools/linter/NamespaceFile.test.ts b/tests/linter/NamespaceFile.test.ts similarity index 100% rename from tests/tools/linter/NamespaceFile.test.ts rename to tests/linter/NamespaceFile.test.ts diff --git a/tests/tools/linter/NamespacesFolder.test.ts b/tests/linter/NamespacesFolder.test.ts similarity index 84% rename from tests/tools/linter/NamespacesFolder.test.ts rename to tests/linter/NamespacesFolder.test.ts index 55e324c01..4b23b8e99 100644 --- a/tests/tools/linter/NamespacesFolder.test.ts +++ b/tests/linter/NamespacesFolder.test.ts @@ -1,7 +1,7 @@ -import NamespacesFolder from '../../../tools/linter/components/NamespacesFolder' +import NamespacesFolder from 'linter/components/NamespacesFolder' test('validate() - When there invalid files', () => { - const validator = new NamespacesFolder('./tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files') + const validator = new NamespacesFolder('./tests/linter/fixtures/folder_validators/namespaces/invalid_files') expect(validator.validate()).toEqual([ { file: 'invalid_files/indices.txt', @@ -37,7 +37,7 @@ test('validate() - When there invalid files', () => { }) test('validate() - When the files are valid but the folder is not', () => { - const validator = new NamespacesFolder('./tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder') + const validator = new NamespacesFolder('./tests/linter/fixtures/folder_validators/namespaces/invalid_folder') expect(validator.validate()).toEqual([ { file: 'invalid_folder/', diff --git a/tests/tools/linter/Operation.test.ts b/tests/linter/Operation.test.ts similarity index 100% rename from tests/tools/linter/Operation.test.ts rename to tests/linter/Operation.test.ts diff --git a/tests/tools/linter/OperationGroup.test.ts b/tests/linter/OperationGroup.test.ts similarity index 100% rename from tests/tools/linter/OperationGroup.test.ts rename to tests/linter/OperationGroup.test.ts diff --git a/tests/tools/linter/Schema.test.ts b/tests/linter/Schema.test.ts similarity index 100% rename from tests/tools/linter/Schema.test.ts rename to tests/linter/Schema.test.ts diff --git a/tests/tools/linter/SchemaFile.test.ts b/tests/linter/SchemaFile.test.ts similarity index 100% rename from tests/tools/linter/SchemaFile.test.ts rename to tests/linter/SchemaFile.test.ts diff --git a/tests/tools/linter/SchemaRefsValidator.test.ts b/tests/linter/SchemaRefsValidator.test.ts similarity index 75% rename from tests/tools/linter/SchemaRefsValidator.test.ts rename to tests/linter/SchemaRefsValidator.test.ts index 7afae1bed..1f295b87b 100644 --- a/tests/tools/linter/SchemaRefsValidator.test.ts +++ b/tests/linter/SchemaRefsValidator.test.ts @@ -1,9 +1,9 @@ -import SchemasFolder from '../../../tools/linter/components/SchemasFolder' -import NamespacesFolder from '../../../tools/linter/components/NamespacesFolder' -import SchemaRefsValidator from '../../../tools/linter/SchemaRefsValidator' +import SchemasFolder from 'linter/components/SchemasFolder' +import NamespacesFolder from 'linter/components/NamespacesFolder' +import SchemaRefsValidator from 'linter/SchemaRefsValidator' test('validate()', () => { - const root_folder = './tests/tools/linter/fixtures/schema_refs_validator' + const root_folder = './tests/linter/fixtures/schema_refs_validator' const namespaces_folder = new NamespacesFolder(`${root_folder}/namespaces`) const schemas_folder = new SchemasFolder(`${root_folder}/schemas`) const validator = new SchemaRefsValidator(namespaces_folder, schemas_folder) diff --git a/tests/tools/linter/SpecValidator.test.ts b/tests/linter/SpecValidator.test.ts similarity index 85% rename from tests/tools/linter/SpecValidator.test.ts rename to tests/linter/SpecValidator.test.ts index 69c248d87..a1739ee08 100644 --- a/tests/tools/linter/SpecValidator.test.ts +++ b/tests/linter/SpecValidator.test.ts @@ -1,7 +1,7 @@ -import SpecValidator from '../../../tools/linter/SpecValidator' +import SpecValidator from 'linter/SpecValidator' test('validate()', () => { - const validator = new SpecValidator('./tests/tools/linter/fixtures/empty') + const validator = new SpecValidator('./tests/linter/fixtures/empty') expect(validator.validate()).toEqual([]) validator.namespaces_folder.validate = jest.fn().mockReturnValue([{ file: 'namespaces/', message: 'namespace error' }]) diff --git a/tests/tools/linter/SupersededOperationsFile.test.ts b/tests/linter/SupersededOperationsFile.test.ts similarity index 77% rename from tests/tools/linter/SupersededOperationsFile.test.ts rename to tests/linter/SupersededOperationsFile.test.ts index 017d1ddd3..5c6c5732d 100644 --- a/tests/tools/linter/SupersededOperationsFile.test.ts +++ b/tests/linter/SupersededOperationsFile.test.ts @@ -1,7 +1,7 @@ -import SupersededOperationsFile from '../../../tools/linter/components/SupersededOperationsFile' +import SupersededOperationsFile from 'linter/components/SupersededOperationsFile' test('validate()', () => { - const validator = new SupersededOperationsFile('./tests/tools/linter/fixtures/_superseded_operations.yaml') + const validator = new SupersededOperationsFile('./tests/linter/fixtures/_superseded_operations.yaml') expect(validator.validate()).toEqual([ { file: 'fixtures/_superseded_operations.yaml', diff --git a/tests/tools/linter/factories/namespace_file.ts b/tests/linter/factories/namespace_file.ts similarity index 92% rename from tests/tools/linter/factories/namespace_file.ts rename to tests/linter/factories/namespace_file.ts index 542b74c79..8f1215801 100644 --- a/tests/tools/linter/factories/namespace_file.ts +++ b/tests/linter/factories/namespace_file.ts @@ -1,9 +1,9 @@ -import NamespaceFile from '../../../../tools/linter/components/NamespaceFile' +import NamespaceFile from 'linter/components/NamespaceFile' import { type OpenAPIV3 } from 'openapi-types' import { mocked_operation_group } from './operation_group' export function namespace_file (fixture_file: string): NamespaceFile { - return new NamespaceFile(`./tests/tools/linter/fixtures/file_validators/namespaces/${fixture_file}`) + return new NamespaceFile(`./tests/linter/fixtures/file_validators/namespaces/${fixture_file}`) } interface MockedReturnedValues { diff --git a/tests/tools/linter/factories/operation.ts b/tests/linter/factories/operation.ts similarity index 94% rename from tests/tools/linter/factories/operation.ts rename to tests/linter/factories/operation.ts index f7745024b..208dd1e86 100644 --- a/tests/tools/linter/factories/operation.ts +++ b/tests/linter/factories/operation.ts @@ -1,5 +1,5 @@ -import Operation from '../../../../tools/linter/components/Operation' -import { type OperationSpec } from '../../../../tools/types' +import Operation from 'linter/components/Operation' +import { type OperationSpec } from 'types' export function operation (spec: Record, file_name = 'indices.yaml'): Operation { return new Operation(`namespaces/${file_name}`, '/{index}/something/{abc_xyz}', 'post', spec as OperationSpec) diff --git a/tests/tools/linter/factories/operation_group.ts b/tests/linter/factories/operation_group.ts similarity index 96% rename from tests/tools/linter/factories/operation_group.ts rename to tests/linter/factories/operation_group.ts index 5e12e675b..7a8cd6c1b 100644 --- a/tests/tools/linter/factories/operation_group.ts +++ b/tests/linter/factories/operation_group.ts @@ -1,4 +1,4 @@ -import OperationGroup from '../../../../tools/linter/components/OperationGroup' +import OperationGroup from 'linter/components/OperationGroup' import { operation, mocked_operation } from './operation' export function operation_group (operation_specs: Array>): OperationGroup { diff --git a/tests/tools/linter/factories/schema.ts b/tests/linter/factories/schema.ts similarity index 92% rename from tests/tools/linter/factories/schema.ts rename to tests/linter/factories/schema.ts index 2155d0d0f..bdaec547c 100644 --- a/tests/tools/linter/factories/schema.ts +++ b/tests/linter/factories/schema.ts @@ -1,4 +1,4 @@ -import Schema from '../../../../tools/linter/components/Schema' +import Schema from 'linter/components/Schema' import { type OpenAPIV3 } from 'openapi-types' export function schema (name: string, spec: Record = {}): Schema { diff --git a/tests/tools/linter/factories/schema_file.ts b/tests/linter/factories/schema_file.ts similarity index 86% rename from tests/tools/linter/factories/schema_file.ts rename to tests/linter/factories/schema_file.ts index c831f103b..98e785aae 100644 --- a/tests/tools/linter/factories/schema_file.ts +++ b/tests/linter/factories/schema_file.ts @@ -1,8 +1,8 @@ import { mocked_schema } from './schema' -import SchemaFile from '../../../../tools/linter/components/SchemaFile' +import SchemaFile from 'linter/components/SchemaFile' export function schema_file (fixture: string): SchemaFile { - return new SchemaFile(`./tests/tools/linter/fixtures/file_validators/schemas/${fixture}`) + return new SchemaFile(`./tests/linter/fixtures/file_validators/schemas/${fixture}`) } interface MockedReturnedValues { diff --git a/tests/tools/linter/fixtures/_info.yaml b/tests/linter/fixtures/_info.yaml similarity index 100% rename from tests/tools/linter/fixtures/_info.yaml rename to tests/linter/fixtures/_info.yaml diff --git a/tests/tools/linter/fixtures/_superseded_operations.yaml b/tests/linter/fixtures/_superseded_operations.yaml similarity index 100% rename from tests/tools/linter/fixtures/_superseded_operations.yaml rename to tests/linter/fixtures/_superseded_operations.yaml diff --git a/tests/tools/linter/fixtures/empty/_info.yaml b/tests/linter/fixtures/empty/_info.yaml similarity index 100% rename from tests/tools/linter/fixtures/empty/_info.yaml rename to tests/linter/fixtures/empty/_info.yaml diff --git a/tests/tools/linter/fixtures/empty/_superseded_operations.yaml b/tests/linter/fixtures/empty/_superseded_operations.yaml similarity index 100% rename from tests/tools/linter/fixtures/empty/_superseded_operations.yaml rename to tests/linter/fixtures/empty/_superseded_operations.yaml diff --git a/tests/tools/linter/fixtures/empty/namespaces/.gitkeep b/tests/linter/fixtures/empty/namespaces/.gitkeep similarity index 100% rename from tests/tools/linter/fixtures/empty/namespaces/.gitkeep rename to tests/linter/fixtures/empty/namespaces/.gitkeep diff --git a/tests/tools/linter/fixtures/empty/opensearch-openapi.yaml b/tests/linter/fixtures/empty/opensearch-openapi.yaml similarity index 100% rename from tests/tools/linter/fixtures/empty/opensearch-openapi.yaml rename to tests/linter/fixtures/empty/opensearch-openapi.yaml diff --git a/tests/tools/linter/fixtures/empty/schemas/.gitkeep b/tests/linter/fixtures/empty/schemas/.gitkeep similarity index 100% rename from tests/tools/linter/fixtures/empty/schemas/.gitkeep rename to tests/linter/fixtures/empty/schemas/.gitkeep diff --git a/tests/tools/linter/fixtures/file_validators/namespaces/empty.yaml b/tests/linter/fixtures/file_validators/namespaces/empty.yaml similarity index 100% rename from tests/tools/linter/fixtures/file_validators/namespaces/empty.yaml rename to tests/linter/fixtures/file_validators/namespaces/empty.yaml diff --git a/tests/tools/linter/fixtures/file_validators/namespaces/invalid_components.yaml b/tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml similarity index 100% rename from tests/tools/linter/fixtures/file_validators/namespaces/invalid_components.yaml rename to tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml diff --git a/tests/tools/linter/fixtures/file_validators/schemas/_common.empty.yaml b/tests/linter/fixtures/file_validators/schemas/_common.empty.yaml similarity index 100% rename from tests/tools/linter/fixtures/file_validators/schemas/_common.empty.yaml rename to tests/linter/fixtures/file_validators/schemas/_common.empty.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml diff --git a/tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml b/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml similarity index 100% rename from tests/tools/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml rename to tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml diff --git a/tests/tools/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml b/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml similarity index 100% rename from tests/tools/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml rename to tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml diff --git a/tests/tools/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml b/tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml similarity index 100% rename from tests/tools/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml rename to tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml diff --git a/tests/tools/linter/fixtures/schema_refs_validator/namespaces/indices.yaml b/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml similarity index 100% rename from tests/tools/linter/fixtures/schema_refs_validator/namespaces/indices.yaml rename to tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml diff --git a/tests/tools/linter/fixtures/schema_refs_validator/schemas/animals.yaml b/tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml similarity index 100% rename from tests/tools/linter/fixtures/schema_refs_validator/schemas/animals.yaml rename to tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml diff --git a/tests/tools/linter/fixtures/schema_refs_validator/schemas/others.yaml b/tests/linter/fixtures/schema_refs_validator/schemas/others.yaml similarity index 100% rename from tests/tools/linter/fixtures/schema_refs_validator/schemas/others.yaml rename to tests/linter/fixtures/schema_refs_validator/schemas/others.yaml diff --git a/tests/merger/OpenApiMerger.test.ts b/tests/merger/OpenApiMerger.test.ts new file mode 100644 index 000000000..ed9ddf027 --- /dev/null +++ b/tests/merger/OpenApiMerger.test.ts @@ -0,0 +1,10 @@ +import OpenApiMerger from 'merger/OpenApiMerger' +import fs from 'fs' + +test('merge()', async () => { + const merger = new OpenApiMerger('./tests/merger/fixtures/spec/') + merger.merge('./tests/merger/opensearch-openapi.yaml') + expect(fs.readFileSync('./tests/merger/fixtures/expected.yaml', 'utf8')) + .toEqual(fs.readFileSync('./tests/merger/opensearch-openapi.yaml', 'utf8')) + fs.unlinkSync('./tests/merger/opensearch-openapi.yaml') +}) diff --git a/tests/tools/merger/fixtures/expected.yaml b/tests/merger/fixtures/expected.yaml similarity index 100% rename from tests/tools/merger/fixtures/expected.yaml rename to tests/merger/fixtures/expected.yaml diff --git a/tests/tools/merger/fixtures/spec/_global_parameters.yaml b/tests/merger/fixtures/spec/_global_parameters.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/_global_parameters.yaml rename to tests/merger/fixtures/spec/_global_parameters.yaml diff --git a/tests/tools/merger/fixtures/spec/_info.yaml b/tests/merger/fixtures/spec/_info.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/_info.yaml rename to tests/merger/fixtures/spec/_info.yaml diff --git a/tests/tools/merger/fixtures/spec/_superseded_operations.yaml b/tests/merger/fixtures/spec/_superseded_operations.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/_superseded_operations.yaml rename to tests/merger/fixtures/spec/_superseded_operations.yaml diff --git a/tests/tools/merger/fixtures/spec/namespaces/indices.yaml b/tests/merger/fixtures/spec/namespaces/indices.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/namespaces/indices.yaml rename to tests/merger/fixtures/spec/namespaces/indices.yaml diff --git a/tests/tools/merger/fixtures/spec/namespaces/shelter.yaml b/tests/merger/fixtures/spec/namespaces/shelter.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/namespaces/shelter.yaml rename to tests/merger/fixtures/spec/namespaces/shelter.yaml diff --git a/tests/tools/merger/fixtures/spec/schemas/actions.yaml b/tests/merger/fixtures/spec/schemas/actions.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/schemas/actions.yaml rename to tests/merger/fixtures/spec/schemas/actions.yaml diff --git a/tests/tools/merger/fixtures/spec/schemas/animals.yaml b/tests/merger/fixtures/spec/schemas/animals.yaml similarity index 100% rename from tests/tools/merger/fixtures/spec/schemas/animals.yaml rename to tests/merger/fixtures/spec/schemas/animals.yaml diff --git a/tests/tools/merger/OpenApiMerger.test.ts b/tests/tools/merger/OpenApiMerger.test.ts deleted file mode 100644 index 7e6202ccd..000000000 --- a/tests/tools/merger/OpenApiMerger.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -import OpenApiMerger from '../../../tools/merger/OpenApiMerger' -import fs from 'fs' - -test('merge()', async () => { - const merger = new OpenApiMerger('./tests/tools/merger/fixtures/spec/') - merger.merge('./tests/tools/merger/opensearch-openapi.yaml') - expect(fs.readFileSync('./tests/tools/merger/fixtures/expected.yaml', 'utf8')) - .toEqual(fs.readFileSync('./tests/tools/merger/opensearch-openapi.yaml', 'utf8')) - fs.unlinkSync('./tests/tools/merger/opensearch-openapi.yaml') -}) diff --git a/tsconfig.json b/tsconfig.json index bc6592779..781197568 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,7 +28,7 @@ "module": "commonjs", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */