From 922d1543a49243c87bd7058378602df5aebaf43d Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 11 Jul 2024 18:01:51 -0400 Subject: [PATCH] Simplify MatchQuery spec. Signed-off-by: dblock --- spec/schemas/_common.query_dsl.yaml | 17 +++++++---------- tools/src/_utils/index.ts | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index 1b5149d15..c5ec3de39 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -69,16 +69,13 @@ components: description: |- Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. - anyOf: - - type: object - additionalProperties: - $ref: '#/components/schemas/MatchQuery' - minProperties: 1 - maxProperties: 1 - - type: object - additionalProperties: true - minProperties: 1 - maxProperties: 1 + type: object + additionalProperties: + anyOf: + - $ref: '#/components/schemas/MatchQuery' + - true + minProperties: 1 + maxProperties: 1 match_all: $ref: '#/components/schemas/MatchAllQuery' match_bool_prefix: diff --git a/tools/src/_utils/index.ts b/tools/src/_utils/index.ts index 2a9c67996..952dc4d7b 100644 --- a/tools/src/_utils/index.ts +++ b/tools/src/_utils/index.ts @@ -11,7 +11,7 @@ import { type OpenAPIV3 } from 'openapi-types' import { type ValidationError } from 'types' export function is_ref (o: MaybeRef): o is OpenAPIV3.ReferenceObject { - return '$ref' in o + return typeof(o) === 'object' && '$ref' in o } export function is_array_schema (schema: OpenAPIV3.SchemaObject): schema is OpenAPIV3.ArraySchemaObject {