Skip to content

Commit

Permalink
spec: replace nullable value with null type (#436)
Browse files Browse the repository at this point in the history
* spec: replace nullable value with null type

Signed-off-by: Jakob Hahn <[email protected]>

* spec: please the linter

Signed-off-by: Jakob Hahn <[email protected]>

* ajv set allowUnionTypes

Signed-off-by: Jakob Hahn <[email protected]>

---------

Signed-off-by: Jakob Hahn <[email protected]>
  • Loading branch information
Jakob3xD committed Jul 19, 2024
1 parent e1cd369 commit bf2772a
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 237 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Replaced the deprecated fs.rmdirSync with fs.rmSync ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359))
- Tester tool now provides better context for non-2XX responses when --verbose is used ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359))
- Lock testing for next release of OpenSearch to a specific SHA ([#431](https://github.com/opensearch-project/opensearch-api-specification/pull/431))
- Replace nullable with null type ([#436](https://github.com/opensearch-project/opensearch-api-specification/pull/436))

### Deprecated

Expand Down
161 changes: 34 additions & 127 deletions spec/schemas/_common.aggregations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,14 @@ components:
KeyedPercentiles:
type: object
additionalProperties:
oneOf:
- type: string
- type: number
- nullable: true
type: string
type: ['null', number, string]
ArrayPercentilesItem:
type: object
properties:
key:
type: string
value:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
value_as_string:
type: string
required:
Expand Down Expand Up @@ -162,10 +155,7 @@ components:
description: |-
The metric value. A missing value generally means that there was no data to aggregate,
unless specified otherwise.
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
value_as_string:
type: string
required:
Expand Down Expand Up @@ -226,20 +216,11 @@ components:
count:
type: number
min:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
max:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
avg:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
sum:
type: number
min_as_string:
Expand All @@ -266,40 +247,19 @@ components:
- type: object
properties:
sum_of_squares:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
variance:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
variance_population:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
variance_sampling:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
std_deviation:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
std_deviation_population:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
std_deviation_sampling:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
std_deviation_bounds:
$ref: '#/components/schemas/StandardDeviationBounds'
sum_of_squares_as_string:
Expand All @@ -326,35 +286,17 @@ components:
type: object
properties:
upper:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
lower:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
upper_population:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
lower_population:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
upper_sampling:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
lower_sampling:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
required:
- lower
- lower_population
Expand Down Expand Up @@ -1426,32 +1368,20 @@ components:
count:
type: number
min_length:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
max_length:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
avg_length:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
entropy:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
distribution:
oneOf:
- type: 'null'
- type: object
additionalProperties:
type: number
- nullable: true
type: string
- type: string
min_length_as_string:
type: string
max_length_as_string:
Expand Down Expand Up @@ -1522,17 +1452,11 @@ components:
sort:
type: array
items:
oneOf:
- $ref: '_common.yaml#/components/schemas/FieldValue'
- nullable: true
type: string
$ref: '_common.yaml#/components/schemas/FieldValue'
metrics:
type: object
additionalProperties:
oneOf:
- $ref: '_common.yaml#/components/schemas/FieldValue'
- nullable: true
type: string
$ref: '_common.yaml#/components/schemas/FieldValue'
required:
- metrics
- sort
Expand All @@ -1542,10 +1466,7 @@ components:
- type: object
properties:
value:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
value_as_string:
type: string
required:
Expand Down Expand Up @@ -2544,21 +2465,13 @@ components:
properties:
from:
description: Start of the range (inclusive).
oneOf:
- type: number
- type: string
- nullable: true
type: string
type: ['null', number, string]
key:
description: Custom key to return the range with.
type: string
to:
description: End of the range (exclusive).
oneOf:
- type: number
- type: string
- nullable: true
type: string
type: ['null', number, string]
GeoHashGridAggregation:
allOf:
- $ref: '#/components/schemas/BucketAggregationBase'
Expand Down Expand Up @@ -2726,19 +2639,13 @@ components:
properties:
from:
description: Start of the range.
oneOf:
- type: string
- nullable: true
type: string
type: ['null', string]
mask:
description: IP range defined as a CIDR mask.
type: string
to:
description: End of the range.
oneOf:
- type: string
- nullable: true
type: string
type: ['null', string]
IpPrefixAggregation:
allOf:
- $ref: '#/components/schemas/BucketAggregationBase'
Expand Down Expand Up @@ -3113,8 +3020,8 @@ components:
- type: array
items:
type: number
- nullable: true
type: string
- type: 'null'
- type: string
hdr:
$ref: '#/components/schemas/HdrMethod'
tdigest:
Expand Down
16 changes: 4 additions & 12 deletions spec/schemas/_common.query_dsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1417,13 +1417,11 @@ components:
from:
oneOf:
- $ref: '_common.yaml#/components/schemas/DateMath'
- nullable: true
type: string
- type: 'null'
to:
oneOf:
- $ref: '_common.yaml#/components/schemas/DateMath'
- nullable: true
type: string
- type: 'null'
format:
$ref: '_common.yaml#/components/schemas/DateFormat'
time_zone:
Expand Down Expand Up @@ -1459,15 +1457,9 @@ components:
description: Less than or equal to.
type: number
from:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
to:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
RankFeatureQuery:
allOf:
- $ref: '#/components/schemas/QueryBase'
Expand Down
20 changes: 8 additions & 12 deletions spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@ components:
type: string
FieldValue:
description: A field value.
oneOf:
- type: number
- type: number
- type: string
- type: boolean
- nullable: true
type: string
- type: object
type:
- boolean
- 'null'
- number
- object
- string
Void:
description: |-
The absence of any type. This is commonly used in APIs that don't return a body.
Expand Down Expand Up @@ -1282,8 +1280,7 @@ components:
licensed:
type: boolean
custom_foldername:
nullable: true
type: string
type: ['null', string]
opensearch_version:
$ref: '#/components/schemas/VersionString'
required:
Expand Down Expand Up @@ -2014,8 +2011,7 @@ components:
relocating_node:
oneOf:
- $ref: '#/components/schemas/NodeId'
- nullable: true
type: string
- type: 'null'
relocation_failure_info:
$ref: '#/components/schemas/RelocationFailureInfo'
required:
Expand Down
5 changes: 1 addition & 4 deletions spec/schemas/_core.bulk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ components:
x-version-removed: '2.0'
_id:
description: The document ID associated with the operation.
anyOf:
- type: string
- nullable: true
type: string
type: ['null', string]
_index:
description: |-
Name of the index associated with the operation.
Expand Down
5 changes: 1 addition & 4 deletions spec/schemas/_core.rank_eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ components:
hit:
$ref: '#/components/schemas/RankEvalHit'
rating:
oneOf:
- type: number
- nullable: true
type: string
type: ['null', number, string]
required:
- hit
RankEvalHit:
Expand Down
Loading

0 comments on commit bf2772a

Please sign in to comment.