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 72e119780e..157bcdaf5d 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -104362,7 +104362,7 @@ }, "target_field": { "description": "The field that will hold the parsed date.", - "default": "`@timestamp`", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field" @@ -145801,7 +145801,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 988706a0a6..3cb9fe3c05 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -67784,7 +67784,7 @@ }, "target_field": { "description": "The field that will hold the parsed date.", - "default": "`@timestamp`", + "default": "@timestamp", "allOf": [ { "$ref": "#/components/schemas/_types.Field" @@ -88004,7 +88004,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 aa9d2ae634..49047b7377 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -139693,9 +139693,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": { @@ -140097,7 +140098,7 @@ } } ], - "specLocation": "eql/search/EqlSearchRequest.ts#L28-L166" + "specLocation": "eql/search/EqlSearchRequest.ts#L28-L167" }, { "kind": "response", @@ -181229,7 +181230,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 7365746f20..a825f16e65 100644 --- a/specification/eql/search/EqlSearchRequest.ts +++ b/specification/eql/search/EqlSearchRequest.ts @@ -108,7 +108,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 1455df044a..0236471f3d 100644 --- a/specification/ingest/_types/Processors.ts +++ b/specification/ingest/_types/Processors.ts @@ -785,7 +785,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 /**