Skip to content

Commit

Permalink
Validate all schemas defined in the spec as valid JSON schemas (#294)
Browse files Browse the repository at this point in the history
- Updated default arg values for merge.ts
- Added Logger to silence merger tool's warnings
- Added SchemasValidator

Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong authored May 17, 2024
1 parent 25bd55d commit b253667
Show file tree
Hide file tree
Showing 37 changed files with 506 additions and 107 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"merge": "ts-node tools/src/merger/merge.ts",
"lint:spec": "ts-node tools/src/linter/lint.ts",
"lint": "eslint .",
"lint--fix": "eslint . --fix",
"test": "jest"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3529,10 +3529,10 @@ components:
in: path
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
x-data-type: array
items:
type: string
required: true
create_pit::query.allow_partial_pit_creation:
name: allow_partial_pit_creation
Expand Down
12 changes: 6 additions & 6 deletions spec/namespaces/cat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1766,13 +1766,13 @@ components:
name: local
in: query
description: Return local information, do not retrieve the state from cluster-manager node.
deprecated: true
x-version-deprecated: '1.0'
x-deprecation-message: This parameter does not cause this API to act locally.
schema:
type: boolean
default: false
description: Return local information, do not retrieve the state from cluster-manager node.
x-version-deprecated: '1.0'
x-deprecation-message: This parameter does not cause this API to act locally.
deprecated: true
cat.nodes::query.master_timeout:
name: master_timeout
in: query
Expand Down Expand Up @@ -2171,10 +2171,10 @@ components:
in: path
description: Comma-separated list or wildcard expression of index names to limit the returned information.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list or wildcard expression of index names to limit the returned information.
x-data-type: array
items:
type: string
required: true
cat.segment_replication::query.active_only:
name: active_only
Expand Down
5 changes: 0 additions & 5 deletions spec/namespaces/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ components:
description: Awareness attribute name.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: Awareness attribute name.
required: true
cluster.get_settings::query.cluster_manager_timeout:
Expand Down Expand Up @@ -962,7 +961,6 @@ components:
description: Awareness attribute name.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: Awareness attribute name.
required: true
cluster.health::path.index:
Expand Down Expand Up @@ -1180,7 +1178,6 @@ components:
description: Awareness attribute name.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: Awareness attribute name.
required: true
cluster.put_decommission_awareness::path.awareness_attribute_value:
Expand All @@ -1189,7 +1186,6 @@ components:
description: Awareness attribute value.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: Awareness attribute value.
required: true
cluster.put_settings::query.cluster_manager_timeout:
Expand Down Expand Up @@ -1230,7 +1226,6 @@ components:
description: Awareness attribute name.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: Awareness attribute name.
required: true
cluster.reroute::query.cluster_manager_timeout:
Expand Down
12 changes: 6 additions & 6 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3966,10 +3966,10 @@ components:
in: path
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
x-data-type: array
items:
type: string
required: true
indices.get_upgrade::query.allow_no_indices:
name: allow_no_indices
Expand Down Expand Up @@ -4980,10 +4980,10 @@ components:
in: path
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
x-data-type: array
items:
type: string
required: true
indices.upgrade::query.allow_no_indices:
name: allow_no_indices
Expand Down
79 changes: 38 additions & 41 deletions spec/namespaces/knn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ components:
description: The id of the model.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: The id of the model.
required: true
knn.get_model::path.model_id:
Expand All @@ -305,7 +304,6 @@ components:
description: The id of the model.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: The id of the model.
required: true
knn.search_models::query._source:
Expand Down Expand Up @@ -649,49 +647,49 @@ components:
in: path
description: Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
x-data-type: array
items:
type: string
required: true
knn.stats::path.stat:
name: stat
in: path
description: Comma-separated list of stats to retrieve; use `_all` or empty string to retrieve all stats.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of stats to retrieve; use `_all` or empty string to retrieve all stats.
x-enum-options:
- circuit_breaker_triggered
- total_load_time
- eviction_count
- hit_count
- miss_count
- graph_memory_usage
- graph_memory_usage_percentage
- graph_index_requests
- graph_index_errors
- graph_query_requests
- graph_query_errors
- knn_query_requests
- cache_capacity_reached
- load_success_count
- load_exception_count
- indices_in_cache
- script_compilations
- script_compilation_errors
- script_query_requests
- script_query_errors
- nmslib_initialized
- faiss_initialized
- model_index_status
- indexing_from_model_degraded
- training_requests
- training_errors
- training_memory_usage
- training_memory_usage_percentage
x-data-type: array
items:
type: string
enum:
- circuit_breaker_triggered
- total_load_time
- eviction_count
- hit_count
- miss_count
- graph_memory_usage
- graph_memory_usage_percentage
- graph_index_requests
- graph_index_errors
- graph_query_requests
- graph_query_errors
- knn_query_requests
- cache_capacity_reached
- load_success_count
- load_exception_count
- indices_in_cache
- script_compilations
- script_compilation_errors
- script_query_requests
- script_query_errors
- nmslib_initialized
- faiss_initialized
- model_index_status
- indexing_from_model_degraded
- training_requests
- training_errors
- training_memory_usage
- training_memory_usage_percentage
required: true
knn.stats::query.timeout:
name: timeout
Expand All @@ -705,7 +703,6 @@ components:
description: The id of the model.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
description: The id of the model.
required: true
knn.train_model::query.preference:
Expand All @@ -720,8 +717,8 @@ components:
in: path
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of indices; use `_all` or empty string to perform the operation on all indices.
x-data-type: array
items:
type: string
required: true
6 changes: 3 additions & 3 deletions spec/namespaces/nodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ components:
in: path
description: Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
schema:
type: string
pattern: ^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$
type: array
description: Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
x-data-type: array
items:
type: string
required: true
nodes.hot_threads::query.ignore_idle_threads:
name: ignore_idle_threads
Expand Down
8 changes: 4 additions & 4 deletions spec/namespaces/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ components:
content:
application/json:
schema:
$ref: '../schemas/security._common.yaml#/components/schemas/AllowlistConfig'
$ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig'
required: true
security.create_role:
content:
Expand Down Expand Up @@ -1280,7 +1280,7 @@ components:
content:
application/json:
schema:
$ref: '../schemas/security._common.yaml#/components/schemas/AllowlistConfig'
$ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig'
security.create_role@200:
description: ''
content:
Expand Down Expand Up @@ -1448,7 +1448,7 @@ components:
content:
application/json:
schema:
$ref: '../schemas/security._common.yaml#/components/schemas/AllowlistConfig'
$ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig'
security.get_audit_configuration@200:
description: ''
content:
Expand Down Expand Up @@ -1646,7 +1646,7 @@ components:
content:
application/json:
schema:
$ref: '../schemas/security._common.yaml#/components/schemas/AllowlistConfig'
$ref: '../schemas/security._common.yaml#/components/schemas/AllowListConfig'
security.patch_audit_configuration@200:
description: ''
content:
Expand Down
1 change: 1 addition & 0 deletions spec/schemas/_common.aggregations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,7 @@ components:
missing:
$ref: '#/components/schemas/Missing'
MovingAverageAggregation:
type: object
discriminator:
propertyName: model
oneOf:
Expand Down
5 changes: 5 additions & 0 deletions spec/schemas/_common.analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ paths: {}
components:
schemas:
Analyzer:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down Expand Up @@ -351,6 +352,7 @@ components:
- type: string
- $ref: '#/components/schemas/CharFilterDefinition'
CharFilterDefinition:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down Expand Up @@ -447,6 +449,7 @@ components:
- type: string
- $ref: '#/components/schemas/TokenFilterDefinition'
TokenFilterDefinition:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down Expand Up @@ -1473,6 +1476,7 @@ components:
required:
- type
Normalizer:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down Expand Up @@ -1509,6 +1513,7 @@ components:
- type: string
- $ref: '#/components/schemas/TokenizerDefinition'
TokenizerDefinition:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down
1 change: 1 addition & 0 deletions spec/schemas/_common.mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ components:
unmatch:
type: string
Property:
type: object
discriminator:
propertyName: type
oneOf:
Expand Down
1 change: 0 additions & 1 deletion spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ components:
description: |-
A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
`d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
x-data-type: time
pattern: ^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$
type: string
Metadata:
Expand Down
4 changes: 1 addition & 3 deletions spec/schemas/_core.rank_eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ components:
- type: object
properties:
normalize:
externalDocs:
url: https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG
description: If set to true, this metric will calculate the Normalized DCG.
description: If set to true, this metric will calculate the Normalized DCG (https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG).
type: boolean
RankEvalMetricExpectedReciprocalRank:
allOf:
Expand Down
1 change: 1 addition & 0 deletions spec/schemas/cluster.remote_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ paths: {}
components:
schemas:
ClusterRemoteInfo:
type: object
discriminator:
propertyName: mode
oneOf:
Expand Down
Loading

0 comments on commit b253667

Please sign in to comment.