Skip to content

Commit 383acc9

Browse files
Allow @ sign in @server_default annotation (#5664) (#5673)
* Allow @ sign in @server_default annotation * Fix lint * Run make contrib (cherry picked from commit 469fd6b) Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
1 parent 9ecc8f5 commit 383acc9

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

compiler/src/model/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,11 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
877877
assert(jsDocs, Array.isArray(value), 'The default value should be an array')
878878
property.serverDefault = value
879879
} else {
880+
// JSDoc prevents literal @ in values, but the at sign can be escaped
881+
if (value.startsWith('\\@')) {
882+
value = value.replace('\\@', '@')
883+
}
884+
880885
switch (property.type.type.name) {
881886
case 'boolean':
882887
assert(jsDocs, value === 'true' || value === 'false', `The default value for ${property.name} should be a boolean`)

docs/modeling-guide.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,18 @@ class Foo {
601601
}
602602
```
603603
604+
If you need an `@` sign, you can escape it:
605+
606+
```ts
607+
class Foo {
608+
/**
609+
* Field containing event timestamp.
610+
* @server_default \@timestamp
611+
*/
612+
timestamp_field?: Field
613+
}
614+
```
615+
604616
#### `@doc_id`
605617
606618
An identifier that can be used for generating the doc url in clients.

output/openapi/elasticsearch-openapi.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/eql/search/EqlSearchRequest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ export interface Request extends RequestBase {
120120
*/
121121
tiebreaker_field?: Field
122122
/**
123-
* Field containing event timestamp. Default "@timestamp"
123+
* Field containing event timestamp.
124+
* @server_default \@timestamp
124125
*/
125126
timestamp_field?: Field
126127
/**

specification/ingest/_types/Processors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ export class DateProcessor extends ProcessorBase {
789789
locale?: string
790790
/**
791791
* The field that will hold the parsed date.
792-
* @server_default `@timestamp`
792+
* @server_default \@timestamp
793793
*/
794794
target_field?: Field
795795
/**

0 commit comments

Comments
 (0)