From 7f78698a735de7d8a6b12d88de4b4bd0104db09e Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 9 Sep 2024 14:41:32 +0400 Subject: [PATCH] Use an enum for ES|QL format parameter (#2873) --- output/openapi/elasticsearch-openapi.json | 15 +++++++- .../elasticsearch-serverless-openapi.json | 15 +++++++- output/schema/schema-serverless.json | 38 ++++++++++++++++++- output/schema/schema.json | 38 ++++++++++++++++++- output/typescript/types.ts | 4 +- specification/esql/query/QueryRequest.ts | 13 ++++++- 6 files changed, 115 insertions(+), 8 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index b2ac01c381..d6d8ca454d 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -8122,7 +8122,7 @@ "description": "A short version of the Accept header, e.g. json, yaml.", "deprecated": false, "schema": { - "type": "string" + "$ref": "#/components/schemas/esql.query:EsqlFormat" }, "style": "form" }, @@ -81917,6 +81917,19 @@ "head" ] }, + "esql.query:EsqlFormat": { + "type": "string", + "enum": [ + "csv", + "json", + "tsv", + "txt", + "yaml", + "cbor", + "smile", + "arrow" + ] + }, "esql._types:TableValuesContainer": { "type": "object", "properties": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index fe2784eaa4..b9ea2b9a5f 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -5307,7 +5307,7 @@ "description": "A short version of the Accept header, e.g. json, yaml.", "deprecated": false, "schema": { - "type": "string" + "$ref": "#/components/schemas/esql.query:EsqlFormat" }, "style": "form" }, @@ -53778,6 +53778,19 @@ "head" ] }, + "esql.query:EsqlFormat": { + "type": "string", + "enum": [ + "csv", + "json", + "tsv", + "txt", + "yaml", + "cbor", + "smile", + "arrow" + ] + }, "esql._types:TableValuesContainer": { "type": "object", "properties": { diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 18d56d754f..6506dfa896 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -17632,8 +17632,8 @@ "type": { "kind": "instance_of", "type": { - "name": "string", - "namespace": "_builtins" + "name": "EsqlFormat", + "namespace": "esql.query" } } }, @@ -91755,6 +91755,40 @@ "kind": "union_of" } }, + { + "kind": "enum", + "members": [ + { + "name": "csv" + }, + { + "name": "json" + }, + { + "name": "tsv" + }, + { + "name": "txt" + }, + { + "name": "yaml" + }, + { + "name": "cbor" + }, + { + "name": "smile" + }, + { + "name": "arrow" + } + ], + "name": { + "name": "EsqlFormat", + "namespace": "esql.query" + }, + "specLocation": "esql/query/QueryRequest.ts#L91-L100" + }, { "kind": "type_alias", "name": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 781a64b48c..cac3188efa 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -116074,6 +116074,40 @@ ] } }, + { + "kind": "enum", + "members": [ + { + "name": "csv" + }, + { + "name": "json" + }, + { + "name": "tsv" + }, + { + "name": "txt" + }, + { + "name": "yaml" + }, + { + "name": "cbor" + }, + { + "name": "smile" + }, + { + "name": "arrow" + } + ], + "name": { + "name": "EsqlFormat", + "namespace": "esql.query" + }, + "specLocation": "esql/query/QueryRequest.ts#L91-L100" + }, { "kind": "request", "attachedBehaviors": [ @@ -116214,8 +116248,8 @@ "type": { "kind": "instance_of", "type": { - "name": "string", - "namespace": "_builtins" + "name": "EsqlFormat", + "namespace": "esql.query" } } }, diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 0504cb7c33..949f0aca8c 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -10247,8 +10247,10 @@ export type EsqlTableValuesLongDouble = double | double[] export type EsqlTableValuesLongValue = long | long[] +export type EsqlQueryEsqlFormat = 'csv' | 'json' | 'tsv' | 'txt' | 'yaml' | 'cbor' | 'smile' | 'arrow' + export interface EsqlQueryRequest extends RequestBase { - format?: string + format?: EsqlQueryEsqlFormat delimiter?: string drop_null_columns?: boolean body?: { diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index 9494fcfc09..44ba0d0953 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -35,7 +35,7 @@ export interface Request extends RequestBase { /** * A short version of the Accept header, e.g. json, yaml. */ - format?: string + format?: EsqlFormat /** * The character to use between values within a CSV row. Only valid for the CSV format. */ @@ -87,3 +87,14 @@ export interface Request extends RequestBase { tables?: Dictionary> } } + +export enum EsqlFormat { + csv, + json, + tsv, + txt, + yaml, + cbor, + smile, + arrow +}