Skip to content

Commit 9700819

Browse files
committed
Populate endpoint deprecation from request definition
1 parent ce9d54c commit 9700819

File tree

4 files changed

+75
-8
lines changed

4 files changed

+75
-8
lines changed

compiler/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import addDescription from './steps/add-description'
2727
import validateModel from './steps/validate-model'
2828
import addContentType from './steps/add-content-type'
2929
import readDefinitionValidation from './steps/read-definition-validation'
30+
import addDeprecation from './steps/add-deprecation'
3031

3132
const nvmrc = readFileSync(join(__dirname, '..', '..', '.nvmrc'), 'utf8')
3233
const nodejsMajor = process.version.split('.').shift()?.slice(1) ?? ''
@@ -67,6 +68,7 @@ const compiler = new Compiler(specsFolder, outputFolder)
6768
compiler
6869
.generateModel()
6970
.step(addInfo)
71+
.step(addDeprecation)
7072
.step(addContentType)
7173
.step(readDefinitionValidation)
7274
.step(validateRestSpec)

compiler/src/steps/add-deprecation.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import assert from 'assert'
21+
import * as model from '../model/metamodel'
22+
import { JsonSpec } from '../model/json-spec'
23+
24+
/**
25+
* Populates the `deprecation` field for endpoints from the value of the corresponding request definition.
26+
*/
27+
export default async function addContentType (model: model.Model, jsonSpec: Map<string, JsonSpec>): Promise<model.Model> {
28+
for (const endpoint of model.endpoints) {
29+
if (endpoint.deprecation != null) {
30+
continue
31+
}
32+
33+
if (endpoint.request == null) {
34+
continue
35+
}
36+
37+
const request = model.types.find(x => x.kind === 'request' && x.name === endpoint.request)
38+
if (request == null) {
39+
continue
40+
}
41+
42+
if (request.deprecation == null) {
43+
continue
44+
}
45+
46+
endpoint.deprecation = request.deprecation
47+
}
48+
49+
return model
50+
}

output/schema/schema.json

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

specification/_types/query_dsl/abstractions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ export class QueryContainer {
165165
* @doc_id query-dsl-geo-distance-query
166166
*/
167167
geo_distance?: GeoDistanceQuery
168+
/**
169+
* @deprecated 7.12.0 Use geo-shape instead.
170+
*/
168171
geo_polygon?: GeoPolygonQuery
169172
/**
170173
* Filter documents indexed using either the `geo_shape` or the `geo_point` type.

0 commit comments

Comments
 (0)