From fb5087da2d704a8dada4fa88d019c1a2a0660c70 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 27 Sep 2024 11:49:28 +0400 Subject: [PATCH] Fix indices.get_alias error response --- output/openapi/elasticsearch-openapi.json | 9 ++- .../elasticsearch-serverless-openapi.json | 9 ++- output/schema/schema-serverless.json | 55 +++++++------------ output/schema/schema.json | 55 +++++++------------ output/typescript/types.ts | 2 +- specification/_types/Base.ts | 2 +- .../get_alias/IndicesGetAliasResponse.ts | 13 ----- 7 files changed, 56 insertions(+), 89 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 116ce5e278..e8c8969e59 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -65172,7 +65172,14 @@ "type": "object", "properties": { "error": { - "$ref": "#/components/schemas/_types:ErrorCause" + "oneOf": [ + { + "$ref": "#/components/schemas/_types:ErrorCause" + }, + { + "type": "string" + } + ] }, "status": { "type": "number" diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 71ae0df83d..26593cb240 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -52351,7 +52351,14 @@ "type": "object", "properties": { "error": { - "$ref": "#/components/schemas/_types:ErrorCause" + "oneOf": [ + { + "$ref": "#/components/schemas/_types:ErrorCause" + }, + { + "type": "string" + } + ] }, "status": { "type": "number" diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 03e93b61bc..fe425c3a76 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -21281,41 +21281,12 @@ } } }, - "exceptions": [ - { - "body": { - "kind": "value", - "value": { - "items": [ - { - "kind": "instance_of", - "type": { - "name": "NotFoundAliases", - "namespace": "indices.get_alias" - } - }, - { - "kind": "instance_of", - "type": { - "name": "ErrorResponseBase", - "namespace": "_types" - } - } - ], - "kind": "union_of" - } - }, - "statusCodes": [ - 404 - ] - } - ], "kind": "response", "name": { "name": "Response", "namespace": "indices.get_alias" }, - "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L26-L35" + "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L24-L27" }, { "attachedBehaviors": [ @@ -75411,11 +75382,23 @@ "name": "error", "required": true, "type": { - "kind": "instance_of", - "type": { - "name": "ErrorCause", - "namespace": "_types" - } + "items": [ + { + "kind": "instance_of", + "type": { + "name": "ErrorCause", + "namespace": "_types" + } + }, + { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + ], + "kind": "union_of" } }, { @@ -118210,7 +118193,7 @@ } } ], - "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L37-L39" + "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L29-L31" }, { "kind": "interface", diff --git a/output/schema/schema.json b/output/schema/schema.json index 8734cfb794..91bdb3fe50 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -43644,11 +43644,23 @@ "name": "error", "required": true, "type": { - "kind": "instance_of", - "type": { - "name": "ErrorCause", - "namespace": "_types" - } + "kind": "union_of", + "items": [ + { + "kind": "instance_of", + "type": { + "name": "ErrorCause", + "namespace": "_types" + } + }, + { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + ] } }, { @@ -130444,7 +130456,7 @@ } } ], - "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L37-L39" + "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L29-L31" }, { "kind": "request", @@ -130570,40 +130582,11 @@ } } }, - "exceptions": [ - { - "body": { - "kind": "value", - "value": { - "kind": "union_of", - "items": [ - { - "kind": "instance_of", - "type": { - "name": "NotFoundAliases", - "namespace": "indices.get_alias" - } - }, - { - "kind": "instance_of", - "type": { - "name": "ErrorResponseBase", - "namespace": "_types" - } - } - ] - } - }, - "statusCodes": [ - 404 - ] - } - ], "name": { "name": "Response", "namespace": "indices.get_alias" }, - "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L26-L35" + "specLocation": "indices/get_alias/IndicesGetAliasResponse.ts#L24-L27" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 9b34cb7c8b..f0d6104dfd 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2304,7 +2304,7 @@ export type ErrorCause = ErrorCauseKeys & { [property: string]: any } export interface ErrorResponseBase { - error: ErrorCause + error: ErrorCause | string status: integer } diff --git a/specification/_types/Base.ts b/specification/_types/Base.ts index 2ac27fe0c5..988b63607b 100644 --- a/specification/_types/Base.ts +++ b/specification/_types/Base.ts @@ -80,7 +80,7 @@ export class ErrorResponseBase { // In some edge cases `error` can be a string that is a shortcut to `error.reason`, for example if you call `GET _cat/foo`. // If the error is a string, it means that it was not caused by an exception on ES side, but on the HTTP routing layer. // This should never happen in clients, because we assume we will never send malformed request. - error: ErrorCause + error: ErrorCause | string status: integer } diff --git a/specification/indices/get_alias/IndicesGetAliasResponse.ts b/specification/indices/get_alias/IndicesGetAliasResponse.ts index 21ebed7999..15f9da29ad 100644 --- a/specification/indices/get_alias/IndicesGetAliasResponse.ts +++ b/specification/indices/get_alias/IndicesGetAliasResponse.ts @@ -18,27 +18,14 @@ */ import { AliasDefinition } from '@indices/_types/AliasDefinition' -import { AdditionalProperties } from '@spec_utils/behaviors' import { Dictionary } from '@spec_utils/Dictionary' -import { ErrorResponseBase } from '@_types/Base' import { IndexName } from '@_types/common' export class Response { /** @codegen_name aliases */ body: Dictionary - exceptions: [ - { - statusCodes: [404] - body: NotFoundAliases | ErrorResponseBase - } - ] } export class IndexAliases { aliases: Dictionary } - -class NotFoundAliases implements AdditionalProperties { - error: string - status: number -}