From ac8659de90e65433497dc75c66e002d24e1f63e1 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 4 Aug 2024 19:24:45 -0400 Subject: [PATCH] Validate titles and descriptions in info and schema objects. (#463) Signed-off-by: dblock --- CHANGELOG.md | 1 + TESTING_GUIDE.md | 4 +- json_schemas/test_story.schema.yaml | 2 +- package-lock.json | 25 ++++ package.json | 2 + spec/namespaces/_core.yaml | 47 +------- spec/namespaces/cat.yaml | 26 +---- spec/namespaces/cluster.yaml | 35 ++---- spec/namespaces/dangling_indices.yaml | 5 +- spec/namespaces/indices.yaml | 55 +-------- spec/namespaces/ingest.yaml | 7 +- spec/namespaces/knn.yaml | 20 ++-- spec/namespaces/ml.yaml | 2 +- spec/namespaces/nodes.yaml | 9 +- spec/namespaces/notifications.yaml | 11 +- spec/namespaces/ppl.yaml | 2 +- spec/namespaces/remote_store.yaml | 5 +- spec/namespaces/rollups.yaml | 11 +- spec/namespaces/search_pipeline.yaml | 5 +- spec/namespaces/security.yaml | 109 +----------------- spec/namespaces/snapshot.yaml | 13 +-- spec/namespaces/sql.yaml | 2 +- spec/namespaces/tasks.yaml | 5 +- spec/namespaces/transforms.yaml | 7 +- spec/schemas/_common.query_dsl.yaml | 2 +- spec/schemas/_common.yaml | 25 ++-- spec/schemas/indices._common.yaml | 4 +- tools/src/linter/components/Info.ts | 47 ++++++++ tools/src/linter/components/NamespaceFile.ts | 13 +++ tools/src/linter/components/Operation.ts | 4 +- tools/src/linter/components/Schema.ts | 12 +- tools/tests/linter/NamespaceFile.test.ts | 54 ++++++++- tools/tests/linter/Operation.test.ts | 2 +- tools/tests/linter/Schema.test.ts | 8 ++ .../tests/linter/factories/namespace_file.ts | 3 + .../namespaces/invalid_info_capitals.yaml | 4 + .../namespaces/invalid_info_periods.yaml | 4 + .../valid_info_multiline_description.yaml | 6 + .../namespaces/invalid_files/cat.yaml | 4 + .../namespaces/invalid_files/dup_path_a.yaml | 4 + .../namespaces/invalid_files/dup_path_b.yaml | 4 + .../namespaces/invalid_files/dup_path_c.yaml | 4 + .../invalid_files/invalid_spec.yaml | 4 + .../namespaces/invalid_folder/cat.yaml | 4 + .../namespaces/invalid_folder/dup_path_a.yaml | 5 + .../namespaces/invalid_folder/dup_path_b.yaml | 4 + .../namespaces/invalid_folder/dup_path_c.yaml | 4 + .../namespaces/invalid_folder/dup_path_d.yaml | 4 + .../invalid_folder/dup_path_namespace_a.yaml | 1 + .../invalid_folder/dup_path_namespace_b.yaml | 1 + .../namespaces/ops.yaml | 4 + .../namespaces/indices.yaml | 4 + .../anonymous_schemas/namespaces/shelter.yaml | 1 - .../named_schemas/namespaces/shelter.yaml | 1 - .../fixtures/extractor/expected_1.3.yaml | 5 - .../fixtures/extractor/expected_2.0.yaml | 5 - .../merger/fixtures/merger/expected.yaml | 2 - .../fixtures/spec/namespaces/indices.yaml | 1 - .../fixtures/spec/namespaces/shelter.yaml | 1 - .../specs/complete/namespaces/index.yaml | 7 +- .../tests/tester/fixtures/specs/excerpt.yaml | 4 - 61 files changed, 288 insertions(+), 388 deletions(-) create mode 100644 tools/src/linter/components/Info.ts create mode 100644 tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_capitals.yaml create mode 100644 tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_periods.yaml create mode 100644 tools/tests/linter/fixtures/file_validators/namespaces/valid_info_multiline_description.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index dadcbee4..8bb8bbfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `retry` to `tester` to support asynchronous tasks ([453](https://github.com/opensearch-project/opensearch-api-specification/pull/453)) - Added passing OPENSEARCH_JAVA_OPTS into the docker container used for tests ([#454](https://github.com/opensearch-project/opensearch-api-specification/pull/454)) - Added a warning on mulitple paths being tested in the same file ([#452](https://github.com/opensearch-project/opensearch-api-specification/pull/452)) +- Added validation of titles and descriptions in info and schema objects ([#463](https://github.com/opensearch-project/opensearch-api-specification/pull/463)) - Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456)) - Added `/_plugins/_ppl`, `explain` and `stats` ([#460](https://github.com/opensearch-project/opensearch-api-specification/pull/460)) - Added tests against OpenSearch 3.0 ([#459](https://github.com/opensearch-project/opensearch-api-specification/pull/459)) diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index efe86d41..948ce228 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -115,8 +115,8 @@ Consider the following chapters in [ml/model_groups](tests/ml/model_groups.yaml) method: POST request_body: payload: - name: "NLP_Group" - description: "Model group for NLP models" + name: NLP_Group + description: Model group for NLP models. response: status: 200 output: # Save the model group id for later use. diff --git a/json_schemas/test_story.schema.yaml b/json_schemas/test_story.schema.yaml index 74d16fd4..d0b09e5c 100644 --- a/json_schemas/test_story.schema.yaml +++ b/json_schemas/test_story.schema.yaml @@ -94,7 +94,7 @@ definitions: The values are paths to the values in the response. The values should be in the form: - `payload.` for the payload - - `headers.` for the headers + - `headers.` for the headers. type: object additionalProperties: type: string diff --git a/package-lock.json b/package-lock.json index 190f2427..f86e80d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@types/lodash": "^4.14.202", "@types/node": "^20.10.3", "@types/qs": "^6.9.15", + "@types/titlecase": "^1.1.2", "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^6.21.0", "ajv": "^8.13.0", @@ -42,6 +43,7 @@ "lodash": "^4.17.21", "qs": "^6.12.1", "smile-js": "^0.7.0", + "titlecase": "^1.1.3", "tmp": "^0.2.3", "ts-jest": "^29.1.2", "ts-node": "^10.9.1", @@ -2298,6 +2300,11 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" }, + "node_modules/@types/titlecase": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/titlecase/-/titlecase-1.1.2.tgz", + "integrity": "sha512-CnYNirLVqAU9E5cu+Y6VwpzBPnOPEt/wFSfi4pkIHesWZPtZWul9aSuLeNwD7lZfR3kpiKHMcgsVyb2mdXNTvg==" + }, "node_modules/@types/tmp": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.6.tgz", @@ -7691,6 +7698,14 @@ "node": ">=0.12" } }, + "node_modules/titlecase": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/titlecase/-/titlecase-1.1.3.tgz", + "integrity": "sha512-pQX4oiemzjBEELPqgK4WE+q0yhAqjp/yzusGtlSJsOuiDys0RQxggepYmo0BuegIDppYS3b3cpdegRwkpyN3hw==", + "bin": { + "to-title-case": "bin.js" + } + }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", @@ -10045,6 +10060,11 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" }, + "@types/titlecase": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/titlecase/-/titlecase-1.1.2.tgz", + "integrity": "sha512-CnYNirLVqAU9E5cu+Y6VwpzBPnOPEt/wFSfi4pkIHesWZPtZWul9aSuLeNwD7lZfR3kpiKHMcgsVyb2mdXNTvg==" + }, "@types/tmp": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.6.tgz", @@ -13798,6 +13818,11 @@ "next-tick": "^1.1.0" } }, + "titlecase": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/titlecase/-/titlecase-1.1.3.tgz", + "integrity": "sha512-pQX4oiemzjBEELPqgK4WE+q0yhAqjp/yzusGtlSJsOuiDys0RQxggepYmo0BuegIDppYS3b3cpdegRwkpyN3hw==" + }, "tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", diff --git a/package.json b/package.json index b574d42d..04e7116e 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@types/lodash": "^4.14.202", "@types/node": "^20.10.3", "@types/qs": "^6.9.15", + "@types/titlecase": "^1.1.2", "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^6.21.0", "ajv": "^8.13.0", @@ -52,6 +53,7 @@ "lodash": "^4.17.21", "qs": "^6.12.1", "smile-js": "^0.7.0", + "titlecase": "^1.1.3", "tmp": "^0.2.3", "ts-jest": "^29.1.2", "ts-node": "^10.9.1", diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 398fe683..9aa5dbea 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: - title: OpenSearch _core API - description: OpenSearch _core API + title: OpenSearch Core API + description: OpenSearch core API. version: 1.0.0 paths: /: @@ -2613,7 +2613,6 @@ components: description: The search definition using the Query DSL responses: bulk@200: - description: '' content: application/json: schema: @@ -2638,7 +2637,6 @@ components: - items - took clear_scroll@200: - description: '' content: application/json: schema: @@ -2652,7 +2650,6 @@ components: - num_freed - succeeded count@200: - description: '' content: application/json: schema: @@ -2666,13 +2663,11 @@ components: - _shards - count create@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase' create_pit@200: - description: '' content: application/json: schema: @@ -2686,13 +2681,11 @@ components: type: integer format: int64 delete@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase' delete_all_pits@200: - description: '' content: application/json: schema: @@ -2703,7 +2696,6 @@ components: items: $ref: '../schemas/_core._common.yaml#/components/schemas/PitsDetailsDeleteAll' delete_by_query@200: - description: '' content: application/json: schema: @@ -2744,13 +2736,11 @@ components: version_conflicts: type: number delete_by_query_rethrottle@200: - description: '' content: application/json: schema: $ref: '../schemas/tasks._common.yaml#/components/schemas/TaskListResponseBase' delete_pit@200: - description: '' content: application/json: schema: @@ -2761,21 +2751,17 @@ components: items: $ref: '../schemas/_core._common.yaml#/components/schemas/DeletedPit' delete_script@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' exists@200: - description: '' content: application/json: {} exists_source@200: - description: '' content: application/json: {} explain@200: - description: '' content: application/json: schema: @@ -2796,7 +2782,6 @@ components: - _index - matched field_caps@200: - description: '' content: application/json: schema: @@ -2814,13 +2799,11 @@ components: - fields - indices get@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.get.yaml#/components/schemas/GetResult' get_all_pits@200: - description: '' content: application/json: schema: @@ -2831,7 +2814,6 @@ components: items: $ref: '../schemas/_core._common.yaml#/components/schemas/PitDetail' get_script@200: - description: '' content: application/json: schema: @@ -2847,7 +2829,6 @@ components: - _id - found get_script_context@200: - description: '' content: application/json: schema: @@ -2860,7 +2841,6 @@ components: required: - contexts get_script_languages@200: - description: '' content: application/json: schema: @@ -2878,25 +2858,21 @@ components: - language_contexts - types_allowed get_source@200: - description: '' content: application/json: schema: type: object index@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase' index@201: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase' info@200: - description: '' content: application/json: schema: @@ -2919,7 +2895,6 @@ components: - tagline - version mget@200: - description: '' content: application/json: schema: @@ -2932,19 +2907,16 @@ components: required: - docs msearch@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.msearch.yaml#/components/schemas/MultiSearchResult' msearch_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.msearch.yaml#/components/schemas/MultiSearchResult' mtermvectors@200: - description: '' content: application/json: schema: @@ -2957,17 +2929,14 @@ components: required: - docs ping@200: - description: '' content: application/json: {} put_script@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' rank_eval@200: - description: '' content: application/json: schema: @@ -2990,7 +2959,6 @@ components: - failures - metric_score reindex@200: - description: '' content: application/json: schema: @@ -3031,7 +2999,6 @@ components: version_conflicts: type: number reindex_rethrottle@200: - description: '' content: application/json: schema: @@ -3044,7 +3011,6 @@ components: required: - nodes render_search_template@200: - description: '' content: application/json: schema: @@ -3057,7 +3023,6 @@ components: required: - template_output scripts_painless_execute@200: - description: '' content: application/json: schema: @@ -3068,19 +3033,16 @@ components: required: - result scroll@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.search.yaml#/components/schemas/ResponseBody' search@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.search.yaml#/components/schemas/ResponseBody' search_shards@200: - description: '' content: application/json: schema: @@ -3105,7 +3067,6 @@ components: - nodes - shards search_template@200: - description: '' content: application/json: schema: @@ -3153,7 +3114,6 @@ components: - timed_out - took termvectors@200: - description: '' content: application/json: schema: @@ -3180,13 +3140,11 @@ components: - found - took update@200: - description: '' content: application/json: schema: $ref: '../schemas/_core.update.yaml#/components/schemas/UpdateWriteResponseBase' update_by_query@200: - description: '' content: application/json: schema: @@ -3227,7 +3185,6 @@ components: throttled_until_millis: $ref: '../schemas/_common.yaml#/components/schemas/DurationValueUnitMillis' update_by_query_rethrottle@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/cat.yaml b/spec/namespaces/cat.yaml index 76a2d8b8..b2263762 100644 --- a/spec/namespaces/cat.yaml +++ b/spec/namespaces/cat.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Cat API - description: OpenSearch Cat API + description: OpenSearch Cat API. version: 1.0.0 paths: /_cat: @@ -787,7 +787,6 @@ components: - pit_id responses: cat.aliases@200: - description: '' content: text/plain: type: string @@ -797,7 +796,6 @@ components: items: $ref: '../schemas/cat.aliases.yaml#/components/schemas/AliasesRecord' cat.all_pit_segments@200: - description: '' content: text/plain: type: string @@ -807,7 +805,6 @@ components: items: $ref: '../schemas/cat._common.yaml#/components/schemas/CatPitSegmentsRecord' cat.allocation@200: - description: '' content: text/plain: type: string @@ -817,7 +814,6 @@ components: items: $ref: '../schemas/cat.allocation.yaml#/components/schemas/AllocationRecord' cat.cluster_manager@200: - description: '' content: text/plain: type: string @@ -827,7 +823,6 @@ components: items: $ref: '../schemas/cat.cluster_manager.yaml#/components/schemas/ClusterManagerRecord' cat.count@200: - description: '' content: text/plain: type: string @@ -837,7 +832,6 @@ components: items: $ref: '../schemas/cat.count.yaml#/components/schemas/CountRecord' cat.fielddata@200: - description: '' content: text/plain: type: string @@ -847,7 +841,6 @@ components: items: $ref: '../schemas/cat.fielddata.yaml#/components/schemas/FielddataRecord' cat.health@200: - description: '' content: text/plain: type: string @@ -872,13 +865,11 @@ components: items: $ref: '../schemas/cat.health.yaml#/components/schemas/HealthRecord' cat.help@200: - description: '' content: text/plain: schema: type: string cat.indices@200: - description: '' content: text/plain: type: string @@ -903,7 +894,6 @@ components: items: $ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord' cat.master@200: - description: '' content: text/plain: type: string @@ -913,7 +903,6 @@ components: items: $ref: '../schemas/cat.master.yaml#/components/schemas/MasterRecord' cat.nodeattrs@200: - description: '' content: text/plain: type: string @@ -923,7 +912,6 @@ components: items: $ref: '../schemas/cat.nodeattrs.yaml#/components/schemas/NodeAttributesRecord' cat.nodes@200: - description: '' content: text/plain: type: string @@ -933,7 +921,6 @@ components: items: $ref: '../schemas/cat.nodes.yaml#/components/schemas/NodesRecord' cat.pending_tasks@200: - description: '' content: text/plain: type: string @@ -943,7 +930,6 @@ components: items: $ref: '../schemas/cat.pending_tasks.yaml#/components/schemas/PendingTasksRecord' cat.pit_segments@200: - description: '' content: text/plain: type: string @@ -953,7 +939,6 @@ components: items: $ref: '../schemas/cat._common.yaml#/components/schemas/CatPitSegmentsRecord' cat.plugins@200: - description: '' content: text/plain: type: string @@ -963,7 +948,6 @@ components: items: $ref: '../schemas/cat.plugins.yaml#/components/schemas/PluginsRecord' cat.recovery@200: - description: '' content: text/plain: type: string @@ -973,7 +957,6 @@ components: items: $ref: '../schemas/cat.recovery.yaml#/components/schemas/RecoveryRecord' cat.repositories@200: - description: '' content: text/plain: type: string @@ -983,7 +966,6 @@ components: items: $ref: '../schemas/cat.repositories.yaml#/components/schemas/RepositoriesRecord' cat.segment_replication@200: - description: '' content: text/plain: type: string @@ -993,7 +975,6 @@ components: items: $ref: '../schemas/cat._common.yaml#/components/schemas/CatSegmentReplicationRecord' cat.segments@200: - description: '' content: text/plain: type: string @@ -1003,7 +984,6 @@ components: items: $ref: '../schemas/cat.segments.yaml#/components/schemas/SegmentsRecord' cat.shards@200: - description: '' content: text/plain: type: string @@ -1013,7 +993,6 @@ components: items: $ref: '../schemas/cat.shards.yaml#/components/schemas/ShardsRecord' cat.snapshots@200: - description: '' content: text/plain: type: string @@ -1023,7 +1002,6 @@ components: items: $ref: '../schemas/cat.snapshots.yaml#/components/schemas/SnapshotsRecord' cat.tasks@200: - description: '' content: text/plain: type: string @@ -1033,7 +1011,6 @@ components: items: $ref: '../schemas/cat.tasks.yaml#/components/schemas/TasksRecord' cat.templates@200: - description: '' content: text/plain: type: string @@ -1043,7 +1020,6 @@ components: items: $ref: '../schemas/cat.templates.yaml#/components/schemas/TemplatesRecord' cat.thread_pool@200: - description: '' content: text/plain: type: string diff --git a/spec/namespaces/cluster.yaml b/spec/namespaces/cluster.yaml index d0b8c5fd..c503c375 100644 --- a/spec/namespaces/cluster.yaml +++ b/spec/namespaces/cluster.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Cluster API - description: OpenSearch Cluster API + description: OpenSearch Cluster API. version: 1.0.0 paths: /_cluster/allocation/explain: @@ -534,7 +534,6 @@ components: description: The definition of `commands` to perform (`move`, `cancel`, `allocate`) responses: cluster.allocation_explain@200: - description: '' content: application/json: schema: @@ -602,25 +601,19 @@ components: - primary - shard cluster.delete_component_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' - cluster.delete_decommission_awareness@200: - description: '' + cluster.delete_decommission_awareness@200: {} cluster.delete_voting_config_exclusions@200: - description: '' content: application/json: {} - cluster.delete_weighted_routing@200: - description: '' + cluster.delete_weighted_routing@200: {} cluster.exists_component_template@200: - description: '' content: application/json: {} cluster.get_component_template@200: - description: '' content: application/json: schema: @@ -632,10 +625,8 @@ components: $ref: '../schemas/cluster._common.yaml#/components/schemas/ComponentTemplate' required: - component_templates - cluster.get_decommission_awareness@200: - description: '' + cluster.get_decommission_awareness@200: {} cluster.get_settings@200: - description: '' content: application/json: schema: @@ -656,16 +647,13 @@ components: required: - persistent - transient - cluster.get_weighted_routing@200: - description: '' + cluster.get_weighted_routing@200: {} cluster.health@200: - description: '' content: application/json: schema: $ref: '../schemas/cluster.health.yaml#/components/schemas/HealthResponseBody' cluster.pending_tasks@200: - description: '' content: application/json: schema: @@ -678,19 +666,15 @@ components: required: - tasks cluster.post_voting_config_exclusions@200: - description: '' content: application/json: {} cluster.put_component_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' - cluster.put_decommission_awareness@200: - description: '' + cluster.put_decommission_awareness@200: {} cluster.put_settings@200: - description: '' content: application/json: schema: @@ -708,10 +692,8 @@ components: - acknowledged - persistent - transient - cluster.put_weighted_routing@200: - description: '' + cluster.put_weighted_routing@200: {} cluster.remote_info@200: - description: '' content: application/json: schema: @@ -719,7 +701,6 @@ components: additionalProperties: $ref: '../schemas/cluster.remote_info.yaml#/components/schemas/ClusterRemoteInfo' cluster.reroute@200: - description: '' content: application/json: schema: @@ -740,13 +721,11 @@ components: required: - acknowledged cluster.state@200: - description: '' content: application/json: schema: type: object cluster.stats@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/dangling_indices.yaml b/spec/namespaces/dangling_indices.yaml index 341757ad..73b8763c 100644 --- a/spec/namespaces/dangling_indices.yaml +++ b/spec/namespaces/dangling_indices.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Dangling_indices API - description: OpenSearch Dangling_indices API + description: OpenSearch Dangling_indices API. version: 1.0.0 paths: /_dangling: @@ -53,19 +53,16 @@ components: requestBodies: {} responses: dangling_indices.delete_dangling_index@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' dangling_indices.import_dangling_index@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' dangling_indices.list_dangling_indices@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/indices.yaml b/spec/namespaces/indices.yaml index 3eca3225..6d36982f 100644 --- a/spec/namespaces/indices.yaml +++ b/spec/namespaces/indices.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Indices API - description: OpenSearch Indices API + description: OpenSearch Indices API. version: 1.0.0 paths: /_alias: @@ -2249,7 +2249,6 @@ components: description: The query definition specified with the Query DSL responses: indices.add_block@200: - description: '' content: application/json: schema: @@ -2268,7 +2267,6 @@ components: - indices - shards_acknowledged indices.analyze@200: - description: '' content: application/json: schema: @@ -2281,13 +2279,11 @@ components: items: $ref: '../schemas/indices.analyze.yaml#/components/schemas/AnalyzeToken' indices.clear_cache@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/ShardsOperationResponseBase' indices.clone@200: - description: '' content: application/json: schema: @@ -2304,7 +2300,6 @@ components: - index - shards_acknowledged indices.close@200: - description: '' content: application/json: schema: @@ -2323,7 +2318,6 @@ components: - indices - shards_acknowledged indices.create@200: - description: '' content: application/json: schema: @@ -2340,13 +2334,11 @@ components: - index - shards_acknowledged indices.create_data_stream@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.data_streams_stats@200: - description: '' content: application/json: schema: @@ -2377,63 +2369,51 @@ components: - data_streams - total_store_size_bytes indices.delete@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndicesResponseBase' indices.delete_alias@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.delete_data_stream@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.delete_index_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.delete_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.exists@200: - description: '' content: application/json: {} indices.exists@404: - description: '' content: application/json: {} indices.exists_alias@200: - description: '' content: application/json: {} indices.exists_index_template@200: - description: '' content: application/json: {} indices.exists_template@200: - description: '' content: application/json: {} indices.flush@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/ShardsOperationResponseBase' indices.forcemerge@200: - description: '' content: application/json: schema: @@ -2447,7 +2427,6 @@ components: you can use the task_id to get the status of the task at _tasks/ type: string indices.get@200: - description: '' content: application/json: schema: @@ -2455,7 +2434,6 @@ components: additionalProperties: $ref: '../schemas/indices._common.yaml#/components/schemas/IndexState' indices.get_alias@200: - description: '' content: application/json: schema: @@ -2463,7 +2441,6 @@ components: additionalProperties: $ref: '../schemas/indices.get_alias.yaml#/components/schemas/IndexAliases' indices.get_data_stream@200: - description: '' content: application/json: schema: @@ -2476,7 +2453,6 @@ components: required: - data_streams indices.get_field_mapping@200: - description: '' content: application/json: schema: @@ -2484,7 +2460,6 @@ components: additionalProperties: $ref: '../schemas/indices.get_field_mapping.yaml#/components/schemas/TypeFieldMappings' indices.get_index_template@200: - description: '' content: application/json: schema: @@ -2497,7 +2472,6 @@ components: required: - index_templates indices.get_mapping@200: - description: '' content: application/json: schema: @@ -2505,7 +2479,6 @@ components: additionalProperties: $ref: '../schemas/indices.get_mapping.yaml#/components/schemas/IndexMappingRecord' indices.get_settings@200: - description: '' content: application/json: schema: @@ -2513,17 +2486,14 @@ components: additionalProperties: $ref: '../schemas/indices._common.yaml#/components/schemas/IndexState' indices.get_template@200: - description: '' content: application/json: schema: type: object additionalProperties: $ref: '../schemas/indices._common.yaml#/components/schemas/TemplateMapping' - indices.get_upgrade@200: - description: '' + indices.get_upgrade@200: {} indices.open@200: - description: '' content: application/json: schema: @@ -2544,37 +2514,31 @@ components: - shards_acknowledged additionalProperties: false indices.put_alias@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.put_index_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.put_mapping@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndicesResponseBase' indices.put_settings@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.put_template@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' indices.recovery@200: - description: '' content: application/json: schema: @@ -2582,13 +2546,11 @@ components: additionalProperties: $ref: '../schemas/indices.recovery.yaml#/components/schemas/RecoveryStatus' indices.refresh@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/ShardsOperationResponseBase' indices.resolve_index@200: - description: '' content: application/json: schema: @@ -2611,7 +2573,6 @@ components: - data_streams - indices indices.rollover@200: - description: '' content: application/json: schema: @@ -2642,7 +2603,6 @@ components: - rolled_over - shards_acknowledged indices.segments@200: - description: '' content: application/json: schema: @@ -2658,7 +2618,6 @@ components: - _shards - indices indices.shard_stores@200: - description: '' content: application/json: schema: @@ -2671,7 +2630,6 @@ components: required: - indices indices.shrink@200: - description: '' content: application/json: schema: @@ -2688,13 +2646,11 @@ components: - index - shards_acknowledged indices.simulate_index_template@200: - description: '' content: application/json: schema: type: object indices.simulate_template@200: - description: '' content: application/json: schema: @@ -2709,7 +2665,6 @@ components: required: - template indices.split@200: - description: '' content: application/json: schema: @@ -2726,7 +2681,6 @@ components: - index - shards_acknowledged indices.stats@200: - description: '' content: application/json: schema: @@ -2744,15 +2698,12 @@ components: - _all - _shards indices.update_aliases@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' - indices.upgrade@200: - description: '' + indices.upgrade@200: {} indices.validate_query@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/ingest.yaml b/spec/namespaces/ingest.yaml index fa21ca56..787d1d50 100644 --- a/spec/namespaces/ingest.yaml +++ b/spec/namespaces/ingest.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Ingest API - description: OpenSearch Ingest API + description: OpenSearch Ingest API. version: 1.0.0 paths: /_ingest/pipeline: @@ -181,13 +181,11 @@ components: required: true responses: ingest.delete_pipeline@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' ingest.get_pipeline@200: - description: '' content: application/json: schema: @@ -195,7 +193,6 @@ components: additionalProperties: $ref: '../schemas/ingest._common.yaml#/components/schemas/Pipeline' ingest.processor_grok@200: - description: '' content: application/json: schema: @@ -208,13 +205,11 @@ components: required: - patterns ingest.put_pipeline@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' ingest.simulate@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/knn.yaml b/spec/namespaces/knn.yaml index 0ef35ae6..d960f34a 100644 --- a/spec/namespaces/knn.yaml +++ b/spec/namespaces/knn.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Knn API - description: OpenSearch Knn API + description: OpenSearch Knn API. version: 1.0.0 paths: /_plugins/_knn/models/_search: @@ -277,18 +277,12 @@ components: - training_index required: true responses: - knn.delete_model@200: - description: '' - knn.get_model@200: - description: '' - knn.search_models@200: - description: '' - knn.stats@200: - description: '' - knn.train_model@200: - description: '' - knn.warmup@200: - description: '' + knn.delete_model@200: {} + knn.get_model@200: {} + knn.search_models@200: {} + knn.stats@200: {} + knn.train_model@200: {} + knn.warmup@200: {} parameters: knn.delete_model::path.model_id: name: model_id diff --git a/spec/namespaces/ml.yaml b/spec/namespaces/ml.yaml index c6060585..54b5ea53 100644 --- a/spec/namespaces/ml.yaml +++ b/spec/namespaces/ml.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch ML API - description: OpenSearch ML API + description: OpenSearch ML API. version: 1.0.0 paths: /_plugins/_ml/model_groups/_register: diff --git a/spec/namespaces/nodes.yaml b/spec/namespaces/nodes.yaml index e99653b1..e8c919eb 100644 --- a/spec/namespaces/nodes.yaml +++ b/spec/namespaces/nodes.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Nodes API - description: OpenSearch Nodes API + description: OpenSearch Nodes API. version: 1.0.0 paths: /_cluster/nodes/hot_threads: @@ -449,28 +449,23 @@ components: $ref: '../schemas/_common.yaml#/components/schemas/Password' description: An object containing the password for the opensearch keystore responses: - nodes.hot_threads@200: - description: '' + nodes.hot_threads@200: {} nodes.info@200: - description: '' content: application/json: schema: $ref: '../schemas/nodes.info.yaml#/components/schemas/ResponseBase' nodes.reload_secure_settings@200: - description: '' content: application/json: schema: $ref: '../schemas/nodes.reload_secure_settings.yaml#/components/schemas/ResponseBase' nodes.stats@200: - description: '' content: application/json: schema: $ref: '../schemas/nodes.stats.yaml#/components/schemas/ResponseBase' nodes.usage@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/notifications.yaml b/spec/namespaces/notifications.yaml index edb7ef07..00faf394 100644 --- a/spec/namespaces/notifications.yaml +++ b/spec/namespaces/notifications.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Notifications API - description: OpenSearch Notifications API + description: OpenSearch Notifications API. version: 1.0.0 paths: /_plugins/_notifications/channels: @@ -204,7 +204,6 @@ components: required: true responses: notifications.create_config@200: - description: '' content: application/json: schema: @@ -213,31 +212,26 @@ components: config_id: type: string notifications.delete_config@200: - description: '' content: application/json: schema: $ref: '../schemas/notifications._common.yaml#/components/schemas/DeleteConfigsResponse' notifications.delete_configs@200: - description: '' content: application/json: schema: $ref: '../schemas/notifications._common.yaml#/components/schemas/DeleteConfigsResponse' notifications.get_config@200: - description: '' content: application/json: schema: $ref: '../schemas/notifications._common.yaml#/components/schemas/GetConfigsResponse' notifications.get_configs@200: - description: '' content: application/json: schema: $ref: '../schemas/notifications._common.yaml#/components/schemas/GetConfigsResponse' notifications.list_channels@200: - description: '' content: application/json: schema: @@ -256,7 +250,6 @@ components: items: $ref: '../schemas/notifications._common.yaml#/components/schemas/NotificationChannel' notifications.list_features@200: - description: '' content: application/json: schema: @@ -269,7 +262,6 @@ components: plugin_features: $ref: '../schemas/notifications._common.yaml#/components/schemas/NotificationsPluginFeaturesMap' notifications.send_test@200: - description: '' content: application/json: schema: @@ -282,7 +274,6 @@ components: items: $ref: '../schemas/notifications._common.yaml#/components/schemas/EventStatus' notifications.update_config@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/ppl.yaml b/spec/namespaces/ppl.yaml index 7515cea9..0794fd32 100644 --- a/spec/namespaces/ppl.yaml +++ b/spec/namespaces/ppl.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch PPL API - description: OpenSearch PPL API + description: OpenSearch PPL API. version: 1.0.0 paths: /_plugins/_ppl: diff --git a/spec/namespaces/remote_store.yaml b/spec/namespaces/remote_store.yaml index a1f1ffb2..4202d5cd 100644 --- a/spec/namespaces/remote_store.yaml +++ b/spec/namespaces/remote_store.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Remote_store API - description: OpenSearch Remote_store API + description: OpenSearch Remote_store API. version: 1.0.0 paths: /_remotestore/_restore: @@ -38,14 +38,12 @@ components: examples: RemoteStoreRestore_example1: summary: Examples for Post Remote Storage Restore Operation. - description: '' value: indices: - books required: true responses: remote_store.restore@200: - description: '' content: application/json: schema: @@ -58,7 +56,6 @@ components: examples: RemoteStoreRestore_example1: summary: Examples for Post Remote Storage Restore Operation. - description: '' value: remote_store: indices: diff --git a/spec/namespaces/rollups.yaml b/spec/namespaces/rollups.yaml index a737139e..e5e56a68 100644 --- a/spec/namespaces/rollups.yaml +++ b/spec/namespaces/rollups.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Index Rollups API - description: OpenSearch Index Rollups API + description: OpenSearch Index Rollups API. version: 1.0.0 paths: /_plugins/_rollup/jobs/{id}: @@ -102,12 +102,9 @@ components: application/json: schema: $ref: '../schemas/rollups._common.yaml#/components/schemas/RollupEntity' - rollups.delete@200: - description: '' - rollups.start@200: - description: '' - rollups.stop@200: - description: '' + rollups.delete@200: {} + rollups.start@200: {} + rollups.stop@200: {} rollups.explain@200: content: application/json: diff --git a/spec/namespaces/search_pipeline.yaml b/spec/namespaces/search_pipeline.yaml index 3ce4c5d8..05d16fbd 100644 --- a/spec/namespaces/search_pipeline.yaml +++ b/spec/namespaces/search_pipeline.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Search_pipeline API - description: OpenSearch Search_pipeline API + description: OpenSearch Search_pipeline API. version: 1.0.0 paths: /_search/pipeline: @@ -65,7 +65,6 @@ components: required: true responses: search_pipeline.put@200: - description: '' content: application/json: schema: @@ -74,7 +73,6 @@ components: acknowledged: type: boolean search_pipeline.delete@200: - description: '' content: application/json: schema: @@ -83,7 +81,6 @@ components: acknowledged: type: boolean search_pipeline.get@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/security.yaml b/spec/namespaces/security.yaml index 234ab6fc..f41647f5 100644 --- a/spec/namespaces/security.yaml +++ b/spec/namespaces/security.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Security API - description: OpenSearch Security API + description: OpenSearch Security API. version: 1.0.0 paths: /_opendistro/_security/sslinfo: @@ -1228,259 +1228,216 @@ components: $ref: '../schemas/security._common.yaml#/components/schemas/PatchOperation' responses: security.authinfo@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AuthInfo' security.authinfo@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.authtoken@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.cache@501: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/MethodNotImplemented' security.change_password@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.config_upgrade_check@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UpgradeCheck' security.config_upgrade_perform@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UpgradePerform' security.create_action_group@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.create_allowlist@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig' security.create_role@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.create_role_mapping@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.create_tenant@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.create_tenant@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.create_update_tenancy_config@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/MultiTenancyConfig' security.create_update_tenancy_config@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.create_user@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.create_user_legacy@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_action_group@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_distinguished_name@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_distinguished_name@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.delete_role@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_role_mapping@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_tenant@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_tenant@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.delete_user@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.delete_user_legacy@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.flush_cache@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.generate_obo_token@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/GenerateOBOToken' security.generate_obo_token@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.generate_user_token@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.generate_user_token@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.generate_user_token_legacy@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.generate_user_token_legacy@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.get_account_details@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AccountDetails' security.get_action_group@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/ActionGroupsMap' security.get_action_groups@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/ActionGroupsMap' security.get_allowlist@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig' security.get_audit_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AuditConfigWithReadOnly' security.get_certificates@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/GetCertificates' security.get_certificates@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.get_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/DynamicConfig' security.get_dashboards_info@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/DashboardsInfo' security.get_dashboards_info@500: - description: '' content: application/json: schema: @@ -1492,385 +1449,321 @@ components: schema: $ref: '../schemas/security._common.yaml#/components/schemas/DistinguishedNames' security.get_distinguished_name@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.get_distinguished_names@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/DistinguishedNamesMap' security.get_distinguished_names@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.get_permissions_info@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/PermissionsInfo' security.get_permissions_info@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.get_role@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/RolesMap' security.get_role_mapping@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/RoleMappings' security.get_role_mappings@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/RoleMappings' security.get_roles@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/RolesMap' security.get_sslinfo@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/SSLInfo' security.get_sslinfo@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.get_tenant@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/TenantsMap' security.get_tenancy_config@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/MultiTenancyConfig' security.get_tenancy_config@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.get_tenants@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/TenantsMap' security.get_tenants@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.get_user@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UsersMap' security.get_user_legacy@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UsersMap' security.get_users@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UsersMap' security.get_users_legacy@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/UsersMap' security.health@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/HealthInfo' security.migrate@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.migrate@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_action_group@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_action_groups@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_allowlist@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig' security.patch_audit_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_distinguished_name@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_distinguished_name@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.patch_distinguished_names@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_distinguished_names@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.patch_role@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_role@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_role_mapping@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_role_mapping@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_role_mappings@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_role_mappings@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_roles@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_roles@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_tenant@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_tenant@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_tenants@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_tenants@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.patch_user@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.patch_users@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.post_dashboards_info@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/DashboardsInfo' security.post_dashboards_info@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.reload_http_certificates@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.reload_http_certificates@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.reload_transport_certificates@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.reload_transport_certificates@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.tenant_info@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/TenantInfo' security.tenant_info@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.update_audit_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.update_configuration@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.update_distinguished_name@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.update_distinguished_name@403: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Unauthorized' security.validate@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/Ok' security.validate@400: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/BadRequest' security.who_am_i@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/WhoAmI' security.who_am_i@500: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/InternalServerError' security.who_am_i_protected@200: - description: '' content: application/json: schema: $ref: '../schemas/security._common.yaml#/components/schemas/WhoAmI' security.who_am_i_protected@500: - description: '' content: application/json: schema: diff --git a/spec/namespaces/snapshot.yaml b/spec/namespaces/snapshot.yaml index 3847af1d..9f6c88c0 100644 --- a/spec/namespaces/snapshot.yaml +++ b/spec/namespaces/snapshot.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Snapshot API - description: OpenSearch Snapshot API + description: OpenSearch Snapshot API. version: 1.0.0 paths: /_snapshot: @@ -362,7 +362,6 @@ components: description: Details of what to restore responses: snapshot.cleanup_repository@200: - description: '' content: application/json: schema: @@ -373,13 +372,11 @@ components: required: - results snapshot.clone@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' snapshot.create@200: - description: '' content: application/json: schema: @@ -391,25 +388,21 @@ components: snapshot: $ref: '../schemas/snapshot._common.yaml#/components/schemas/SnapshotInfo' snapshot.create_repository@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' snapshot.delete@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' snapshot.delete_repository@200: - description: '' content: application/json: schema: $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' snapshot.get@200: - description: '' content: application/json: schema: @@ -433,7 +426,6 @@ components: - remaining - total snapshot.get_repository@200: - description: '' content: application/json: schema: @@ -441,7 +433,6 @@ components: additionalProperties: $ref: '../schemas/snapshot._common.yaml#/components/schemas/Repository' snapshot.restore@200: - description: '' content: application/json: schema: @@ -452,7 +443,6 @@ components: required: - snapshot snapshot.status@200: - description: '' content: application/json: schema: @@ -465,7 +455,6 @@ components: required: - snapshots snapshot.verify_repository@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 7de1b1c2..a54c6cc3 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch SQL API - description: OpenSearch SQL API + description: OpenSearch SQL API. version: 1.0.0 paths: /_plugins/_query/settings: diff --git a/spec/namespaces/tasks.yaml b/spec/namespaces/tasks.yaml index 9f5bf8dc..013155f8 100644 --- a/spec/namespaces/tasks.yaml +++ b/spec/namespaces/tasks.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Tasks API - description: OpenSearch Tasks API + description: OpenSearch Tasks API. version: 1.0.0 paths: /_tasks: @@ -75,13 +75,11 @@ components: requestBodies: {} responses: tasks.cancel@200: - description: '' content: application/json: schema: $ref: '../schemas/tasks._common.yaml#/components/schemas/TaskListResponseBase' tasks.get@200: - description: '' content: application/json: schema: @@ -99,7 +97,6 @@ components: - completed - task tasks.list@200: - description: '' content: application/json: schema: diff --git a/spec/namespaces/transforms.yaml b/spec/namespaces/transforms.yaml index 336cd18a..b525f101 100644 --- a/spec/namespaces/transforms.yaml +++ b/spec/namespaces/transforms.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Index Transforms API - description: OpenSearch Index Transforms API + description: OpenSearch Index Transforms API. version: 1.0.0 paths: /_plugins/_transform: @@ -80,7 +80,7 @@ paths: operationId: transforms.stop.0 x-operation-group: transforms.stop x-version-added: '1.0' - description: stop transform. + description: Stop transform. externalDocs: url: https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#stop-a-transform-job parameters: @@ -135,8 +135,7 @@ components: application/json: schema: $ref: '../schemas/transforms._common.yaml#/components/schemas/TransformEntity' - transforms.delete@200: - description: '' + transforms.delete@200: {} transforms.start@200: content: application/json: diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index 414272b8..a0d547cd 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -1637,7 +1637,7 @@ components: required: - query SimpleQueryStringFlags: - description: Query flags can be either a single flag or a combination of flags, e.g. `OR|AND|PREFIX` + description: Query flags can be either a single flag or a combination of flags, e.g. `OR|AND|PREFIX`. allOf: - $ref: '_common.yaml#/components/schemas/PipeSeparatedFlagsSimpleQueryStringFlag' SimpleQueryStringFlag: diff --git a/spec/schemas/_common.yaml b/spec/schemas/_common.yaml index 81c69f23..afb4b6d1 100644 --- a/spec/schemas/_common.yaml +++ b/spec/schemas/_common.yaml @@ -49,7 +49,7 @@ components: - as 4 top/bottom/left/right coordinates - as 2 top_left / bottom_right points - as 2 top_right / bottom_left points - - as a WKT bounding box + - as a WKT bounding box. oneOf: - $ref: '#/components/schemas/CoordsGeoBounds' - $ref: '#/components/schemas/TopLeftBottomRightGeoBounds' @@ -87,7 +87,7 @@ components: - as a `{lat, long}` object - as a geo hash value - as a `[lon, lat]` array - - as a string in `", "` or WKT point formats + - as a string in `", "` or WKT point formats. oneOf: - $ref: '#/components/schemas/LatLonGeoLocation' - $ref: '#/components/schemas/GeoHashLocation' @@ -137,12 +137,11 @@ components: allOf: - $ref: '#/components/schemas/UnitMillis' UnitMillis: - description: Time unit for milliseconds + description: Time unit for milliseconds. type: number DurationLarge: description: |- - A date histogram interval. Similar to `Duration` with additional units: `w` (week), `M` (month), `q` (quarter) and - `y` (year) + A date histogram interval. Similar to `Duration` with additional units: `w` (week), `M` (month), `q` (quarter) and `y` (year). type: string FieldValue: description: A field value. @@ -159,13 +158,13 @@ components: Although "void" is generally used for the unit type that has only one value, this is to be interpreted as the bottom type that has no value at all. Most languages have a unit type, but few have a bottom type. - See https://en.m.wikipedia.org/wiki/Unit_type and https://en.m.wikipedia.org/wiki/Bottom_type + See https://en.m.wikipedia.org/wiki/Unit_type and https://en.m.wikipedia.org/wiki/Bottom_type. type: object GeoTile: - description: A map tile reference, represented as `{zoom}/{x}/{y}` + description: A map tile reference, represented as `{zoom}/{x}/{y}`. type: string GeoHexCell: - description: A map hex cell (H3) reference + description: A map hex cell (H3) reference. type: string IndexName: type: string @@ -319,7 +318,7 @@ components: allOf: - $ref: '#/components/schemas/UnitNanos' UnitNanos: - description: Time unit for nanoseconds + description: Time unit for nanoseconds. type: number ScrollId: type: string @@ -373,7 +372,7 @@ components: - missing - popular MinimumShouldMatch: - description: The minimum number of terms that should match as integer, percentage or range + description: The minimum number of terms that should match as integer, percentage or range. oneOf: - type: number - type: string @@ -742,10 +741,10 @@ components: allOf: - $ref: '#/components/schemas/UnitSeconds' UnitSeconds: - description: Time unit for seconds + description: Time unit for seconds. type: number TimeOfDay: - description: Time of day, expressed as HH:MM:SS + description: Time of day, expressed as HH:MM:SS. type: string TimeUnit: type: string @@ -1907,7 +1906,7 @@ components: - name - transport_address NodeRoles: - description: '* @doc_id node-roles' + description: Node roles. type: array items: $ref: '#/components/schemas/NodeRole' diff --git a/spec/schemas/indices._common.yaml b/spec/schemas/indices._common.yaml index 8cf004a9..fce77a57 100644 --- a/spec/schemas/indices._common.yaml +++ b/spec/schemas/indices._common.yaml @@ -8,6 +8,7 @@ components: schemas: IndexSettings: type: object + description: The index settings to be updated. properties: index: $ref: '#/components/schemas/IndexSettings' @@ -138,7 +139,6 @@ components: store: $ref: '#/components/schemas/Storage' additionalProperties: {} - description: The index settings to be updated SoftDeletes: type: object properties: @@ -953,7 +953,7 @@ components: $ref: '#/components/schemas/IndexTemplateDataStreamConfiguration' required: - index_patterns - description: New index template definition to be simulated, if no index template name is specified + description: New index template definition to be simulated, if no index template name is specified. IndexTemplateSummary: type: object properties: diff --git a/tools/src/linter/components/Info.ts b/tools/src/linter/components/Info.ts new file mode 100644 index 00000000..0ec39bec --- /dev/null +++ b/tools/src/linter/components/Info.ts @@ -0,0 +1,47 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import { type OpenAPIV3 } from 'openapi-types' +import { type ValidationError } from 'types' +import ValidatorBase from './base/ValidatorBase' +import { toLaxTitleCase } from 'titlecase' + +const DESCRIPTION_REGEX = /^\p{Lu}[\s\S]*\.$/u + +export default class Info extends ValidatorBase { + path: string + spec: OpenAPIV3.InfoObject + + constructor (file: string, path: string, spec: OpenAPIV3.InfoObject) { + super(file, 'Info') + this.path = path + this.spec = spec + } + + validate (): ValidationError[] { + return [ + this.validate_title(), + this.validate_description() + ].filter((e) => e) as ValidationError[] + } + + validate_description (): ValidationError | undefined { + const description = this.spec?.description ?? '' + if (description === '') { return this.error('Missing description property.') } + if (!DESCRIPTION_REGEX.test(description)) { return this.error('Description must start with a capital letter and end with a period.') } + } + + validate_title (): ValidationError | undefined { + const title = this.spec?.title ?? '' + if (title === '') { return this.error('Missing title property.') } + const expected_title = toLaxTitleCase(title) + if (title.endsWith('.')) { return this.error('Title must not end with a period.') } + if (title !== expected_title) return this.error(`Title must be capitalized, expected '${expected_title}'.`) + } +} diff --git a/tools/src/linter/components/NamespaceFile.ts b/tools/src/linter/components/NamespaceFile.ts index fdfb2d0e..7b738e16 100644 --- a/tools/src/linter/components/NamespaceFile.ts +++ b/tools/src/linter/components/NamespaceFile.ts @@ -14,12 +14,14 @@ import _ from 'lodash' import Operation from './Operation' import { resolve_ref, sort_by_keys } from '../../helpers' import FileValidator from './base/FileValidator' +import Info from './Info' const HTTP_METHODS = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'] const NAME_REGEX = /^[a-z]+[a-z_]*[a-z]+$/ export default class NamespaceFile extends FileValidator { namespace: string + private _info: Info | undefined private _operation_groups: OperationGroup[] | undefined private _refs: Set | undefined @@ -36,6 +38,7 @@ export default class NamespaceFile extends FileValidator { return [ this.validate_schemas(), + ...this.validate_info(), ...this.validate_unresolved_refs(), ...this.validate_unused_refs(), ...this.validate_parameter_refs(), @@ -43,6 +46,12 @@ export default class NamespaceFile extends FileValidator { ].filter((e) => e) as ValidationError[] } + info (): Info { + if (this._info) return this._info + this._info = new Info(this.file, this.file_path, this.spec().info) + return this._info + } + operation_groups (): OperationGroup[] { if (this._operation_groups) return this._operation_groups const ops: Operation[] = _.entries(this.spec().paths).flatMap(([path, ops]) => { @@ -78,6 +87,10 @@ export default class NamespaceFile extends FileValidator { if (this.spec().components?.schemas) { return this.error('components/schemas is not allowed in namespace files', '#/components/schemas') } } + validate_info(): ValidationError[] { + return this.info().validate() + } + validate_unresolved_refs (): ValidationError[] { return Array.from(this.refs()).map((ref) => { if (resolve_ref(ref, this.spec()) === undefined) return this.error(`Unresolved reference: ${ref}`, ref) diff --git a/tools/src/linter/components/Operation.ts b/tools/src/linter/components/Operation.ts index 742b0208..bb06233a 100644 --- a/tools/src/linter/components/Operation.ts +++ b/tools/src/linter/components/Operation.ts @@ -12,6 +12,8 @@ import _ from 'lodash' import ValidatorBase from './base/ValidatorBase' const GROUP_REGEX = /^([a-z]+[a-z_]*[a-z]+\.)?([a-z]+[a-z_]*[a-z]+)$/ +const DESCRIPTION_REGEX = /^\p{Lu}[\s\S]*\.$/u + export default class Operation extends ValidatorBase { path: string verb: string @@ -65,7 +67,7 @@ export default class Operation extends ValidatorBase { validate_description (): ValidationError | undefined { const description = this.spec.description ?? '' if (description === '') { return this.error('Missing description property.') } - if (!description.endsWith('.')) { return this.error('Description must end with a period.') } + if (!DESCRIPTION_REGEX.test(description)) return this.error('Description must start with a capital letter and end with a period.') } validate_operation_id (): ValidationError | undefined { diff --git a/tools/src/linter/components/Schema.ts b/tools/src/linter/components/Schema.ts index 9178950a..a84438f9 100644 --- a/tools/src/linter/components/Schema.ts +++ b/tools/src/linter/components/Schema.ts @@ -12,6 +12,7 @@ import { type OpenAPIV3 } from 'openapi-types' import { type ValidationError } from 'types' const NAME_REGEX = /^[A-Za-z0-9]+$/ +const DESCRIPTION_REGEX = /^\p{Lu}[\s\S]*\.$/u export default class Schema extends ValidatorBase { name: string @@ -24,10 +25,19 @@ export default class Schema extends ValidatorBase { } validate (): ValidationError[] { - return [this.validate_name()].filter(e => e) as ValidationError[] + return [ + this.validate_name(), + this.validate_description() + ].filter(e => e) as ValidationError[] } validate_name (): ValidationError | undefined { if (!NAME_REGEX.test(this.name)) { return this.error(`Invalid schema name '${this.name}'. Only alphanumeric characters are allowed.`) } } + + validate_description (): ValidationError | undefined { + const description = this.spec.description ?? '' + if (description === '') return + if (!DESCRIPTION_REGEX.test(description)) { return this.error('Description must start with a capital letter and end with a period.') } + } } diff --git a/tools/tests/linter/NamespaceFile.test.ts b/tools/tests/linter/NamespaceFile.test.ts index 6e5ff9eb..88cb22c9 100644 --- a/tools/tests/linter/NamespaceFile.test.ts +++ b/tools/tests/linter/NamespaceFile.test.ts @@ -99,23 +99,69 @@ test('validate_order_of_operations()', () => { ]) }) +test('validate_info() periods', () => { + const validator = namespace_file('invalid_info_periods.yaml') + expect(validator.info().validate()).toEqual([ + { + file: 'namespaces/invalid_info_periods.yaml', + location: 'Info', + message: 'Title must not end with a period.' + }, + { + file: 'namespaces/invalid_info_periods.yaml', + location: 'Info', + message: 'Description must start with a capital letter and end with a period.' + } + ]) +}) + +test('validate_info() multiline', () => { + const validator = namespace_file('valid_info_multiline_description.yaml') + expect(validator.info().validate()).toEqual([]) +}) + +test('validate_info() capitals', () => { + const validator = namespace_file('invalid_info_capitals.yaml') + expect(validator.info().validate()).toEqual([ + { + file: 'namespaces/invalid_info_capitals.yaml', + location: 'Info', + message: "Title must be capitalized, expected 'Title Must Be Capitalized'." + }, + { + file: 'namespaces/invalid_info_capitals.yaml', + location: 'Info', + message: "Description must start with a capital letter and end with a period." + } + ]) +}) + test('validate()', () => { - const invalid_name = mocked_namespace_file({ returned_values: { validate_name: 'Invalid Name' }, groups_errors: [['group error']] }) + const invalid_name = mocked_namespace_file({ returned_values: { validate_name: 'Invalid Name' } }) expect(invalid_name.validate()).toEqual(['Invalid Name']) - const invalid_groups = mocked_namespace_file({ returned_values: { validate_schemas: 'Invalid schemas' }, groups_errors: [['error']] }) + const invalid_groups = mocked_namespace_file({ groups_errors: [['error']] }) expect(invalid_groups.validate()).toEqual(['error']) const typical = mocked_namespace_file({ returned_values: { + validate_info: ['title error', 'description error'], validate_schemas: 'schemas error', validate_unresolved_refs: ['unresolved'], validate_unused_refs: ['unused'], validate_parameter_refs: ['parameter'] } }) - expect(typical.validate()).toEqual(['schemas error', 'unresolved', 'unused', 'parameter']) - const valid = mocked_namespace_file({ groups_errors: [[], []] }) + expect(typical.validate()).toEqual([ + 'schemas error', + 'title error', + 'description error', + 'unresolved', + 'unused', + 'parameter' + ]) + + const valid = mocked_namespace_file({ spec: { info: { title: 'Title', description: 'Description.' } }, groups_errors: [[], []] }) expect(valid.validate()).toEqual([]) }) diff --git a/tools/tests/linter/Operation.test.ts b/tools/tests/linter/Operation.test.ts index aeedd3a0..c5154eb0 100644 --- a/tools/tests/linter/Operation.test.ts +++ b/tools/tests/linter/Operation.test.ts @@ -69,7 +69,7 @@ test('validate_description()', () => { const invalid_description = operation({ 'x-operation-group': 'indices.create', description: 'This is a description without a period' }) expect(invalid_description.validate_description()) - .toEqual(invalid_description.error('Description must end with a period.')) + .toEqual(invalid_description.error('Description must start with a capital letter and end with a period.')) const valid_description = operation({ 'x-operation-group': 'indices.create', description: 'This is a description with a period.' }) expect(valid_description.validate_description()) diff --git a/tools/tests/linter/Schema.test.ts b/tools/tests/linter/Schema.test.ts index d5249224..afedc891 100644 --- a/tools/tests/linter/Schema.test.ts +++ b/tools/tests/linter/Schema.test.ts @@ -21,3 +21,11 @@ test('validate_name()', () => { expect(schema('Valid1Name').validate_name()).toBeUndefined() expect(schema('uint').validate_name()).toBeUndefined() }) + +test('validate_description()', () => { + expect(schema('Name', { description: 'Does not end with a period' }).validate_description()).toEqual({ + file: '_common.yaml', + location: '#/components/schemas/Name', + message: "Description must start with a capital letter and end with a period." + }) +}) diff --git a/tools/tests/linter/factories/namespace_file.ts b/tools/tests/linter/factories/namespace_file.ts index 6b661989..833070c8 100644 --- a/tools/tests/linter/factories/namespace_file.ts +++ b/tools/tests/linter/factories/namespace_file.ts @@ -18,6 +18,7 @@ export function namespace_file (fixture_file: string): NamespaceFile { interface MockedReturnedValues { validate?: string[] validate_name?: string | undefined + validate_info?: string[], validate_schemas?: string | undefined validate_unresolved_refs?: string[] validate_unused_refs?: string[] @@ -41,12 +42,14 @@ export function mocked_namespace_file (ops: { returned_values?: MockedReturnedVa return ns_file } + ns_file.validate_info = jest.fn() ns_file.validate_name = jest.fn() ns_file.validate_schemas = jest.fn() ns_file.validate_unresolved_refs = jest.fn() ns_file.validate_unused_refs = jest.fn() ns_file.validate_parameter_refs = jest.fn() + if (ops.returned_values.validate_info != null) (ns_file.validate_info as jest.Mock).mockReturnValue(ops.returned_values.validate_info) if (ops.returned_values.validate_name != null) (ns_file.validate_name as jest.Mock).mockReturnValue(ops.returned_values.validate_name) if (ops.returned_values.validate_schemas != null) (ns_file.validate_schemas as jest.Mock).mockReturnValue(ops.returned_values.validate_schemas) if (ops.returned_values.validate_unresolved_refs != null) (ns_file.validate_unresolved_refs as jest.Mock).mockReturnValue(ops.returned_values.validate_unresolved_refs) diff --git a/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_capitals.yaml b/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_capitals.yaml new file mode 100644 index 00000000..1b58fdd8 --- /dev/null +++ b/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_capitals.yaml @@ -0,0 +1,4 @@ +openapi: 3.1.0 +info: + title: Title must be capitalized + description: description must start with a capital letter and end with a period. \ No newline at end of file diff --git a/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_periods.yaml b/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_periods.yaml new file mode 100644 index 00000000..87701239 --- /dev/null +++ b/tools/tests/linter/fixtures/file_validators/namespaces/invalid_info_periods.yaml @@ -0,0 +1,4 @@ +openapi: 3.1.0 +info: + title: Title should not have a period. + description: Description should have a period \ No newline at end of file diff --git a/tools/tests/linter/fixtures/file_validators/namespaces/valid_info_multiline_description.yaml b/tools/tests/linter/fixtures/file_validators/namespaces/valid_info_multiline_description.yaml new file mode 100644 index 00000000..eeef80e7 --- /dev/null +++ b/tools/tests/linter/fixtures/file_validators/namespaces/valid_info_multiline_description.yaml @@ -0,0 +1,6 @@ +openapi: 3.1.0 +info: + title: Title is Valid + description: |- + Description is valid. + This description is valid too. \ No newline at end of file diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml index 95c4f4c6..46f0228c 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/cat.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/_cat/aliases/{name}': get: diff --git a/tools/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 index c0feea71..64ece732 100644 --- a/tools/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 @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/{index}': {} '/{index}/_clone': {} diff --git a/tools/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 index 168ecad3..e1f45811 100644 --- a/tools/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 @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: /_rollover: {} /{index}/_rollover: {} \ No newline at end of file diff --git a/tools/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 index 30d77011..737089fd 100644 --- a/tools/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 @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/{index}': {} '/{index}/_rollover': {} \ No newline at end of file diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml index 99c22abc..bf35791a 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_files/invalid_spec.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/{index}/_doc/{id}': get: diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml index 95c4f4c6..46f0228c 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/cat.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/_cat/aliases/{name}': get: diff --git a/tools/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 index c0feea71..eaf35fd0 100644 --- a/tools/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 @@ -1,3 +1,8 @@ + +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/{index}': {} '/{index}/_clone': {} diff --git a/tools/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 index 168ecad3..e1f45811 100644 --- a/tools/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 @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: /_rollover: {} /{index}/_rollover: {} \ No newline at end of file diff --git a/tools/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 index 30d77011..737089fd 100644 --- a/tools/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 @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/{index}': {} '/{index}/_rollover': {} \ No newline at end of file diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_d.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_d.yaml index 20067892..c8be8c31 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_d.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_d.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: '/nodes/{metric}': {} '/nodes/{node_id}': {} diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_a.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_a.yaml index 88c1dc7c..61babec1 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_a.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_a.yaml @@ -1,6 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Indices API (Namespace 1) + description: Description. version: 1.0.0 paths: '/indices/{metric}': {} diff --git a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_b.yaml b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_b.yaml index 6e8dcd79..9b363b16 100644 --- a/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_b.yaml +++ b/tools/tests/linter/fixtures/folder_validators/namespaces/invalid_folder/dup_path_namespace_b.yaml @@ -1,6 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch Indices API (Namespace 2) + description: Description. version: 1.0.0 paths: '/indices/{node_id}': {} diff --git a/tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml b/tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml index 0a58a571..7c8a2a59 100644 --- a/tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml +++ b/tools/tests/linter/fixtures/inline_object_schema_validator/namespaces/ops.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. paths: /the/path: post: diff --git a/tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml b/tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml index f8fc46fb..4942c1b9 100644 --- a/tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml +++ b/tools/tests/linter/fixtures/schema_refs_validator/namespaces/indices.yaml @@ -1,3 +1,7 @@ +openapi: 3.1.0 +info: + title: Title + description: Description. components: parameters: animals::query.mammal: diff --git a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml index 7b066da2..8b40f025 100644 --- a/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/anonymous_schemas/namespaces/shelter.yaml @@ -45,7 +45,6 @@ components: type: number2 responses: adopt@200: - description: '' content: application/json: schema: diff --git a/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml b/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml index 4072426c..85398b8f 100644 --- a/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml +++ b/tools/tests/linter/fixtures/schemas_validator/named_schemas/namespaces/shelter.yaml @@ -39,7 +39,6 @@ components: type: number responses: adopt@200: - description: '' application/json: schema: type: object \ No newline at end of file diff --git a/tools/tests/merger/fixtures/extractor/expected_1.3.yaml b/tools/tests/merger/fixtures/extractor/expected_1.3.yaml index 81eecb28..d0fa222f 100644 --- a/tools/tests/merger/fixtures/extractor/expected_1.3.yaml +++ b/tools/tests/merger/fixtures/extractor/expected_1.3.yaml @@ -55,7 +55,6 @@ components: requestBodies: {} responses: info@200: - description: '' content: application/json: schema: @@ -68,7 +67,6 @@ components: required: - tagline info@201: - description: '' content: application/json: schema: @@ -80,7 +78,6 @@ components: - tagline unevaluatedProperties: true info@404: - description: '' content: application/json: schema: @@ -93,7 +90,6 @@ components: unevaluatedProperties: type: object info@500: - description: '' content: application/json: schema: @@ -102,7 +98,6 @@ components: tagline: type: string info@503: - description: '' content: application/json: schema: diff --git a/tools/tests/merger/fixtures/extractor/expected_2.0.yaml b/tools/tests/merger/fixtures/extractor/expected_2.0.yaml index 95e11986..cfb4279d 100644 --- a/tools/tests/merger/fixtures/extractor/expected_2.0.yaml +++ b/tools/tests/merger/fixtures/extractor/expected_2.0.yaml @@ -97,7 +97,6 @@ components: description: Nodes options. responses: info@200: - description: '' content: application/json: schema: @@ -108,7 +107,6 @@ components: required: - tagline info@201: - description: '' content: application/json: schema: @@ -120,7 +118,6 @@ components: - tagline unevaluatedProperties: true info@404: - description: '' content: application/json: schema: @@ -133,7 +130,6 @@ components: unevaluatedProperties: type: object info@500: - description: '' content: application/json: schema: @@ -142,7 +138,6 @@ components: tagline: type: string info@503: - description: '' content: application/json: schema: diff --git a/tools/tests/merger/fixtures/merger/expected.yaml b/tools/tests/merger/fixtures/merger/expected.yaml index ef0560ad..789d1f20 100644 --- a/tools/tests/merger/fixtures/merger/expected.yaml +++ b/tools/tests/merger/fixtures/merger/expected.yaml @@ -95,12 +95,10 @@ components: type: string responses: adopt@200: - description: '' application/json: schema: type: object indices.create@200: - description: '' application/json: schema: type: object diff --git a/tools/tests/merger/fixtures/spec/namespaces/indices.yaml b/tools/tests/merger/fixtures/spec/namespaces/indices.yaml index d5f1fcb9..7caa9b02 100644 --- a/tools/tests/merger/fixtures/spec/namespaces/indices.yaml +++ b/tools/tests/merger/fixtures/spec/namespaces/indices.yaml @@ -41,7 +41,6 @@ components: type: boolean responses: indices.create@200: - description: '' application/json: schema: type: object diff --git a/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml b/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml index 4072426c..85398b8f 100644 --- a/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml +++ b/tools/tests/merger/fixtures/spec/namespaces/shelter.yaml @@ -39,7 +39,6 @@ components: type: number responses: adopt@200: - description: '' application/json: schema: type: object \ No newline at end of file diff --git a/tools/tests/tester/fixtures/specs/complete/namespaces/index.yaml b/tools/tests/tester/fixtures/specs/complete/namespaces/index.yaml index a2402b35..68337dc6 100644 --- a/tools/tests/tester/fixtures/specs/complete/namespaces/index.yaml +++ b/tools/tests/tester/fixtures/specs/complete/namespaces/index.yaml @@ -31,7 +31,6 @@ paths: components: responses: info@200: - description: '' content: application/json: schema: @@ -44,7 +43,6 @@ components: required: - tagline info@201: - description: '' content: application/json: schema: @@ -56,7 +54,6 @@ components: - tagline unevaluatedProperties: true info@404: - description: '' content: application/json: schema: @@ -73,14 +70,13 @@ components: info@removed-2.0: description: Removed in 2.0 via attribute next to ref. info@added-1.3-removed-2.0: - description: 'Added in 1.3, removed in 2.0 via attribute in response body.' + description: Added in 1.3, removed in 2.0 via attribute in response body. x-version-added: '1.3' x-version-removed: '2.0' info@added-2.1: description: Added in 2.1 via attribute in response body. x-version-added: '2.1' info@500: - description: '' content: application/json: schema: @@ -89,7 +85,6 @@ components: tagline: type: string info@503: - description: '' content: application/json: schema: diff --git a/tools/tests/tester/fixtures/specs/excerpt.yaml b/tools/tests/tester/fixtures/specs/excerpt.yaml index 2a285955..64ad01d3 100644 --- a/tools/tests/tester/fixtures/specs/excerpt.yaml +++ b/tools/tests/tester/fixtures/specs/excerpt.yaml @@ -126,7 +126,6 @@ components: items: type: object cat.indices@200: - description: '' content: text/plain: schema: @@ -152,17 +151,14 @@ components: items: type: object indices.delete@200: - description: '' content: application/json: schema: $ref: '#/components/schemas/_common:IndicesResponseBase' indices.exists@200: - description: '' content: application/json: {} indices.create@200: - description: '' content: application/json: schema: