diff --git a/compiler/src/model/utils.ts b/compiler/src/model/utils.ts index 3822274220..ea61184934 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/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" 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 /**