diff --git a/spec/_replaced_operations.yaml b/spec/_replaced_operations.yaml new file mode 100644 index 000000000..2bb951699 --- /dev/null +++ b/spec/_replaced_operations.yaml @@ -0,0 +1,566 @@ +/_opendistro/_alerting/destinations: + replaced_by: /_plugins/_alerting/destinations + operations: + - GET +/_opendistro/_alerting/destinations/email_accounts/_search: + replaced_by: /_plugins/_alerting/destinations/email_accounts/_search + operations: + - GET + - POST +/_opendistro/_alerting/destinations/email_accounts/{emailAccountID}: + replaced_by: /_plugins/_alerting/destinations/email_accounts/{emailAccountID} + operations: + - GET + - HEAD +/_opendistro/_alerting/destinations/email_groups/_search: + replaced_by: /_plugins/_alerting/destinations/email_groups/_search + operations: + - GET + - POST +/_opendistro/_alerting/destinations/email_groups/{emailGroupID}: + replaced_by: /_plugins/_alerting/destinations/email_groups/{emailGroupID} + operations: + - GET + - HEAD +/_opendistro/_alerting/destinations/{destinationID}: + replaced_by: /_plugins/_alerting/destinations/{destinationID} + operations: + - GET +/_opendistro/_alerting/monitors: + replaced_by: /_plugins/_alerting/monitors + operations: + - POST +/_opendistro/_alerting/monitors/_execute: + replaced_by: /_plugins/_alerting/monitors/_execute + operations: + - POST +/_opendistro/_alerting/monitors/_search: + replaced_by: /_plugins/_alerting/monitors/_search + operations: + - GET + - POST +/_opendistro/_alerting/monitors/alerts: + replaced_by: /_plugins/_alerting/monitors/alerts + operations: + - GET +/_opendistro/_alerting/monitors/{monitorID}: + replaced_by: /_plugins/_alerting/monitors/{monitorID} + operations: + - GET + - PUT + - DELETE + - HEAD +/_opendistro/_alerting/monitors/{monitorID}/_acknowledge/alerts: + replaced_by: /_plugins/_alerting/monitors/{monitorID}/_acknowledge/alerts + operations: + - POST +/_opendistro/_alerting/monitors/{monitorID}/_execute: + replaced_by: /_plugins/_alerting/monitors/{monitorID}/_execute + operations: + - POST +/_opendistro/_alerting/stats/: + replaced_by: /_plugins/_alerting/stats/ + operations: + - GET +/_opendistro/_alerting/stats/{metric}: + replaced_by: /_plugins/_alerting/stats/{metric} + operations: + - GET +/_opendistro/_alerting/{nodeId}/stats/: + replaced_by: /_plugins/_alerting/{nodeId}/stats/ + operations: + - GET +/_opendistro/_alerting/{nodeId}/stats/{metric}: + replaced_by: /_plugins/_alerting/{nodeId}/stats/{metric} + operations: + - GET +/_opendistro/_anomaly_detection/detectors: + replaced_by: /_plugins/_anomaly_detection/detectors + operations: + - POST +/_opendistro/_anomaly_detection/detectors/_search: + replaced_by: /_plugins/_anomaly_detection/detectors/_search + operations: + - GET + - POST +/_opendistro/_anomaly_detection/detectors/count: + replaced_by: /_plugins/_anomaly_detection/detectors/count + operations: + - GET +/_opendistro/_anomaly_detection/detectors/match: + replaced_by: /_plugins/_anomaly_detection/detectors/match + operations: + - GET +/_opendistro/_anomaly_detection/detectors/results/_search: + replaced_by: /_plugins/_anomaly_detection/detectors/results/_search + operations: + - GET + - POST +/_opendistro/_anomaly_detection/detectors/tasks/_search: + replaced_by: /_plugins/_anomaly_detection/detectors/tasks/_search + operations: + - GET + - POST +/_opendistro/_anomaly_detection/detectors/{detectorID}: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID} + operations: + - GET + - PUT + - DELETE + - HEAD +/_opendistro/_anomaly_detection/detectors/{detectorID}/_preview: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_preview + operations: + - POST +/_opendistro/_anomaly_detection/detectors/{detectorID}/_profile: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_profile + operations: + - GET +/_opendistro/_anomaly_detection/detectors/{detectorID}/_profile/{type}: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_profile/{type} + operations: + - GET +/_opendistro/_anomaly_detection/detectors/{detectorID}/_run: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_run + operations: + - POST +/_opendistro/_anomaly_detection/detectors/{detectorID}/_start: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_start + operations: + - POST +/_opendistro/_anomaly_detection/detectors/{detectorID}/_stop: + replaced_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_stop + operations: + - POST +/_opendistro/_anomaly_detection/stats/: + replaced_by: /_plugins/_anomaly_detection/stats/ + operations: + - GET +/_opendistro/_anomaly_detection/stats/{stat}: + replaced_by: /_plugins/_anomaly_detection/stats/{stat} + operations: + - GET +/_opendistro/_anomaly_detection/{nodeId}/stats/: + replaced_by: /_plugins/_anomaly_detection/{nodeId}/stats/ + operations: + - GET +/_opendistro/_anomaly_detection/{nodeId}/stats/{stat}: + replaced_by: /_plugins/_anomaly_detection/{nodeId}/stats/{stat} + operations: + - GET +/_opendistro/_asynchronous_search: + replaced_by: /_plugins/_asynchronous_search + operations: + - POST +/_opendistro/_asynchronous_search/_nodes/{nodeId}/stats: + replaced_by: /_plugins/_asynchronous_search/_nodes/{nodeId}/stats + operations: + - GET +/_opendistro/_asynchronous_search/stats: + replaced_by: /_plugins/_asynchronous_search/stats + operations: + - GET +/_opendistro/_asynchronous_search/{id}: + replaced_by: /_plugins/_asynchronous_search/{id} + operations: + - GET + - DELETE +/_opendistro/_ism/add: + replaced_by: /_plugins/_ism/add + operations: + - POST +/_opendistro/_ism/add/{index}: + replaced_by: /_plugins/_ism/add/{index} + operations: + - POST +/_opendistro/_ism/change_policy: + replaced_by: /_plugins/_ism/change_policy + operations: + - POST +/_opendistro/_ism/change_policy/{index}: + replaced_by: /_plugins/_ism/change_policy/{index} + operations: + - POST +/_opendistro/_ism/explain: + replaced_by: /_plugins/_ism/explain + operations: + - GET +/_opendistro/_ism/explain/{index}: + replaced_by: /_plugins/_ism/explain/{index} + operations: + - GET +/_opendistro/_ism/policies: + replaced_by: /_plugins/_ism/policies + operations: + - GET + - PUT +/_opendistro/_ism/policies/{policyID}: + replaced_by: /_plugins/_ism/policies/{policyID} + operations: + - GET + - PUT + - DELETE + - HEAD +/_opendistro/_ism/remove: + replaced_by: /_plugins/_ism/remove + operations: + - POST +/_opendistro/_ism/remove/{index}: + replaced_by: /_plugins/_ism/remove/{index} + operations: + - POST +/_opendistro/_ism/retry: + replaced_by: /_plugins/_ism/retry + operations: + - POST +/_opendistro/_ism/retry/{index}: + replaced_by: /_plugins/_ism/retry/{index} + operations: + - POST +/_opendistro/_knn/stats/: + replaced_by: /_plugins/_knn/stats/ + operations: + - GET +/_opendistro/_knn/stats/{stat}: + replaced_by: /_plugins/_knn/stats/{stat} + operations: + - GET +/_opendistro/_knn/warmup/{index}: + replaced_by: /_plugins/_knn/warmup/{index} + operations: + - GET +/_opendistro/_knn/{nodeId}/stats/: + replaced_by: /_plugins/_knn/{nodeId}/stats/ + operations: + - GET +/_opendistro/_knn/{nodeId}/stats/{stat}: + replaced_by: /_plugins/_knn/{nodeId}/stats/{stat} + operations: + - GET +/_opendistro/_performanceanalyzer/_agent/{redirectEndpoint}: + replaced_by: /_plugins/_performanceanalyzer/_agent/{redirectEndpoint} + operations: + - GET +/_opendistro/_performanceanalyzer/batch/cluster/config: + replaced_by: /_plugins/_performanceanalyzer/batch/cluster/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/batch/config: + replaced_by: /_plugins/_performanceanalyzer/batch/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/cluster/config: + replaced_by: /_plugins/_performanceanalyzer/cluster/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/config: + replaced_by: /_plugins/_performanceanalyzer/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/logging/cluster/config: + replaced_by: /_plugins/_performanceanalyzer/logging/cluster/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/logging/config: + replaced_by: /_plugins/_performanceanalyzer/logging/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/override/cluster/config: + replaced_by: /_plugins/_performanceanalyzer/override/cluster/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/rca/cluster/config: + replaced_by: /_plugins/_performanceanalyzer/rca/cluster/config + operations: + - GET + - POST +/_opendistro/_performanceanalyzer/rca/config: + replaced_by: /_plugins/_performanceanalyzer/rca/config + operations: + - GET + - POST +/_opendistro/_ppl: + replaced_by: /_plugins/_ppl + operations: + - POST +/_opendistro/_ppl/_explain: + replaced_by: /_plugins/_ppl/_explain + operations: + - POST +/_opendistro/_ppl/stats: + replaced_by: /_plugins/_ppl/stats + operations: + - GET + - POST +/_opendistro/_refresh_search_analyzers: + replaced_by: /_plugins/_refresh_search_analyzers + operations: + - POST +/_opendistro/_refresh_search_analyzers/{index}: + replaced_by: /_plugins/_refresh_search_analyzers/{index} + operations: + - POST +/_opendistro/_reports/_local/stats: + replaced_by: /_plugins/_reports/_local/stats + operations: + - GET +/_opendistro/_reports/definition: + replaced_by: /_plugins/_reports/definition + operations: + - POST +/_opendistro/_reports/definition/{reportDefinitionId}: + replaced_by: /_plugins/_reports/definition/{reportDefinitionId} + operations: + - GET + - PUT + - DELETE +/_opendistro/_reports/definitions: + replaced_by: /_plugins/_reports/definitions + operations: + - GET +/_opendistro/_reports/instance/{reportInstanceId}: + replaced_by: /_plugins/_reports/instance/{reportInstanceId} + operations: + - GET + - POST +/_opendistro/_reports/instances: + replaced_by: /_plugins/_reports/instances + operations: + - GET +/_opendistro/_reports/on_demand: + replaced_by: /_plugins/_reports/on_demand + operations: + - PUT +/_opendistro/_reports/on_demand/{reportDefinitionId}: + replaced_by: /_plugins/_reports/on_demand/{reportDefinitionId} + operations: + - POST +/_opendistro/_rollup/jobs: + replaced_by: /_plugins/_rollup/jobs + operations: + - GET + - PUT +/_opendistro/_rollup/jobs/{rollupID}: + replaced_by: /_plugins/_rollup/jobs/{rollupID} + operations: + - GET + - PUT + - DELETE + - HEAD +/_opendistro/_rollup/jobs/{rollupID}/_explain: + replaced_by: /_plugins/_rollup/jobs/{rollupID}/_explain + operations: + - GET +/_opendistro/_rollup/jobs/{rollupID}/_start: + replaced_by: /_plugins/_rollup/jobs/{rollupID}/_start + operations: + - POST +/_opendistro/_rollup/jobs/{rollupID}/_stop: + replaced_by: /_plugins/_rollup/jobs/{rollupID}/_stop + operations: + - POST +/_opendistro/_security/api/account: + replaced_by: /_plugins/_security/api/account + operations: + - GET + - PUT +/_opendistro/_security/api/actiongroup/: + replaced_by: /_plugins/_security/api/actiongroup/ + operations: + - GET +/_opendistro/_security/api/actiongroup/{name}: + replaced_by: /_plugins/_security/api/actiongroup/{name} + operations: + - GET + - PUT + - DELETE +/_opendistro/_security/api/actiongroups/: + replaced_by: /_plugins/_security/api/actiongroups/ + operations: + - GET + - PATCH +/_opendistro/_security/api/actiongroups/{name}: + replaced_by: /_plugins/_security/api/actiongroups/{name} + operations: + - GET + - PUT + - DELETE + - PATCH +/_opendistro/_security/api/audit/: + replaced_by: /_plugins/_security/api/audit/ + operations: + - GET + - PATCH +/_opendistro/_security/api/audit/config: + replaced_by: /_plugins/_security/api/audit/config + operations: + - PUT +/_opendistro/_security/api/authtoken: + replaced_by: /_plugins/_security/api/authtoken + operations: + - POST +/_opendistro/_security/api/cache: + replaced_by: /_plugins/_security/api/cache + operations: + - GET + - PUT + - POST + - DELETE +/_opendistro/_security/api/internalusers/: + replaced_by: /_plugins/_security/api/internalusers/ + operations: + - GET + - PATCH +/_opendistro/_security/api/internalusers/{name}: + replaced_by: /_plugins/_security/api/internalusers/{name} + operations: + - GET + - PUT + - DELETE + - PATCH +/_opendistro/_security/api/internalusers/{name}/authtoken: + replaced_by: /_plugins/_security/api/internalusers/{name}/authtoken + operations: + - POST +/_opendistro/_security/api/migrate: + replaced_by: /_plugins/_security/api/migrate + operations: + - POST +/_opendistro/_security/api/permissionsinfo: + replaced_by: /_plugins/_security/api/permissionsinfo + operations: + - GET +/_opendistro/_security/api/roles/: + replaced_by: /_plugins/_security/api/roles/ + operations: + - GET + - PATCH +/_opendistro/_security/api/roles/{name}: + replaced_by: /_plugins/_security/api/roles/{name} + operations: + - GET + - PUT + - DELETE + - PATCH +/_opendistro/_security/api/rolesmapping/: + replaced_by: /_plugins/_security/api/rolesmapping/ + operations: + - GET + - PATCH +/_opendistro/_security/api/rolesmapping/{name}: + replaced_by: /_plugins/_security/api/rolesmapping/{name} + operations: + - GET + - PUT + - DELETE + - PATCH +/_opendistro/_security/api/securityconfig: + replaced_by: /_plugins/_security/api/securityconfig + operations: + - GET + - PATCH +/_opendistro/_security/api/securityconfig/config: + replaced_by: /_plugins/_security/api/securityconfig/config + operations: + - PUT +/_opendistro/_security/api/ssl/certs: + replaced_by: /_plugins/_security/api/ssl/certs + operations: + - GET +/_opendistro/_security/api/ssl/{certType}/reloadcerts/: + replaced_by: /_plugins/_security/api/ssl/{certType}/reloadcerts/ + operations: + - PUT +/_opendistro/_security/api/tenancy/config: + replaced_by: /_plugins/_security/api/tenancy/config + operations: + - GET + - PUT +/_opendistro/_security/api/tenants/: + replaced_by: /_plugins/_security/api/tenants/ + operations: + - GET + - PATCH +/_opendistro/_security/api/tenants/{name}: + replaced_by: /_plugins/_security/api/tenants/{name} + operations: + - GET + - PUT + - DELETE + - PATCH +/_opendistro/_security/api/user/: + replaced_by: /_plugins/_security/api/user/ + operations: + - GET +/_opendistro/_security/api/user/{name}: + replaced_by: /_plugins/_security/api/user/{name} + operations: + - GET + - PUT + - DELETE +/_opendistro/_security/api/user/{name}/authtoken: + replaced_by: /_plugins/_security/api/user/{name}/authtoken + operations: + - POST +/_opendistro/_security/api/validate: + replaced_by: /_plugins/_security/api/validate + operations: + - GET +/_opendistro/_security/api/whitelist: + replaced_by: /_plugins/_security/api/whitelist + operations: + - GET + - PUT + - PATCH +/_opendistro/_security/authinfo: + replaced_by: /_plugins/_security/authinfo + operations: + - GET + - POST +/_opendistro/_security/health: + replaced_by: /_plugins/_security/health + operations: + - GET + - POST +/_opendistro/_security/kibanainfo: + replaced_by: /_plugins/_security/kibanainfo + operations: + - GET + - POST +/_opendistro/_security/sslinfo: + replaced_by: /_plugins/_security/sslinfo + operations: + - GET +/_opendistro/_security/tenantinfo: + replaced_by: /_plugins/_security/tenantinfo + operations: + - GET + - POST +/_opendistro/_sql: + replaced_by: /_plugins/_sql + operations: + - POST +/_opendistro/_sql/_explain: + replaced_by: /_plugins/_sql/_explain + operations: + - POST +/_opendistro/_sql/close: + replaced_by: /_plugins/_sql/close + operations: + - POST +/_opendistro/_sql/settings: + replaced_by: /_plugins/_sql/settings + operations: + - PUT +/_opendistro/_sql/stats: + replaced_by: /_plugins/_sql/stats + operations: + - GET + - POST diff --git a/tools/merger/OpenApiMerger.ts b/tools/merger/OpenApiMerger.ts index 2e108ce55..a82ed2738 100644 --- a/tools/merger/OpenApiMerger.ts +++ b/tools/merger/OpenApiMerger.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import _ from 'lodash'; import yaml from 'yaml'; import { write2file } from '../helpers'; +import ReplacedOpsGenerator from "./ReplacedOpsGenerator"; // Create a single-file OpenAPI spec from multiple files for OpenAPI validation and programmatic consumption export default class OpenApiMerger { @@ -33,6 +34,7 @@ export default class OpenApiMerger { this.#merge_namespaces(); this.#apply_global_params(); this.#sort_spec_keys(); + this.#generate_replaced_ops(); if(output_path) write2file(output_path, this.spec); return this.spec as OpenAPIV3.Document; @@ -124,4 +126,9 @@ export default class OpenApiMerger { this.spec.paths[path] = _.fromPairs(Object.entries(pathItem!).sort()); }); } + + #generate_replaced_ops(): void { + const gen = new ReplacedOpsGenerator(this.root_folder); + gen.generate(this.spec); + } } \ No newline at end of file diff --git a/tools/merger/OpenDistro.ts b/tools/merger/OpenDistro.ts new file mode 100644 index 000000000..253f33285 --- /dev/null +++ b/tools/merger/OpenDistro.ts @@ -0,0 +1,25 @@ +import fs from "fs"; +import YAML from "yaml"; +import { OperationPath, HttpVerb, ReplacedOperationMap } from "../types"; +import { write2file } from "../helpers"; + +// One-time script to generate _replaced_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. +// TODO: Remove this file in 2025. +export default class OpenDistro { + input: Record; + output: ReplacedOperationMap = {}; + + constructor(file_path: string) { + this.input = YAML.parse(fs.readFileSync(file_path, 'utf8')); + this.build_output(); + write2file(file_path, this.output); + } + + build_output() { + for(const [path, operations] of Object.entries(this.input)) { + const replaced_by = path.replace('_opendistro', '_plugins'); + this.output[path] = { replaced_by, operations }; + } + } +} \ No newline at end of file diff --git a/tools/merger/ReplacedOpsGenerator.ts b/tools/merger/ReplacedOpsGenerator.ts new file mode 100644 index 000000000..219f7d393 --- /dev/null +++ b/tools/merger/ReplacedOpsGenerator.ts @@ -0,0 +1,50 @@ +import {OperationSpec, ReplacedOperationMap} from "../types"; +import YAML from "yaml"; +import fs from "fs"; +import _ from "lodash"; + +export default class ReplacedOpsGenerator { + file_path: string; + replaced_ops: ReplacedOperationMap; + + constructor(root_path: string) { + this.file_path = root_path + '/_replaced_operations.yaml'; + this.replaced_ops = YAML.parse(fs.readFileSync(this.file_path, 'utf8')); + } + + generate(spec: Record): void { + for(const [path, { replaced_by, operations }] of _.entries(this.replaced_ops)) { + const regex = this.path_to_regex(replaced_by); + const operation_keys = operations.map(op => op.toLowerCase()); + const replaced_path = this.copy_params(replaced_by, path); + const path_entry = _.entries(spec.paths).find(([path, _]) => regex.test(path)); + if(!path_entry) console.log(`Path not found: ${replaced_by}`); + else spec.paths[replaced_path] = this.path_object(path_entry[1] as any, operation_keys); + } + } + + path_object(obj: Record, keys: string[]): Record { + const cloned_obj = _.cloneDeep(_.pick(obj, keys)); + for(const key in cloned_obj) { + const operation = cloned_obj[key] as OperationSpec; + operation.operationId = operation.operationId + '_replaced'; + operation.deprecated = true; + operation['x-ignorable'] = true; + } + return cloned_obj; + } + + path_to_regex(path: string): RegExp { + const source = '^' + path.replace(/\{.+?}/g, '\\{.+?\\}').replace(/\//g, '\\/') + '$'; + return new RegExp(source, 'g'); + } + + copy_params(source: string, target: string): string { + const target_parts = target.split('/'); + const target_params = target_parts.filter(part => part.startsWith('{')); + const source_params = source.split('/').filter(part => part.startsWith('{')).reverse(); + if(target_params.length !== source_params.length) + throw new Error('Mismatched parameters in source and target paths: ' + source + ' -> ' + target); + return target_parts.map((part) => part.startsWith('{') ? source_params.pop()! : part).join('/'); + } +} \ No newline at end of file diff --git a/tools/merger/merge.ts b/tools/merger/merge.ts index 98758cb34..60a07ea49 100644 --- a/tools/merger/merge.ts +++ b/tools/merger/merge.ts @@ -4,4 +4,4 @@ import OpenApiMerger from "./OpenApiMerger"; const root_path: string = process.argv[2] || '../spec/opensearch-openapi.yaml' const output_path: string = process.argv[3] || '../opensearch-openapi.yaml' const merger = new OpenApiMerger(root_path); -merger.merge(output_path); \ No newline at end of file +merger.merge(output_path); diff --git a/tools/test/merger/fixtures/expected.yaml b/tools/test/merger/fixtures/expected.yaml index 1d28db66d..76d99b7dd 100644 --- a/tools/test/merger/fixtures/expected.yaml +++ b/tools/test/merger/fixtures/expected.yaml @@ -4,23 +4,39 @@ info: description: OpenSearch API version: 1.0.0 paths: - /adopt/{animal}: + /adopt/{animal}/dockets/{docket}: get: + operationId: adopt.0 parameters: - $ref: '#/components/parameters/adopt::path.animal' + - $ref: '#/components/parameters/adopt::path.docket' - $ref: '#/components/parameters/_global::query.human' responses: '200': $ref: '#/components/responses/adopt@200' post: + operationId: adopt.1 parameters: - $ref: '#/components/parameters/adopt::path.animal' + - $ref: '#/components/parameters/adopt::path.docket' - $ref: '#/components/parameters/_global::query.human' requestBody: $ref: '#/components/requestBodies/adopt' responses: '200': $ref: '#/components/responses/adopt@200' + /replaced/adopting/{animal}/something/{docket}: + get: + operationId: adopt.0_replaced + parameters: + - $ref: '#/components/parameters/adopt::path.animal' + - $ref: '#/components/parameters/adopt::path.docket' + - $ref: '#/components/parameters/_global::query.human' + responses: + '200': + $ref: '#/components/responses/adopt@200' + deprecated: true + x-ignorable: true components: parameters: _global::query.human: @@ -36,6 +52,11 @@ components: in: path schema: $ref: '#/components/schemas/animals:Animal' + adopt::path.docket: + name: docket + in: path + schema: + type: number indices.create::path.index: name: index in: path diff --git a/tools/test/merger/fixtures/spec/_replaced_operations.yaml b/tools/test/merger/fixtures/spec/_replaced_operations.yaml new file mode 100644 index 000000000..dd014f906 --- /dev/null +++ b/tools/test/merger/fixtures/spec/_replaced_operations.yaml @@ -0,0 +1,10 @@ +/replaced/adopting/{a}/something/{b}: + replaced_by: /adopt/{animal}/dockets/{docket} + operations: + - GET + - DELETE +/something/else: + replaced_by: /not/here + operations: + - POST + - PUT \ No newline at end of file diff --git a/tools/test/merger/fixtures/spec/namespaces/shelter.yaml b/tools/test/merger/fixtures/spec/namespaces/shelter.yaml index b91dc827a..0f1a2970b 100644 --- a/tools/test/merger/fixtures/spec/namespaces/shelter.yaml +++ b/tools/test/merger/fixtures/spec/namespaces/shelter.yaml @@ -4,16 +4,20 @@ info: description: OpenSearch API version: 1.0.0 paths: - '/adopt/{animal}': + '/adopt/{animal}/dockets/{docket}': get: + operationId: adopt.0 parameters: - $ref: '#/components/parameters/adopt::path.animal' + - $ref: '#/components/parameters/adopt::path.docket' responses: '200': $ref: '#/components/responses/adopt@200' post: + operationId: adopt.1 parameters: - $ref: '#/components/parameters/adopt::path.animal' + - $ref: '#/components/parameters/adopt::path.docket' requestBody: $ref: '#/components/requestBodies/adopt' responses: @@ -28,6 +32,11 @@ components: in: path schema: $ref: '../schemas/animals.yaml#/components/schemas/Animal' + adopt::path.docket: + name: docket + in: path + schema: + type: number responses: adopt@200: description: '' diff --git a/tools/test/merger/fixtures/spec/opensearch-openapi.yaml b/tools/test/merger/fixtures/spec/opensearch-openapi.yaml index 1e9a06617..b9bdd719d 100644 --- a/tools/test/merger/fixtures/spec/opensearch-openapi.yaml +++ b/tools/test/merger/fixtures/spec/opensearch-openapi.yaml @@ -4,8 +4,8 @@ info: description: OpenSearch API version: 1.0.0 paths: - '/adopt/{animal}': - $ref: 'namespaces/shelter.yaml#/paths/~1adopt~1{animal}' + '/adopt/{animal}/dockets/{docket}': + $ref: 'namespaces/shelter.yaml#/paths/~1adopt~1{animal}~1dockets~1{docket}' components: parameters: _global::query.human: diff --git a/tools/types.ts b/tools/types.ts index dfd485de8..b9a5a4f90 100644 --- a/tools/types.ts +++ b/tools/types.ts @@ -25,4 +25,8 @@ export interface ValidationError { file: string; location?: string; message: string; -} \ No newline at end of file +} + +export type HttpVerb = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' +export type OperationPath = string; +export type ReplacedOperationMap = Record;