From 627e35549969733a51337f1ef7de1346a16a2f13 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Nov 2025 16:29:06 +0400 Subject: [PATCH 1/3] Allow @ sign in @server_default annotation --- compiler/src/model/utils.ts | 5 +++++ docs/modeling-guide.md | 12 ++++++++++++ output/schema/schema.json | 7 ++++--- specification/eql/search/EqlSearchRequest.ts | 3 ++- specification/ingest/_types/Processors.ts | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/compiler/src/model/utils.ts b/compiler/src/model/utils.ts index 3822274220..13d065287b 100644 --- a/compiler/src/model/utils.ts +++ b/compiler/src/model/utils.ts @@ -877,6 +877,11 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v assert(jsDocs, Array.isArray(value), 'The default value should be an array') property.serverDefault = value } else { + // JSDoc prevents literal @ in values, but the at sign can be escaped + if (value.startsWith("\\@")) { + value = value.replace("\\@", "@") + } + switch (property.type.type.name) { case 'boolean': assert(jsDocs, value === 'true' || value === 'false', `The default value for ${property.name} should be a boolean`) diff --git a/docs/modeling-guide.md b/docs/modeling-guide.md index 8f0ea182c7..73db4512a5 100644 --- a/docs/modeling-guide.md +++ b/docs/modeling-guide.md @@ -601,6 +601,18 @@ class Foo { } ``` +If you need an `@` sign, you can escape it: + +```ts +class Foo { + /** + * Field containing event timestamp. + * @server_default \@timestamp + */ + timestamp_field?: Field +} +``` + #### `@doc_id` An identifier that can be used for generating the doc url in clients. diff --git a/output/schema/schema.json b/output/schema/schema.json index 8ca95fe68d..82c950373f 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -141437,9 +141437,10 @@ } }, { - "description": "Field containing event timestamp. Default \"@timestamp\"", + "description": "Field containing event timestamp.", "name": "timestamp_field", "required": false, + "serverDefault": "@timestamp", "type": { "kind": "instance_of", "type": { @@ -141860,7 +141861,7 @@ } } ], - "specLocation": "eql/search/EqlSearchRequest.ts#L28-L178" + "specLocation": "eql/search/EqlSearchRequest.ts#L28-L179" }, { "kind": "response", @@ -186488,7 +186489,7 @@ "description": "The field that will hold the parsed date.", "name": "target_field", "required": false, - "serverDefault": "`@timestamp`", + "serverDefault": "@timestamp", "type": { "kind": "instance_of", "type": { diff --git a/specification/eql/search/EqlSearchRequest.ts b/specification/eql/search/EqlSearchRequest.ts index 8955ad7efa..50982d142f 100644 --- a/specification/eql/search/EqlSearchRequest.ts +++ b/specification/eql/search/EqlSearchRequest.ts @@ -120,7 +120,8 @@ export interface Request extends RequestBase { */ tiebreaker_field?: Field /** - * Field containing event timestamp. Default "@timestamp" + * Field containing event timestamp. + * @server_default \@timestamp */ timestamp_field?: Field /** diff --git a/specification/ingest/_types/Processors.ts b/specification/ingest/_types/Processors.ts index 0b3d08e272..4de6172cb3 100644 --- a/specification/ingest/_types/Processors.ts +++ b/specification/ingest/_types/Processors.ts @@ -789,7 +789,7 @@ export class DateProcessor extends ProcessorBase { locale?: string /** * The field that will hold the parsed date. - * @server_default `@timestamp` + * @server_default \@timestamp */ target_field?: Field /** From dca71e8208020cd6298fbed10400db92b9ce721c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Nov 2025 17:20:11 +0400 Subject: [PATCH 2/3] Fix lint --- compiler/src/model/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/model/utils.ts b/compiler/src/model/utils.ts index 13d065287b..ea61184934 100644 --- a/compiler/src/model/utils.ts +++ b/compiler/src/model/utils.ts @@ -878,8 +878,8 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v property.serverDefault = value } else { // JSDoc prevents literal @ in values, but the at sign can be escaped - if (value.startsWith("\\@")) { - value = value.replace("\\@", "@") + if (value.startsWith('\\@')) { + value = value.replace('\\@', '@') } switch (property.type.type.name) { From 087a661e18433b7b29b8afb15c3b6a83d08896df Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Nov 2025 17:20:19 +0400 Subject: [PATCH 3/3] Run make contrib --- output/openapi/elasticsearch-openapi.json | 5 +++-- output/openapi/elasticsearch-serverless-openapi.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 509724a275..2f76026b26 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -105440,7 +105440,7 @@ }, "target_field": { "description": "The field that will hold the parsed date.", - "default": "`@timestamp`", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field" @@ -147017,7 +147017,8 @@ ] }, "timestamp_field": { - "description": "Field containing event timestamp. Default \"@timestamp\"", + "description": "Field containing event timestamp.", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field" diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 4540c7f451..977d883d38 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -69266,7 +69266,7 @@ }, "target_field": { "description": "The field that will hold the parsed date.", - "default": "`@timestamp`", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field" @@ -89575,7 +89575,8 @@ ] }, "timestamp_field": { - "description": "Field containing event timestamp. Default \"@timestamp\"", + "description": "Field containing event timestamp.", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field"