Support for deprecated paths (#828)
* Updated code generation * API generation * Updated test
This commit is contained in:
committed by
delvedor
parent
dbfeb5d1a9
commit
12e88d6f87
@ -94,12 +94,6 @@ function buildDelete (opts) {
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['index'] == null)) {
|
||||
const err = new ConfigurationError('Missing required parameter of the url: index')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
|
||||
|
||||
@ -96,12 +96,6 @@ function buildIndex (opts) {
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
// check required url components
|
||||
if (params['id'] != null && (params['index'] == null)) {
|
||||
const err = new ConfigurationError('Missing required parameter of the url: index')
|
||||
return handleError(err, callback)
|
||||
}
|
||||
|
||||
// validate headers object
|
||||
if (options.headers != null && typeof options.headers !== 'object') {
|
||||
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
|
||||
|
||||
@ -111,6 +111,7 @@ function buildIndicesPutMapping (opts) {
|
||||
} else if ((index) != null && (type) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type)
|
||||
} else if ((type) != null) {
|
||||
<<<<<<< HEAD
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else if ((type) != null) {
|
||||
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
|
||||
@ -118,6 +119,15 @@ function buildIndicesPutMapping (opts) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
|
||||
=======
|
||||
path = '/' + '_mappings' + '/' + encodeURIComponent(type)
|
||||
} else if ((type) != null) {
|
||||
path = '/' + '_mapping' + '/' + encodeURIComponent(type)
|
||||
} else if ((index) != null) {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mapping'
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(index) + '/' + '_mappings'
|
||||
>>>>>>> 349b832... Support for deprecated paths (#828)
|
||||
}
|
||||
|
||||
// build request object
|
||||
|
||||
@ -101,9 +101,14 @@ function buildNodesHotThreads (opts) {
|
||||
} else if ((node_id || nodeId) != null) {
|
||||
path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads'
|
||||
} else if ((node_id || nodeId) != null) {
|
||||
<<<<<<< HEAD
|
||||
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads'
|
||||
} else if ((node_id || nodeId) != null) {
|
||||
=======
|
||||
>>>>>>> 349b832... Support for deprecated paths (#828)
|
||||
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads'
|
||||
} else if ((node_id || nodeId) != null) {
|
||||
path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads'
|
||||
} else {
|
||||
path = '/' + '_cluster' + '/' + 'nodes' + '/' + 'hotthreads'
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint camelcase: 0 */
|
||||
|
||||
'use strict'
|
||||
|
||||
const dedent = require('dedent')
|
||||
@ -33,6 +35,7 @@ const noPathValidation = [
|
||||
'explain',
|
||||
'get',
|
||||
'get_source',
|
||||
'index',
|
||||
'indices.get_alias',
|
||||
'indices.exists_alias',
|
||||
'indices.get_field_mapping',
|
||||
@ -40,6 +43,7 @@ const noPathValidation = [
|
||||
'indices.get_settings',
|
||||
'indices.put_mapping',
|
||||
'indices.stats',
|
||||
'delete',
|
||||
'nodes.info',
|
||||
'nodes.stats',
|
||||
'nodes.usage',
|
||||
@ -66,10 +70,16 @@ function generate (spec, common) {
|
||||
.replace(/_([a-z])/g, k => k[1].toUpperCase())
|
||||
|
||||
const methods = spec[api].methods
|
||||
const { paths, parts, params } = spec[api].url
|
||||
const { paths, deprecated_paths, parts, params } = spec[api].url
|
||||
const acceptedQuerystring = []
|
||||
const required = []
|
||||
|
||||
if (deprecated_paths) {
|
||||
for (const p of deprecated_paths) {
|
||||
paths.push(p.path)
|
||||
}
|
||||
}
|
||||
|
||||
for (const key in parts) {
|
||||
if (parts[key].required) {
|
||||
required.push(key)
|
||||
|
||||
@ -34,6 +34,9 @@ const esFolder = join(__dirname, '..', '..', 'elasticsearch')
|
||||
const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test')
|
||||
const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test')
|
||||
const customSkips = [
|
||||
// TODO: remove this once 'arbitrary_key' is implemented
|
||||
// https://github.com/elastic/elasticsearch/pull/41492
|
||||
'indices.split/30_copy_settings.yml',
|
||||
// skipping because we are booting ES with `discovery.type=single-node`
|
||||
// and this test will fail because of this configuration
|
||||
'nodes.stats/30_discovery.yml',
|
||||
|
||||
Reference in New Issue
Block a user