From 2fb68d5f01d50e63aa3efb7f26854a3141f23b8b Mon Sep 17 00:00:00 2001 From: dblock Date: Mon, 13 May 2024 10:18:15 -0400 Subject: [PATCH] Moved source into tools/src and tests into tools/tests. Signed-off-by: dblock --- .github/workflows/lint.yml | 4 ++-- .github/workflows/tools.yml | 4 ++-- DEVELOPER_GUIDE.md | 4 ++-- jest.config.js | 2 +- package.json | 4 ++-- tests/merger/OpenApiMerger.test.ts | 10 ---------- {src => tools}/README.md | 4 ++-- {src => tools}/helpers.ts | 0 .../src}/linter/InlineObjectSchemaValidator.ts | 2 +- {src => tools/src}/linter/SchemaRefsValidator.ts | 2 +- {src => tools/src}/linter/SpecValidator.ts | 2 +- {src => tools/src}/linter/components/InfoFile.ts | 0 {src => tools/src}/linter/components/NamespaceFile.ts | 4 ++-- .../src}/linter/components/NamespacesFolder.ts | 2 +- {src => tools/src}/linter/components/Operation.ts | 2 +- {src => tools/src}/linter/components/OperationGroup.ts | 2 +- {src => tools/src}/linter/components/Schema.ts | 2 +- {src => tools/src}/linter/components/SchemaFile.ts | 2 +- {src => tools/src}/linter/components/SchemasFolder.ts | 2 +- .../src}/linter/components/SupersededOperationsFile.ts | 0 .../src}/linter/components/base/FileValidator.ts | 4 ++-- .../src}/linter/components/base/FolderValidator.ts | 2 +- .../src}/linter/components/base/ValidatorBase.ts | 2 +- {src => tools/src}/linter/lint.ts | 2 +- .../src}/linter/utils/SpecificationVisitor.ts | 0 {src => tools/src}/linter/utils/index.ts | 2 +- {src => tools/src}/merger/GlobalParamsGenerator.ts | 2 +- {src => tools/src}/merger/OpenApiMerger.ts | 2 +- {src => tools/src}/merger/OpenDistro.ts | 4 ++-- {src => tools/src}/merger/SupersededOpsGenerator.ts | 4 ++-- {src => tools/src}/merger/merge.ts | 4 ++-- {src => tools/src}/types.ts | 0 {tests => tools/tests}/linter/InfoFile.test.ts | 2 +- .../tests}/linter/InlineObjectSchemaValidator.test.ts | 2 +- {tests => tools/tests}/linter/NamespaceFile.test.ts | 0 {tests => tools/tests}/linter/NamespacesFolder.test.ts | 4 ++-- {tests => tools/tests}/linter/Operation.test.ts | 0 {tests => tools/tests}/linter/OperationGroup.test.ts | 0 {tests => tools/tests}/linter/Schema.test.ts | 0 {tests => tools/tests}/linter/SchemaFile.test.ts | 0 .../tests}/linter/SchemaRefsValidator.test.ts | 2 +- {tests => tools/tests}/linter/SpecValidator.test.ts | 2 +- .../tests}/linter/SupersededOperationsFile.test.ts | 2 +- .../tests}/linter/factories/namespace_file.ts | 2 +- {tests => tools/tests}/linter/factories/operation.ts | 0 .../tests}/linter/factories/operation_group.ts | 0 {tests => tools/tests}/linter/factories/schema.ts | 0 {tests => tools/tests}/linter/factories/schema_file.ts | 2 +- {tests => tools/tests}/linter/fixtures/_info.yaml | 0 .../tests}/linter/fixtures/_superseded_operations.yaml | 0 .../tests}/linter/fixtures/empty/_info.yaml | 0 .../linter/fixtures/empty/_superseded_operations.yaml | 0 .../tests}/linter/fixtures/empty/namespaces/.gitkeep | 0 .../linter/fixtures/empty/opensearch-openapi.yaml | 0 .../tests}/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 tools/tests/merger/OpenApiMerger.test.ts | 10 ++++++++++ {tests => tools/tests}/merger/fixtures/expected.yaml | 0 .../merger/fixtures/spec/_global_parameters.yaml | 0 {tests => tools/tests}/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 .../tests}/merger/fixtures/spec/schemas/actions.yaml | 0 .../tests}/merger/fixtures/spec/schemas/animals.yaml | 0 tsconfig.json | 2 +- 84 files changed, 56 insertions(+), 56 deletions(-) delete mode 100644 tests/merger/OpenApiMerger.test.ts rename {src => tools}/README.md (89%) rename {src => tools}/helpers.ts (100%) rename {src => tools/src}/linter/InlineObjectSchemaValidator.ts (97%) rename {src => tools/src}/linter/SchemaRefsValidator.ts (98%) rename {src => tools/src}/linter/SpecValidator.ts (97%) rename {src => tools/src}/linter/components/InfoFile.ts (100%) rename {src => tools/src}/linter/components/NamespaceFile.ts (97%) rename {src => tools/src}/linter/components/NamespacesFolder.ts (95%) rename {src => tools/src}/linter/components/Operation.ts (98%) rename {src => tools/src}/linter/components/OperationGroup.ts (98%) rename {src => tools/src}/linter/components/Schema.ts (93%) rename {src => tools/src}/linter/components/SchemaFile.ts (96%) rename {src => tools/src}/linter/components/SchemasFolder.ts (85%) rename {src => tools/src}/linter/components/SupersededOperationsFile.ts (100%) rename {src => tools/src}/linter/components/base/FileValidator.ts (95%) rename {src => tools/src}/linter/components/base/FolderValidator.ts (94%) rename {src => tools/src}/linter/components/base/ValidatorBase.ts (88%) rename {src => tools/src}/linter/lint.ts (98%) rename {src => tools/src}/linter/utils/SpecificationVisitor.ts (100%) rename {src => tools/src}/linter/utils/index.ts (97%) rename {src => tools/src}/merger/GlobalParamsGenerator.ts (97%) rename {src => tools/src}/merger/OpenApiMerger.ts (98%) rename {src => tools/src}/merger/OpenDistro.ts (91%) rename {src => tools/src}/merger/SupersededOpsGenerator.ts (97%) rename {src => tools/src}/merger/merge.ts (88%) rename {src => tools/src}/types.ts (100%) rename {tests => tools/tests}/linter/InfoFile.test.ts (77%) rename {tests => tools/tests}/linter/InlineObjectSchemaValidator.test.ts (94%) rename {tests => tools/tests}/linter/NamespaceFile.test.ts (100%) rename {tests => tools/tests}/linter/NamespacesFolder.test.ts (88%) rename {tests => tools/tests}/linter/Operation.test.ts (100%) rename {tests => tools/tests}/linter/OperationGroup.test.ts (100%) rename {tests => tools/tests}/linter/Schema.test.ts (100%) rename {tests => tools/tests}/linter/SchemaFile.test.ts (100%) rename {tests => tools/tests}/linter/SchemaRefsValidator.test.ts (93%) rename {tests => tools/tests}/linter/SpecValidator.test.ts (92%) rename {tests => tools/tests}/linter/SupersededOperationsFile.test.ts (87%) rename {tests => tools/tests}/linter/factories/namespace_file.ts (95%) rename {tests => tools/tests}/linter/factories/operation.ts (100%) rename {tests => tools/tests}/linter/factories/operation_group.ts (100%) rename {tests => tools/tests}/linter/factories/schema.ts (100%) rename {tests => tools/tests}/linter/factories/schema_file.ts (92%) rename {tests => tools/tests}/linter/fixtures/_info.yaml (100%) rename {tests => tools/tests}/linter/fixtures/_superseded_operations.yaml (100%) rename {tests => tools/tests}/linter/fixtures/empty/_info.yaml (100%) rename {tests => tools/tests}/linter/fixtures/empty/_superseded_operations.yaml (100%) rename {tests => tools/tests}/linter/fixtures/empty/namespaces/.gitkeep (100%) rename {tests => tools/tests}/linter/fixtures/empty/opensearch-openapi.yaml (100%) rename {tests => tools/tests}/linter/fixtures/empty/schemas/.gitkeep (100%) rename {tests => tools/tests}/linter/fixtures/file_validators/namespaces/empty.yaml (100%) rename {tests => tools/tests}/linter/fixtures/file_validators/namespaces/invalid_components.yaml (100%) rename {tests => tools/tests}/linter/fixtures/file_validators/schemas/_common.empty.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml (100%) rename {tests => tools/tests}/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml (100%) rename {tests => tools/tests}/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml (100%) rename {tests => tools/tests}/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml (100%) rename {tests => tools/tests}/linter/fixtures/schema_refs_validator/namespaces/indices.yaml (100%) rename {tests => tools/tests}/linter/fixtures/schema_refs_validator/schemas/animals.yaml (100%) rename {tests => tools/tests}/linter/fixtures/schema_refs_validator/schemas/others.yaml (100%) create mode 100644 tools/tests/merger/OpenApiMerger.test.ts rename {tests => tools/tests}/merger/fixtures/expected.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/_global_parameters.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/_info.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/_superseded_operations.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/namespaces/indices.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/namespaces/shelter.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/schemas/actions.yaml (100%) rename {tests => tools/tests}/merger/fixtures/spec/schemas/animals.yaml (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6a516ab36..2d7bd2f26 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,12 +5,12 @@ on: branches: ['**'] paths: - 'spec/**' - - 'src/linter/**' + - 'tools/src/linter/**' pull_request: branches: ['**'] paths: - 'spec/**' - - 'src/linter/**' + - 'tools/src/linter/**' jobs: lint-spec: diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 6081f7763..0cae7671e 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -4,11 +4,11 @@ on: push: branches: ['**'] paths: - - 'src/**' + - 'tools/**' pull_request: branches: ['**'] paths: - - 'src/**' + - 'tools/**' jobs: tools-tests: diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 38b7a5832..ca19a0bd3 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 [src](./src/). 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 [tools](./tools/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](src/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](tools/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 3382b0b7c..272fc8594 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,5 +2,5 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', - moduleDirectories: ['node_modules', 'src'] + moduleDirectories: ['node_modules', './tools/src'] } diff --git a/package.json b/package.json index e81a2d005..974ef1145 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "author": "opensearch-project", "license": "Apache-2.0", "scripts": { - "merge": "ts-node src/merger/merge.ts", - "lint:spec": "ts-node src/linter/lint.ts", + "merge": "ts-node tools/src/merger/merge.ts", + "lint:spec": "ts-node tools/src/linter/lint.ts", "lint": "eslint .", "test": "jest" }, diff --git a/tests/merger/OpenApiMerger.test.ts b/tests/merger/OpenApiMerger.test.ts deleted file mode 100644 index ed9ddf027..000000000 --- a/tests/merger/OpenApiMerger.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -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/src/README.md b/tools/README.md similarity index 89% rename from src/README.md rename to tools/README.md index a4a1b2b6c..ec95eab7e 100644 --- a/src/README.md +++ b/tools/README.md @@ -2,8 +2,8 @@ This folder contains tools for the repo: -- [Merger](./merger): merges multiple OpenAPI files into one -- [Linter](./linter): validates files in the spec folder +- [Merger](./src/merger): merges multiple OpenAPI files into one +- [Linter](./src/linter): validates files in the spec folder ## Setup diff --git a/src/helpers.ts b/tools/helpers.ts similarity index 100% rename from src/helpers.ts rename to tools/helpers.ts diff --git a/src/linter/InlineObjectSchemaValidator.ts b/tools/src/linter/InlineObjectSchemaValidator.ts similarity index 97% rename from src/linter/InlineObjectSchemaValidator.ts rename to tools/src/linter/InlineObjectSchemaValidator.ts index f54b641f3..892c9af6a 100644 --- a/src/linter/InlineObjectSchemaValidator.ts +++ b/tools/src/linter/InlineObjectSchemaValidator.ts @@ -1,6 +1,6 @@ import type NamespacesFolder from './components/NamespacesFolder' import type SchemasFolder from './components/SchemasFolder' -import { type ValidationError } from '../types' +import { type ValidationError } from 'types' import { SchemaVisitor } from './utils/SpecificationVisitor' import { is_ref, type MaybeRef, SpecificationContext } from './utils' import { type OpenAPIV3 } from 'openapi-types' diff --git a/src/linter/SchemaRefsValidator.ts b/tools/src/linter/SchemaRefsValidator.ts similarity index 98% rename from src/linter/SchemaRefsValidator.ts rename to tools/src/linter/SchemaRefsValidator.ts index 149d40f34..ae5af24fb 100644 --- a/src/linter/SchemaRefsValidator.ts +++ b/tools/src/linter/SchemaRefsValidator.ts @@ -1,6 +1,6 @@ import type NamespacesFolder from './components/NamespacesFolder' import type SchemasFolder from './components/SchemasFolder' -import { type ValidationError } from '../types' +import { type ValidationError } from 'types' export default class SchemaRefsValidator { namespaces_folder: NamespacesFolder diff --git a/src/linter/SpecValidator.ts b/tools/src/linter/SpecValidator.ts similarity index 97% rename from src/linter/SpecValidator.ts rename to tools/src/linter/SpecValidator.ts index 50f489e12..12da4175c 100644 --- a/src/linter/SpecValidator.ts +++ b/tools/src/linter/SpecValidator.ts @@ -1,6 +1,6 @@ import SchemasFolder from './components/SchemasFolder' import NamespacesFolder from './components/NamespacesFolder' -import { type ValidationError } from '../types' +import { type ValidationError } from 'types' import SchemaRefsValidator from './SchemaRefsValidator' import SupersededOperationsFile from './components/SupersededOperationsFile' import InfoFile from './components/InfoFile' diff --git a/src/linter/components/InfoFile.ts b/tools/src/linter/components/InfoFile.ts similarity index 100% rename from src/linter/components/InfoFile.ts rename to tools/src/linter/components/InfoFile.ts diff --git a/src/linter/components/NamespaceFile.ts b/tools/src/linter/components/NamespaceFile.ts similarity index 97% rename from src/linter/components/NamespaceFile.ts rename to tools/src/linter/components/NamespaceFile.ts index f163c0c28..1373b72f9 100644 --- a/src/linter/components/NamespaceFile.ts +++ b/tools/src/linter/components/NamespaceFile.ts @@ -1,9 +1,9 @@ import { type OpenAPIV3 } from 'openapi-types' -import { type OperationSpec, type ValidationError } from '../../types' +import { type OperationSpec, type ValidationError } from 'types' import OperationGroup from './OperationGroup' import _ from 'lodash' import Operation from './Operation' -import { resolve_ref } from '../../helpers' +import { resolve_ref } from '../../../helpers' import FileValidator from './base/FileValidator' const HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] diff --git a/src/linter/components/NamespacesFolder.ts b/tools/src/linter/components/NamespacesFolder.ts similarity index 95% rename from src/linter/components/NamespacesFolder.ts rename to tools/src/linter/components/NamespacesFolder.ts index 86c544fb3..a1c10003c 100644 --- a/src/linter/components/NamespacesFolder.ts +++ b/tools/src/linter/components/NamespacesFolder.ts @@ -1,5 +1,5 @@ import NamespaceFile from './NamespaceFile' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' import FolderValidator from './base/FolderValidator' export default class NamespacesFolder extends FolderValidator { diff --git a/src/linter/components/Operation.ts b/tools/src/linter/components/Operation.ts similarity index 98% rename from src/linter/components/Operation.ts rename to tools/src/linter/components/Operation.ts index 5714473b1..6a9f2ead6 100644 --- a/src/linter/components/Operation.ts +++ b/tools/src/linter/components/Operation.ts @@ -1,4 +1,4 @@ -import { type OperationSpec, type ValidationError } from '../../types' +import { type OperationSpec, type ValidationError } from 'types' import _ from 'lodash' import ValidatorBase from './base/ValidatorBase' diff --git a/src/linter/components/OperationGroup.ts b/tools/src/linter/components/OperationGroup.ts similarity index 98% rename from src/linter/components/OperationGroup.ts rename to tools/src/linter/components/OperationGroup.ts index 681563875..f99cb9ab3 100644 --- a/src/linter/components/OperationGroup.ts +++ b/tools/src/linter/components/OperationGroup.ts @@ -1,5 +1,5 @@ import type Operation from './Operation' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' import ValidatorBase from './base/ValidatorBase' export default class OperationGroup extends ValidatorBase { diff --git a/src/linter/components/Schema.ts b/tools/src/linter/components/Schema.ts similarity index 93% rename from src/linter/components/Schema.ts rename to tools/src/linter/components/Schema.ts index 38ac29017..d132f86e3 100644 --- a/src/linter/components/Schema.ts +++ b/tools/src/linter/components/Schema.ts @@ -1,6 +1,6 @@ import ValidatorBase from './base/ValidatorBase' import { type OpenAPIV3 } from 'openapi-types' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' const NAME_REGEX = /^[A-Za-z0-9]+$/ diff --git a/src/linter/components/SchemaFile.ts b/tools/src/linter/components/SchemaFile.ts similarity index 96% rename from src/linter/components/SchemaFile.ts rename to tools/src/linter/components/SchemaFile.ts index 074b76892..8fa364b13 100644 --- a/src/linter/components/SchemaFile.ts +++ b/tools/src/linter/components/SchemaFile.ts @@ -1,5 +1,5 @@ import FileValidator from './base/FileValidator' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' import Schema from './Schema' import { type OpenAPIV3 } from 'openapi-types' diff --git a/src/linter/components/SchemasFolder.ts b/tools/src/linter/components/SchemasFolder.ts similarity index 85% rename from src/linter/components/SchemasFolder.ts rename to tools/src/linter/components/SchemasFolder.ts index e40ff4f87..d6d30fd6a 100644 --- a/src/linter/components/SchemasFolder.ts +++ b/tools/src/linter/components/SchemasFolder.ts @@ -1,6 +1,6 @@ import SchemaFile from './SchemaFile' import FolderValidator from './base/FolderValidator' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' export default class SchemasFolder extends FolderValidator { constructor (folder_path: string) { diff --git a/src/linter/components/SupersededOperationsFile.ts b/tools/src/linter/components/SupersededOperationsFile.ts similarity index 100% rename from src/linter/components/SupersededOperationsFile.ts rename to tools/src/linter/components/SupersededOperationsFile.ts diff --git a/src/linter/components/base/FileValidator.ts b/tools/src/linter/components/base/FileValidator.ts similarity index 95% rename from src/linter/components/base/FileValidator.ts rename to tools/src/linter/components/base/FileValidator.ts index a0e0fa7c7..3d3a5d296 100644 --- a/src/linter/components/base/FileValidator.ts +++ b/tools/src/linter/components/base/FileValidator.ts @@ -1,7 +1,7 @@ import ValidatorBase from './ValidatorBase' -import { type ValidationError } from '../../../types' +import { type ValidationError } from 'types' import { type OpenAPIV3 } from 'openapi-types' -import { read_yaml } from '../../../helpers' +import { read_yaml } from '../../../../helpers' import AJV from 'ajv' import addFormats from 'ajv-formats' diff --git a/src/linter/components/base/FolderValidator.ts b/tools/src/linter/components/base/FolderValidator.ts similarity index 94% rename from src/linter/components/base/FolderValidator.ts rename to tools/src/linter/components/base/FolderValidator.ts index 30eafbfac..8a63644dc 100644 --- a/src/linter/components/base/FolderValidator.ts +++ b/tools/src/linter/components/base/FolderValidator.ts @@ -1,7 +1,7 @@ import fs from 'fs' import ValidatorBase from './ValidatorBase' import type FileValidator from './FileValidator' -import { type ValidationError } from '../../../types' +import { type ValidationError } from 'types' export default class FolderValidator extends ValidatorBase { folder_path: string diff --git a/src/linter/components/base/ValidatorBase.ts b/tools/src/linter/components/base/ValidatorBase.ts similarity index 88% rename from src/linter/components/base/ValidatorBase.ts rename to tools/src/linter/components/base/ValidatorBase.ts index 7b0deaafe..3790218bf 100644 --- a/src/linter/components/base/ValidatorBase.ts +++ b/tools/src/linter/components/base/ValidatorBase.ts @@ -1,4 +1,4 @@ -import { type ValidationError } from '../../../types' +import { type ValidationError } from 'types' export default class ValidatorBase { file: string location: string | undefined diff --git a/src/linter/lint.ts b/tools/src/linter/lint.ts similarity index 98% rename from src/linter/lint.ts rename to tools/src/linter/lint.ts index 32d2e80a3..6b30fa1d8 100644 --- a/src/linter/lint.ts +++ b/tools/src/linter/lint.ts @@ -4,7 +4,7 @@ import { resolve } from 'path' const command = new Command() .description('Validate the OpenSearch multi-file spec.') - .addOption(new Option('-s, --source ', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../spec'))) + .addOption(new Option('-s, --source ', 'path to the root folder of the multi-file spec').default(resolve(__dirname, '../../../spec'))) .allowExcessArguments(false) .parse() diff --git a/src/linter/utils/SpecificationVisitor.ts b/tools/src/linter/utils/SpecificationVisitor.ts similarity index 100% rename from src/linter/utils/SpecificationVisitor.ts rename to tools/src/linter/utils/SpecificationVisitor.ts diff --git a/src/linter/utils/index.ts b/tools/src/linter/utils/index.ts similarity index 97% rename from src/linter/utils/index.ts rename to tools/src/linter/utils/index.ts index 5e6bea1c3..db451638f 100644 --- a/src/linter/utils/index.ts +++ b/tools/src/linter/utils/index.ts @@ -1,5 +1,5 @@ import { type OpenAPIV3 } from 'openapi-types' -import { type ValidationError } from '../../types' +import { type ValidationError } from 'types' export function is_ref (o: MaybeRef): o is OpenAPIV3.ReferenceObject { return '$ref' in o diff --git a/src/merger/GlobalParamsGenerator.ts b/tools/src/merger/GlobalParamsGenerator.ts similarity index 97% rename from src/merger/GlobalParamsGenerator.ts rename to tools/src/merger/GlobalParamsGenerator.ts index 612c18fa0..e8da16ea2 100644 --- a/src/merger/GlobalParamsGenerator.ts +++ b/tools/src/merger/GlobalParamsGenerator.ts @@ -1,6 +1,6 @@ import { type OpenAPIV3 } from 'openapi-types' import _ from 'lodash' -import { read_yaml } from '../helpers' +import { read_yaml } from '../../helpers' export default class GlobalParamsGenerator { global_params: Record diff --git a/src/merger/OpenApiMerger.ts b/tools/src/merger/OpenApiMerger.ts similarity index 98% rename from src/merger/OpenApiMerger.ts rename to tools/src/merger/OpenApiMerger.ts index 0bb0be431..c2d8bec6f 100644 --- a/src/merger/OpenApiMerger.ts +++ b/tools/src/merger/OpenApiMerger.ts @@ -1,7 +1,7 @@ import { type OpenAPIV3 } from 'openapi-types' import fs from 'fs' import _ from 'lodash' -import { read_yaml, write_yaml } from '../helpers' +import { read_yaml, write_yaml } from '../../helpers' import SupersededOpsGenerator from './SupersededOpsGenerator' import GlobalParamsGenerator from './GlobalParamsGenerator' diff --git a/src/merger/OpenDistro.ts b/tools/src/merger/OpenDistro.ts similarity index 91% rename from src/merger/OpenDistro.ts rename to tools/src/merger/OpenDistro.ts index e35cace6e..b3d1d431d 100644 --- a/src/merger/OpenDistro.ts +++ b/tools/src/merger/OpenDistro.ts @@ -1,5 +1,5 @@ -import { type HttpVerb, type OperationPath, type SupersededOperationMap } from '../types' -import { read_yaml, write_yaml } from '../helpers' +import { type HttpVerb, type OperationPath, type SupersededOperationMap } from 'types' +import { read_yaml, write_yaml } from '../../helpers' // One-time script to generate _superseded_operations.yaml file for OpenDistro // Keeping this for now in case we need to update the file in the near future. Can be removed after a few months. diff --git a/src/merger/SupersededOpsGenerator.ts b/tools/src/merger/SupersededOpsGenerator.ts similarity index 97% rename from src/merger/SupersededOpsGenerator.ts rename to tools/src/merger/SupersededOpsGenerator.ts index 747204c61..b673aa3d1 100644 --- a/src/merger/SupersededOpsGenerator.ts +++ b/tools/src/merger/SupersededOpsGenerator.ts @@ -1,6 +1,6 @@ -import { type OperationSpec, type SupersededOperationMap } from '../types' +import { type OperationSpec, type SupersededOperationMap } from 'types' import _ from 'lodash' -import { read_yaml } from '../helpers' +import { read_yaml } from '../../helpers' export default class SupersededOpsGenerator { superseded_ops: SupersededOperationMap diff --git a/src/merger/merge.ts b/tools/src/merger/merge.ts similarity index 88% rename from src/merger/merge.ts rename to tools/src/merger/merge.ts index 6db2f0f9a..c38f29c97 100644 --- a/src/merger/merge.ts +++ b/tools/src/merger/merge.ts @@ -4,8 +4,8 @@ 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('-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'))) .allowExcessArguments(false) .parse() diff --git a/src/types.ts b/tools/src/types.ts similarity index 100% rename from src/types.ts rename to tools/src/types.ts diff --git a/tests/linter/InfoFile.test.ts b/tools/tests/linter/InfoFile.test.ts similarity index 77% rename from tests/linter/InfoFile.test.ts rename to tools/tests/linter/InfoFile.test.ts index bd342603c..e93f2ea0e 100644 --- a/tests/linter/InfoFile.test.ts +++ b/tools/tests/linter/InfoFile.test.ts @@ -1,7 +1,7 @@ import InfoFile from 'linter/components/InfoFile' test('validate()', () => { - const validator = new InfoFile('./tests/linter/fixtures/_info.yaml') + const validator = new InfoFile('./tools/tests/linter/fixtures/_info.yaml') expect(validator.validate()).toEqual([ { file: 'fixtures/_info.yaml', diff --git a/tests/linter/InlineObjectSchemaValidator.test.ts b/tools/tests/linter/InlineObjectSchemaValidator.test.ts similarity index 94% rename from tests/linter/InlineObjectSchemaValidator.test.ts rename to tools/tests/linter/InlineObjectSchemaValidator.test.ts index cbd7ec95a..6cff2d2c1 100644 --- a/tests/linter/InlineObjectSchemaValidator.test.ts +++ b/tools/tests/linter/InlineObjectSchemaValidator.test.ts @@ -3,7 +3,7 @@ import NamespacesFolder from 'linter/components/NamespacesFolder' import InlineObjectSchemaValidator from 'linter/InlineObjectSchemaValidator' test('validate()', () => { - const root_folder = './tests/linter/fixtures/inline_object_schema_validator' + const root_folder = './tools/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/linter/NamespaceFile.test.ts b/tools/tests/linter/NamespaceFile.test.ts similarity index 100% rename from tests/linter/NamespaceFile.test.ts rename to tools/tests/linter/NamespaceFile.test.ts diff --git a/tests/linter/NamespacesFolder.test.ts b/tools/tests/linter/NamespacesFolder.test.ts similarity index 88% rename from tests/linter/NamespacesFolder.test.ts rename to tools/tests/linter/NamespacesFolder.test.ts index 4b23b8e99..08b1ac854 100644 --- a/tests/linter/NamespacesFolder.test.ts +++ b/tools/tests/linter/NamespacesFolder.test.ts @@ -1,7 +1,7 @@ import NamespacesFolder from 'linter/components/NamespacesFolder' test('validate() - When there invalid files', () => { - const validator = new NamespacesFolder('./tests/linter/fixtures/folder_validators/namespaces/invalid_files') + const validator = new NamespacesFolder('./tools/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/linter/fixtures/folder_validators/namespaces/invalid_folder') + const validator = new NamespacesFolder('./tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder') expect(validator.validate()).toEqual([ { file: 'invalid_folder/', diff --git a/tests/linter/Operation.test.ts b/tools/tests/linter/Operation.test.ts similarity index 100% rename from tests/linter/Operation.test.ts rename to tools/tests/linter/Operation.test.ts diff --git a/tests/linter/OperationGroup.test.ts b/tools/tests/linter/OperationGroup.test.ts similarity index 100% rename from tests/linter/OperationGroup.test.ts rename to tools/tests/linter/OperationGroup.test.ts diff --git a/tests/linter/Schema.test.ts b/tools/tests/linter/Schema.test.ts similarity index 100% rename from tests/linter/Schema.test.ts rename to tools/tests/linter/Schema.test.ts diff --git a/tests/linter/SchemaFile.test.ts b/tools/tests/linter/SchemaFile.test.ts similarity index 100% rename from tests/linter/SchemaFile.test.ts rename to tools/tests/linter/SchemaFile.test.ts diff --git a/tests/linter/SchemaRefsValidator.test.ts b/tools/tests/linter/SchemaRefsValidator.test.ts similarity index 93% rename from tests/linter/SchemaRefsValidator.test.ts rename to tools/tests/linter/SchemaRefsValidator.test.ts index 1f295b87b..7cae50ad1 100644 --- a/tests/linter/SchemaRefsValidator.test.ts +++ b/tools/tests/linter/SchemaRefsValidator.test.ts @@ -3,7 +3,7 @@ import NamespacesFolder from 'linter/components/NamespacesFolder' import SchemaRefsValidator from 'linter/SchemaRefsValidator' test('validate()', () => { - const root_folder = './tests/linter/fixtures/schema_refs_validator' + const root_folder = './tools/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/linter/SpecValidator.test.ts b/tools/tests/linter/SpecValidator.test.ts similarity index 92% rename from tests/linter/SpecValidator.test.ts rename to tools/tests/linter/SpecValidator.test.ts index a1739ee08..0ba8cb576 100644 --- a/tests/linter/SpecValidator.test.ts +++ b/tools/tests/linter/SpecValidator.test.ts @@ -1,7 +1,7 @@ import SpecValidator from 'linter/SpecValidator' test('validate()', () => { - const validator = new SpecValidator('./tests/linter/fixtures/empty') + const validator = new SpecValidator('./tools/tests/linter/fixtures/empty') expect(validator.validate()).toEqual([]) validator.namespaces_folder.validate = jest.fn().mockReturnValue([{ file: 'namespaces/', message: 'namespace error' }]) diff --git a/tests/linter/SupersededOperationsFile.test.ts b/tools/tests/linter/SupersededOperationsFile.test.ts similarity index 87% rename from tests/linter/SupersededOperationsFile.test.ts rename to tools/tests/linter/SupersededOperationsFile.test.ts index 5c6c5732d..5c97edfff 100644 --- a/tests/linter/SupersededOperationsFile.test.ts +++ b/tools/tests/linter/SupersededOperationsFile.test.ts @@ -1,7 +1,7 @@ import SupersededOperationsFile from 'linter/components/SupersededOperationsFile' test('validate()', () => { - const validator = new SupersededOperationsFile('./tests/linter/fixtures/_superseded_operations.yaml') + const validator = new SupersededOperationsFile('./tools/tests/linter/fixtures/_superseded_operations.yaml') expect(validator.validate()).toEqual([ { file: 'fixtures/_superseded_operations.yaml', diff --git a/tests/linter/factories/namespace_file.ts b/tools/tests/linter/factories/namespace_file.ts similarity index 95% rename from tests/linter/factories/namespace_file.ts rename to tools/tests/linter/factories/namespace_file.ts index 8f1215801..7c130de4d 100644 --- a/tests/linter/factories/namespace_file.ts +++ b/tools/tests/linter/factories/namespace_file.ts @@ -3,7 +3,7 @@ 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/linter/fixtures/file_validators/namespaces/${fixture_file}`) + return new NamespaceFile(`./tools/tests/linter/fixtures/file_validators/namespaces/${fixture_file}`) } interface MockedReturnedValues { diff --git a/tests/linter/factories/operation.ts b/tools/tests/linter/factories/operation.ts similarity index 100% rename from tests/linter/factories/operation.ts rename to tools/tests/linter/factories/operation.ts diff --git a/tests/linter/factories/operation_group.ts b/tools/tests/linter/factories/operation_group.ts similarity index 100% rename from tests/linter/factories/operation_group.ts rename to tools/tests/linter/factories/operation_group.ts diff --git a/tests/linter/factories/schema.ts b/tools/tests/linter/factories/schema.ts similarity index 100% rename from tests/linter/factories/schema.ts rename to tools/tests/linter/factories/schema.ts diff --git a/tests/linter/factories/schema_file.ts b/tools/tests/linter/factories/schema_file.ts similarity index 92% rename from tests/linter/factories/schema_file.ts rename to tools/tests/linter/factories/schema_file.ts index 98e785aae..b19c9724f 100644 --- a/tests/linter/factories/schema_file.ts +++ b/tools/tests/linter/factories/schema_file.ts @@ -2,7 +2,7 @@ import { mocked_schema } from './schema' import SchemaFile from 'linter/components/SchemaFile' export function schema_file (fixture: string): SchemaFile { - return new SchemaFile(`./tests/linter/fixtures/file_validators/schemas/${fixture}`) + return new SchemaFile(`./tools/tests/linter/fixtures/file_validators/schemas/${fixture}`) } interface MockedReturnedValues { diff --git a/tests/linter/fixtures/_info.yaml b/tools/tests/linter/fixtures/_info.yaml similarity index 100% rename from tests/linter/fixtures/_info.yaml rename to tools/tests/linter/fixtures/_info.yaml diff --git a/tests/linter/fixtures/_superseded_operations.yaml b/tools/tests/linter/fixtures/_superseded_operations.yaml similarity index 100% rename from tests/linter/fixtures/_superseded_operations.yaml rename to tools/tests/linter/fixtures/_superseded_operations.yaml diff --git a/tests/linter/fixtures/empty/_info.yaml b/tools/tests/linter/fixtures/empty/_info.yaml similarity index 100% rename from tests/linter/fixtures/empty/_info.yaml rename to tools/tests/linter/fixtures/empty/_info.yaml diff --git a/tests/linter/fixtures/empty/_superseded_operations.yaml b/tools/tests/linter/fixtures/empty/_superseded_operations.yaml similarity index 100% rename from tests/linter/fixtures/empty/_superseded_operations.yaml rename to tools/tests/linter/fixtures/empty/_superseded_operations.yaml diff --git a/tests/linter/fixtures/empty/namespaces/.gitkeep b/tools/tests/linter/fixtures/empty/namespaces/.gitkeep similarity index 100% rename from tests/linter/fixtures/empty/namespaces/.gitkeep rename to tools/tests/linter/fixtures/empty/namespaces/.gitkeep diff --git a/tests/linter/fixtures/empty/opensearch-openapi.yaml b/tools/tests/linter/fixtures/empty/opensearch-openapi.yaml similarity index 100% rename from tests/linter/fixtures/empty/opensearch-openapi.yaml rename to tools/tests/linter/fixtures/empty/opensearch-openapi.yaml diff --git a/tests/linter/fixtures/empty/schemas/.gitkeep b/tools/tests/linter/fixtures/empty/schemas/.gitkeep similarity index 100% rename from tests/linter/fixtures/empty/schemas/.gitkeep rename to tools/tests/linter/fixtures/empty/schemas/.gitkeep diff --git a/tests/linter/fixtures/file_validators/namespaces/empty.yaml b/tools/tests/linter/fixtures/file_validators/namespaces/empty.yaml similarity index 100% rename from tests/linter/fixtures/file_validators/namespaces/empty.yaml rename to tools/tests/linter/fixtures/file_validators/namespaces/empty.yaml diff --git a/tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml b/tools/tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml similarity index 100% rename from tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml rename to tools/tests/linter/fixtures/file_validators/namespaces/invalid_components.yaml diff --git a/tests/linter/fixtures/file_validators/schemas/_common.empty.yaml b/tools/tests/linter/fixtures/file_validators/schemas/_common.empty.yaml similarity index 100% rename from tests/linter/fixtures/file_validators/schemas/_common.empty.yaml rename to tools/tests/linter/fixtures/file_validators/schemas/_common.empty.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_a.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_b.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/dup_path_c.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/indices.txt diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_yaml.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_a.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_b.yaml diff --git a/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml similarity index 100% rename from tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml rename to tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_c.yaml diff --git a/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml b/tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml similarity index 100% rename from tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml rename to tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml diff --git a/tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml b/tools/tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml similarity index 100% rename from tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml rename to tools/tests/linter/fixtures/inline_object_schema_validator/schemas/schemas.yaml diff --git a/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml b/tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml similarity index 100% rename from tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml rename to tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml diff --git a/tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml b/tools/tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml similarity index 100% rename from tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml rename to tools/tests/linter/fixtures/schema_refs_validator/schemas/animals.yaml diff --git a/tests/linter/fixtures/schema_refs_validator/schemas/others.yaml b/tools/tests/linter/fixtures/schema_refs_validator/schemas/others.yaml similarity index 100% rename from tests/linter/fixtures/schema_refs_validator/schemas/others.yaml rename to tools/tests/linter/fixtures/schema_refs_validator/schemas/others.yaml diff --git a/tools/tests/merger/OpenApiMerger.test.ts b/tools/tests/merger/OpenApiMerger.test.ts new file mode 100644 index 000000000..f261aef0b --- /dev/null +++ b/tools/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('./tools/tests/merger/fixtures/spec/') + merger.merge('./tools/tests/merger/opensearch-openapi.yaml') + expect(fs.readFileSync('./tools/tests/merger/fixtures/expected.yaml', 'utf8')) + .toEqual(fs.readFileSync('./tools/tests/merger/opensearch-openapi.yaml', 'utf8')) + fs.unlinkSync('./tools/tests/merger/opensearch-openapi.yaml') +}) diff --git a/tests/merger/fixtures/expected.yaml b/tools/tests/merger/fixtures/expected.yaml similarity index 100% rename from tests/merger/fixtures/expected.yaml rename to tools/tests/merger/fixtures/expected.yaml diff --git a/tests/merger/fixtures/spec/_global_parameters.yaml b/tools/tests/merger/fixtures/spec/_global_parameters.yaml similarity index 100% rename from tests/merger/fixtures/spec/_global_parameters.yaml rename to tools/tests/merger/fixtures/spec/_global_parameters.yaml diff --git a/tests/merger/fixtures/spec/_info.yaml b/tools/tests/merger/fixtures/spec/_info.yaml similarity index 100% rename from tests/merger/fixtures/spec/_info.yaml rename to tools/tests/merger/fixtures/spec/_info.yaml diff --git a/tests/merger/fixtures/spec/_superseded_operations.yaml b/tools/tests/merger/fixtures/spec/_superseded_operations.yaml similarity index 100% rename from tests/merger/fixtures/spec/_superseded_operations.yaml rename to tools/tests/merger/fixtures/spec/_superseded_operations.yaml diff --git a/tests/merger/fixtures/spec/namespaces/indices.yaml b/tools/tests/merger/fixtures/spec/namespaces/indices.yaml similarity index 100% rename from tests/merger/fixtures/spec/namespaces/indices.yaml rename to tools/tests/merger/fixtures/spec/namespaces/indices.yaml diff --git a/tests/merger/fixtures/spec/namespaces/shelter.yaml b/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml similarity index 100% rename from tests/merger/fixtures/spec/namespaces/shelter.yaml rename to tools/tests/merger/fixtures/spec/namespaces/shelter.yaml diff --git a/tests/merger/fixtures/spec/schemas/actions.yaml b/tools/tests/merger/fixtures/spec/schemas/actions.yaml similarity index 100% rename from tests/merger/fixtures/spec/schemas/actions.yaml rename to tools/tests/merger/fixtures/spec/schemas/actions.yaml diff --git a/tests/merger/fixtures/spec/schemas/animals.yaml b/tools/tests/merger/fixtures/spec/schemas/animals.yaml similarity index 100% rename from tests/merger/fixtures/spec/schemas/animals.yaml rename to tools/tests/merger/fixtures/spec/schemas/animals.yaml diff --git a/tsconfig.json b/tsconfig.json index 781197568..8312f50b5 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": "./src", /* Specify the base directory to resolve non-relative module names. */ + "baseUrl": "./tools/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'. */