Skip to content

Commit b81acc0

Browse files
authored
obsolete/deprecation/g (#773)
1 parent 17a63de commit b81acc0

File tree

10 files changed

+53
-23
lines changed

10 files changed

+53
-23
lines changed

compiler/model/utils.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -491,16 +491,15 @@ export function modelProperty (declaration: PropertySignature | PropertyDeclarat
491491
}
492492

493493
/**
494-
* Pulls @obsolete and @obsolete_description from types and properties
494+
* Pulls @deprecated from types and properties
495495
*/
496-
function setObsolete (type: model.BaseType | model.Property | model.EnumMember, tags: Record<string, string>): void {
497-
const obsolete = tags.obsolete
498-
const description = tags.obsolete_description
499-
if (obsolete !== undefined) {
500-
type.deprecation = { version: obsolete, description: description }
496+
function setDeprecated (type: model.BaseType | model.Property | model.EnumMember, tags: Record<string, string>, jsDocs: JSDoc[]): void {
497+
if (tags.deprecated !== undefined) {
498+
const [version, ...description] = tags.deprecated.split(' ')
499+
assert(jsDocs, semver.valid(version), 'Invalid semver value')
500+
type.deprecation = { version, description: description.join(' ') }
501501
}
502-
delete tags.obsolete
503-
delete tags.obsolete_description
502+
delete tags.deprecated
504503
}
505504

506505
/**
@@ -515,7 +514,7 @@ function setTags<TType extends model.BaseType | model.Property | model.EnumMembe
515514
): void {
516515
if (Object.keys(tags).length === 0) return
517516

518-
setObsolete(type, tags)
517+
setDeprecated(type, tags, jsDocs)
519518
const badTags = Object.keys(tags).filter(tag => !validTags.includes(tag))
520519
assert(
521520
jsDocs,

docs/modeling-guide.md

+24
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,27 @@ export interface Request extends RequestBase {
516516
...
517517
}
518518
```
519+
520+
#### `@deprecated`
521+
522+
Use if an endpoint or property is deprecated, you should add the version as well.
523+
524+
```ts
525+
class Foo {
526+
bar: string
527+
/** @deprecated 7.0.0 */
528+
baz?: string
529+
faz: string
530+
}
531+
```
532+
533+
You can also add an optional description:
534+
535+
```ts
536+
class Foo {
537+
bar: string
538+
/** @deprecated 7.0.0 'baz' has been deprecated, use 'bar' instead */
539+
baz?: string
540+
faz: string
541+
}
542+
```

output/schema/schema.json

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_global/get/GetResponse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Response<TDocument> {
3838
_routing?: string
3939
_seq_no?: SequenceNumber
4040
_source?: TDocument
41-
/** @obsolete 7.0.0 */
41+
/** @deprecated 7.0.0 */
4242
_type?: Type
4343
_version?: VersionNumber
4444
}

specification/_global/scroll/ScrollRequest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { Time } from '@_types/Time'
2828
*/
2929
export interface Request extends RequestBase {
3030
path_parts: {
31-
/** @obsolete 7.0.0 */
31+
/** @deprecated 7.0.0 */
3232
scroll_id?: Id
3333
}
3434
query_parameters: {
@@ -38,7 +38,7 @@ export interface Request extends RequestBase {
3838
* @server_default 1d
3939
*/
4040
scroll?: Time
41-
/** @obsolete 7.0.0 */
41+
/** @deprecated 7.0.0 */
4242
scroll_id?: ScrollId
4343
/**
4444
* If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object.

specification/_types/query_dsl/abstractions.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import {
100100
export class QueryContainer {
101101
bool?: BoolQuery
102102
boosting?: BoostingQuery
103-
/** @obsolete 7.3.0 */
103+
/** @deprecated 7.3.0 */
104104
common?: SingleKeyDictionary<Field, CommonTermsQuery>
105105
/** @since 7.13.0 */
106106
combined_fields?: CombinedFieldsQuery
@@ -154,8 +154,7 @@ export class QueryContainer {
154154
wildcard?: SingleKeyDictionary<Field, WildcardQuery>
155155

156156
/**
157-
* @obsolete 7.0.0
158-
* @obsolete_description https://www.elastic.co/guide/en/elasticsearch/reference/7.x/removal-of-types.html
157+
* @deprecated 7.0.0 https://www.elastic.co/guide/en/elasticsearch/reference/7.x/removal-of-types.html
159158
*/
160159
type?: TypeQuery
161160
}

specification/_types/query_dsl/fulltext.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class MatchQuery extends QueryBase {
135135
analyzer?: string
136136
/** @server_default true */
137137
auto_generate_synonyms_phrase_query?: boolean
138-
/** @obsolete 7.3.0 */
138+
/** @deprecated 7.3.0 */
139139
cutoff_frequency?: double
140140
fuzziness?: Fuzziness
141141
fuzzy_rewrite?: MultiTermQueryRewrite
@@ -192,7 +192,7 @@ export class MultiMatchQuery extends QueryBase {
192192
analyzer?: string
193193
/** @server_default true */
194194
auto_generate_synonyms_phrase_query?: boolean
195-
/** @obsolete 7.3.0 */
195+
/** @deprecated 7.3.0 */
196196
cutoff_frequency?: double
197197
fields?: Fields
198198
fuzziness?: Fuzziness

specification/_types/query_dsl/geo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class BoundingBox {
5151
export class GeoBoundingBoxQuery
5252
extends QueryBase
5353
implements AdditionalProperty<Field, BoundingBox> {
54-
/** @obsolete 7.14.0 */
54+
/** @deprecated 7.14.0 */
5555
type?: GeoExecution
5656
/** @server_default 'strict' */
5757
validation_method?: GeoValidationMethod
@@ -77,7 +77,7 @@ export class GeoPolygonPoints {
7777
points: GeoLocation[]
7878
}
7979

80-
/** @obsolete 7.12.0 Use geo-shape instead. */
80+
/** @deprecated 7.12.0 Use geo-shape instead. */
8181
export class GeoPolygonQuery
8282
extends QueryBase
8383
implements AdditionalProperty<Field, GeoPolygonPoints> {

specification/ml/close_job/MlCloseJobRequest.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ export interface Request extends RequestBase {
4747
*/
4848
allow_no_match?: boolean
4949
/**
50-
* @obsolete 7.10.0
51-
* @obsolete_description Use `allow_no_match` instead.
50+
* @deprecated 7.10.0 Use `allow_no_match` instead.
5251
*/
5352
allow_no_jobs?: boolean
5453
/**

specification/monitoring/bulk/BulkMonitoringRequest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { OperationContainer } from '@global/bulk/types'
2929
export interface Request<TSource> extends RequestBase {
3030
path_parts: {
3131
/**
32-
* @obsolete 7.0.0
32+
* @deprecated 7.0.0
3333
*/
3434
type?: string
3535
}

0 commit comments

Comments
 (0)