Skip to content

Commit 2a39edd

Browse files
authored
Ensure correct OpenAPI 3.1.0 spec. (#646)
* Added Python and Ruby spec validators. Signed-off-by: dblock <[email protected]> * Add empty descriptions where missing and remove descriptions next to refs. Signed-off-by: dblock <[email protected]> * Replaced the validator compatible with OpenAPI 3.1. Signed-off-by: dblock <[email protected]> * Fixed incorrect style. Signed-off-by: dblock <[email protected]> * Added missing require. Signed-off-by: dblock <[email protected]> * Fix: schema null is not supported. Signed-off-by: dblock <[email protected]> * Removed unused required property. Signed-off-by: dblock <[email protected]> * Fix: added missing schema. Signed-off-by: dblock <[email protected]> * Fix: removed incorrect defaults. Signed-off-by: dblock <[email protected]> * Fix: added missing required. Signed-off-by: dblock <[email protected]> * Fix: removed incorrect required. Signed-off-by: dblock <[email protected]> * Removed incorrect externalDocs. Signed-off-by: dblock <[email protected]> * Document the ruby spec validator. Signed-off-by: dblock <[email protected]> * Fix: removed redundant content types. Signed-off-by: dblock <[email protected]> * Improve displaying of errors. Signed-off-by: dblock <[email protected]> * Normalize keys to be compatible with OpenAPI 3.1. Signed-off-by: dblock <[email protected]> * Removed superseeded operations that have unresolved parameters. Signed-off-by: dblock <[email protected]> * Fix: don't reduce error payload, allows to verify schema. Signed-off-by: dblock <[email protected]> * Fix: flow framework schema tests. Signed-off-by: dblock <[email protected]> * Fix: if no decision is made there's no weight ranking. Signed-off-by: dblock <[email protected]> * Fix: wrap indexing errors. Signed-off-by: dblock <[email protected]> * Added verbose logging of the story being evaluated. Signed-off-by: dblock <[email protected]> * Fix: security API test error responses. Signed-off-by: dblock <[email protected]> * Fix: duration ref. Signed-off-by: dblock <[email protected]> * Fix typo in property. Signed-off-by: dblock <[email protected]> * Fix superseeded operation parameters. Signed-off-by: dblock <[email protected]> * Fix: neural search error response. Signed-off-by: dblock <[email protected]> * Normalize fields. .replaceAll('::', '___') .replaceAll('@', '__') .replaceAll(':', '_') Signed-off-by: dblock <[email protected]> * Re-added default values into the schema. Signed-off-by: dblock <[email protected]> * Disallowed characters are replaced with ___. Signed-off-by: dblock <[email protected]> --------- Signed-off-by: dblock <[email protected]>
1 parent 3167577 commit 2a39edd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1295
-501
lines changed

.cspell

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ geotile
6363
gsub
6464
Gsub
6565
haasephonetik
66+
hashcode
6667
heteroscedastic
6768
hnsw
6869
homoscedastic
@@ -134,6 +135,7 @@ Oversample
134135
performanceanalyzer
135136
permissionsinfo
136137
pipefail
138+
pipenv
137139
preconfigure
138140
preconfigured
139141
prefilter
File renamed without changes.
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Validate Spec (Python)
2+
3+
on: [pull_request,push]
4+
5+
jobs:
6+
validate-spec-py:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout the repo
10+
uses: actions/checkout@v4
11+
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: '20'
16+
17+
- name: Build
18+
run: npm ci && npm run merge
19+
20+
- name: Set Up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install Dependencies
26+
working-directory: tools/src/validate-spec-py
27+
run: |
28+
pip install --user pipenv
29+
pipenv install
30+
31+
- name: Validate Spec
32+
working-directory: tools/src/validate-spec-py
33+
run: |
34+
pipenv run python validate.py ../../../build/opensearch-openapi.yaml
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Validate Spec (Ruby)
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
validate-spec-ruby:
7+
runs-on: ubuntu-latest
8+
env:
9+
BUNDLE_GEMFILE: ${{ github.workspace }}/tools/src/validate-spec-ruby/Gemfile
10+
steps:
11+
- name: Checkout the repo
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '20'
18+
19+
- name: Build
20+
run: npm ci && npm run merge
21+
22+
- uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: '3.3'
25+
bundler-cache: true
26+
27+
- name: Validate Spec
28+
working-directory: tools/src/validate-spec-ruby
29+
run: |
30+
bundle exec ruby validate.rb ../../../build/opensearch-openapi.yaml

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
### Added
88
- Added API specs for query groups lifecycle APIs ([#649](https://github.com/opensearch-project/opensearch-api-specification/pull/649))
9+
- Added Python and Ruby spec validators ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
10+
- Added verbose output of the story being evaluated ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
911

1012
### Removed
1113
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
1214

15+
### Fixed
16+
- Spec passes OpenAPI 3.1.0 validations ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
17+
- Disallowed characters (`::`, `@`, and `:`) in key names are replaced with `___` on merge ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
18+
- Added missing `required` to `path` parameters ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
19+
- Added missing `schema` parent to response types ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
20+
- Removed invalid `externalDocs` from `flow_framework.create/update::query.use_case` ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
21+
- Fixed incorrect `style` in `indices.get_mapping::query.index` ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
22+
- Removed invalid `required` from `ppl` responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
23+
- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
24+
1325
## [0.1.0] - 2024-10-25
1426

1527
### Added

DEVELOPER_GUIDE.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
- [Comment on PR](#comment-on-pr)
2727
- [Test Tools (Unit)](#test-tools-unit)
2828
- [Test Tools (Integration)](#test-tools-integration)
29-
- [Validate Spec](#validate-spec)
29+
- [Validate Spec (Lint)](#validate-spec-lint)
30+
- [Validate Spec (Python)](#validate-spec-python)
31+
- [Validate Spec (Ruby)](#validate-spec-ruby)
3032
<!-- TOC -->
3133

3234
# Developer Guide
@@ -375,6 +377,30 @@ This workflow runs on PRs to invoke the [tools' unit tests](tools/tests), upload
375377

376378
This workflow runs on PRs to invoke the [tools' integration tests](tools/tests) that require a running instance of OpenSearch to ensure there are no breakages in behavior.
377379

378-
### [Validate Spec](.github/workflows/validate-spec.yml)
380+
### [Validate Spec (Lint)](.github/workflows/validate-spec-lint.yml)
379381

380382
This workflow runs on PRs to invoke the [spec linter](#spec-linter) and ensure the multi-file spec is correct and follows the design guidelines.
383+
384+
### [Validate Spec (Python)](.github/workflows/validate-spec-py.yml)
385+
386+
This workflow runs on PRs to invoke the [Python openapi-spec-validator](https://pypi.org/project/openapi-spec-validator/) to ensure that the resulting spec can be loaded by Python tools.
387+
388+
You can run the validator locally as follows after installing [pipenv](https://pipenv.pypa.io/en/latest/installation.html).
389+
390+
```
391+
cd tools/src/validate-spec-py
392+
pipenv install
393+
npm run merge ; pipenv run python validate.py ../../../build/opensearch-openapi.yaml
394+
```
395+
396+
### [Validate Spec (Ruby)](.github/workflows/validate-spec-ruby.yml)
397+
398+
This workflow runs on PRs to invoke the Ruby [Json Schemer](https://github.com/davishmcclurg/json_schemer/) to ensure that the resulting spec can be loaded by Ruby tools.
399+
400+
You can run the validator locally as follows.
401+
402+
```
403+
cd tools/src/validate-spec-ruby
404+
bundle install
405+
npm run merge ; bundle exec ruby validate.rb ../../../build/opensearch-openapi.yaml
406+
```

spec/_global_parameters.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ components:
1010
description: Whether to pretty format the returned JSON response.
1111
schema:
1212
type: boolean
13-
default: false
13+
default: false
1414
human:
1515
name: human
1616
in: query
1717
description: Whether to return human readable values for statistics.
1818
schema:
1919
type: boolean
20-
default: true
20+
default: true
2121
error_trace:
2222
name: error_trace
2323
in: query
2424
description: Whether to include the stack trace of returned errors.
2525
schema:
2626
type: boolean
27-
default: false
27+
default: false
2828
source:
2929
name: source
3030
in: query

spec/_superseded_operations.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
201201
- GET
202202
- PUT
203203
/_opendistro/_ism/policies/{policyID}:
204-
superseded_by: /_plugins/_ism/policies/{policyID}
204+
superseded_by: /_plugins/_ism/policies/{policy_id}
205205
operations:
206206
- GET
207207
- HEAD
@@ -240,7 +240,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
240240
operations:
241241
- GET
242242
/_opendistro/_knn/{nodeId}/stats/{stat}:
243-
superseded_by: /_plugins/_knn/{nodeId}/stats/{stat}
243+
superseded_by: /_plugins/_knn/{node_id}/stats/{stat}
244244
operations:
245245
- GET
246246
/_opendistro/_performanceanalyzer/_agent/{redirectEndpoint}:
@@ -354,22 +354,22 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
354354
- GET
355355
- PUT
356356
/_opendistro/_rollup/jobs/{rollupID}:
357-
superseded_by: /_plugins/_rollup/jobs/{rollupID}
357+
superseded_by: /_plugins/_rollup/jobs/{id}
358358
operations:
359359
- GET
360360
- HEAD
361361
- PUT
362362
- DELETE
363363
/_opendistro/_rollup/jobs/{rollupID}/_explain:
364-
superseded_by: /_plugins/_rollup/jobs/{rollupID}/_explain
364+
superseded_by: /_plugins/_rollup/jobs/{id}/_explain
365365
operations:
366366
- GET
367367
/_opendistro/_rollup/jobs/{rollupID}/_start:
368-
superseded_by: /_plugins/_rollup/jobs/{rollupID}/_start
368+
superseded_by: /_plugins/_rollup/jobs/{id}/_start
369369
operations:
370370
- POST
371371
/_opendistro/_rollup/jobs/{rollupID}/_stop:
372-
superseded_by: /_plugins/_rollup/jobs/{rollupID}/_stop
372+
superseded_by: /_plugins/_rollup/jobs/{id}/_stop
373373
operations:
374374
- POST
375375
/_opendistro/_security/api/_upgrade_check/:
@@ -401,7 +401,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
401401
- GET
402402
- PATCH
403403
/_opendistro/_security/api/actiongroups/{name}:
404-
superseded_by: /_plugins/_security/api/actiongroups/{name}
404+
superseded_by: /_plugins/_security/api/actiongroups/{action_group}
405405
operations:
406406
- GET
407407
- PUT
@@ -433,14 +433,14 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
433433
- GET
434434
- PATCH
435435
/_opendistro/_security/api/internalusers/{name}:
436-
superseded_by: /_plugins/_security/api/internalusers/{name}
436+
superseded_by: /_plugins/_security/api/internalusers/{username}
437437
operations:
438438
- GET
439439
- PUT
440440
- PATCH
441441
- DELETE
442442
/_opendistro/_security/api/internalusers/{name}/authtoken:
443-
superseded_by: /_plugins/_security/api/internalusers/{name}/authtoken
443+
superseded_by: /_plugins/_security/api/internalusers/{username}/authtoken
444444
operations:
445445
- POST
446446
/_opendistro/_security/api/migrate:
@@ -457,7 +457,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
457457
- GET
458458
- PATCH
459459
/_opendistro/_security/api/roles/{name}:
460-
superseded_by: /_plugins/_security/api/roles/{name}
460+
superseded_by: /_plugins/_security/api/roles/{role}
461461
operations:
462462
- GET
463463
- PUT
@@ -469,7 +469,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
469469
- GET
470470
- PATCH
471471
/_opendistro/_security/api/rolesmapping/{name}:
472-
superseded_by: /_plugins/_security/api/rolesmapping/{name}
472+
superseded_by: /_plugins/_security/api/rolesmapping/{role}
473473
operations:
474474
- GET
475475
- PUT
@@ -519,7 +519,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
519519
- GET
520520
- PATCH
521521
/_opendistro/_security/api/tenants/{name}:
522-
superseded_by: /_plugins/_security/api/tenants/{name}
522+
superseded_by: /_plugins/_security/api/tenants/{tenant}
523523
operations:
524524
- GET
525525
- PUT
@@ -529,14 +529,14 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml
529529
superseded_by: /_plugins/_security/api/user
530530
operations:
531531
- GET
532-
/_opendistro/_security/api/user/{name}:
533-
superseded_by: /_plugins/_security/api/user/{name}
532+
/_opendistro/_security/api/user/{username}:
533+
superseded_by: /_plugins/_security/api/user/{username}
534534
operations:
535535
- GET
536536
- PUT
537537
- DELETE
538538
/_opendistro/_security/api/user/{name}/authtoken:
539-
superseded_by: /_plugins/_security/api/user/{name}/authtoken
539+
superseded_by: /_plugins/_security/api/user/{username}/authtoken
540540
operations:
541541
- POST
542542
/_opendistro/_security/api/validate:

spec/namespaces/asynchronous_search.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ components:
9090
in: path
9191
schema:
9292
type: string
93+
required: true
9394
asynchronous_search.delete::path.id:
9495
name: id
9596
in: path
9697
schema:
9798
type: string
99+
required: true
98100
requestBodies:
99101
asynchronous_search.search:
100102
content:

0 commit comments

Comments
 (0)