Skip to content

Commit 9b3d893

Browse files
authored
Add additional compiler warnings (#628)
* Cleanup spec * Add additional compiler warnings
1 parent 6e3e382 commit 9b3d893

File tree

103 files changed

+23
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+23
-152
lines changed

compiler/model/build-model.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
180180
)
181181
}
182182

183-
let bodyWasSet = false
184-
185183
// Request and Response definitions needs to be handled
186184
// differently from normal classes
187185
if (name === 'Request' || name === 'Response') {
@@ -240,15 +238,16 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
240238
`The property '${part.name}' does not exist in the rest-api-spec ${namespace} url template`
241239
)
242240
}
241+
assert(member, property.properties.length > 0, 'There is no need to declare an empty object path_parts, just remove the path_parts declaration.')
243242
type.path = property.properties
244243
} else if (property.name === 'query_parameters') {
244+
assert(member, property.properties.length > 0, 'There is no need to declare an empty object query_parameters, just remove the query_parameters declaration.')
245245
type.query = property.properties
246246
} else if (property.name === 'body') {
247-
bodyWasSet = true
248247
// the body can either be a value (eg Array<string> or an object with properties)
249248
if (property.valueOf != null) {
250249
if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') {
251-
type.body = { kind: 'no_body' }
250+
assert(member, false, 'There is no need to use Void in requets definitions, just remove the body declaration.')
252251
} else {
253252
type.body = { kind: 'value', value: property.valueOf }
254253
const openGenerics = declaration.getTypeParameters().map(modelGenerics)
@@ -268,7 +267,8 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
268267
type.body.identifier = tags.identifier
269268
}
270269
}
271-
} else if (property.properties.length > 0) {
270+
} else if (Array.isArray(property.properties)) {
271+
assert(member, property.properties.length > 0, 'There is no need to declare an empty object body, just remove the body declaration.')
272272
type.body = { kind: 'properties', properties: property.properties }
273273
}
274274
} else {
@@ -291,7 +291,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
291291
)
292292
const property = visitRequestOrResponseProperty(member)
293293
if (property.name === 'body') {
294-
bodyWasSet = true
295294
// the body can either by a value (eg Array<string> or an object with properties)
296295
if (property.valueOf != null) {
297296
if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') {
@@ -341,10 +340,15 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
341340
}
342341

343342
// If the body wasn't set and we have a parent class, then it's a property body with no additional properties
344-
if (!bodyWasSet && type.inherits != null) {
343+
if (type.body.kind === 'no_body' && type.inherits != null) {
345344
const parent = type.inherits.type
346345
// RequestBase is special as it's a "marker" base class that doesn't imply a property body type. We should get rid of it.
347-
if (!(parent.name === 'RequestBase' && parent.namespace === '_types')) {
346+
if (parent.name === 'RequestBase' && parent.namespace === '_types') {
347+
// nothing to do
348+
// CatRequestBase is special as it's a "marker" base class that doesn't imply a property body type. We should get rid of it.
349+
} else if (parent.name === 'CatRequestBase' && parent.namespace === 'cat._types') {
350+
// nothing to do
351+
} else {
348352
type.body = { kind: 'properties', properties: new Array<model.Property>() }
349353
}
350354
}

specification/_global/clear_scroll/ClearScrollRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface Request extends RequestBase {
2929
path_parts?: {
3030
scroll_id?: Ids
3131
}
32-
query_parameters?: {}
3332
body?: {
3433
scroll_id?: Ids
3534
}

specification/_global/close_point_in_time/ClosePointInTimeRequest.ts

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import { Id } from '@_types/common'
2626
* @stability TODO
2727
*/
2828
export interface Request extends RequestBase {
29-
path_parts?: {}
30-
query_parameters?: {}
3129
body?: {
3230
id: Id
3331
}

specification/_global/delete/DeleteRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,4 @@ export interface Request extends RequestBase {
5353
version_type?: VersionType
5454
wait_for_active_shards?: WaitForActiveShards
5555
}
56-
body?: {}
5756
}

specification/_global/delete_by_query_rethrottle/DeleteByQueryRethrottleRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends RequestBase {
3333
query_parameters?: {
3434
requests_per_second?: long
3535
}
36-
body?: {}
3736
}

specification/_global/delete_script/DeleteScriptRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ export interface Request extends RequestBase {
3434
master_timeout?: Time
3535
timeout?: Time
3636
}
37-
body?: {}
3837
}

specification/_global/exists/DocumentExistsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,4 @@ export interface Request extends RequestBase {
5151
version?: VersionNumber
5252
version_type?: VersionType
5353
}
54-
body?: {}
5554
}

specification/_global/exists_source/SourceExistsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,4 @@ export interface Request extends RequestBase {
5050
version?: VersionNumber
5151
version_type?: VersionType
5252
}
53-
body?: {}
5453
}

specification/_global/open_point_in_time/OpenPointInTimeRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends RequestBase {
3333
query_parameters?: {
3434
keep_alive?: Time
3535
}
36-
body?: {}
3736
}

specification/_global/ping/PingRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { RequestBase } from '@_types/Base'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends RequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends RequestBase {}

specification/_global/reindex_rethrottle/ReindexRethrottleRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends RequestBase {
3333
query_parameters?: {
3434
requests_per_second?: long
3535
}
36-
body?: {}
3736
}

specification/_global/render_search_template/RenderSearchTemplateRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export interface Request extends RequestBase {
3131
path_parts?: {
3232
id?: Id
3333
}
34-
query_parameters?: {}
3534
body?: {
3635
file?: string
3736
params?: Dictionary<string, UserDefinedValue>

specification/_global/scripts_painless_execute/ExecutePainlessScriptRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { PainlessContextSetup } from './types'
2727
* @stability TODO
2828
*/
2929
export interface Request extends RequestBase {
30-
query_parameters?: {}
3130
body?: {
3231
context?: string
3332
context_setup?: PainlessContextSetup

specification/_global/update_by_query_rethrottle/UpdateByQueryRethrottleRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends RequestBase {
3333
query_parameters?: {
3434
requests_per_second?: long
3535
}
36-
body?: {}
3736
}

specification/async_search/get/AsyncSearchGetRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ export interface Request extends RequestBase {
3535
typed_keys?: boolean
3636
wait_for_completion_timeout?: Time
3737
}
38-
body?: {}
3938
}

specification/async_search/status/AsyncSearchStatusRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ export interface Request extends RequestBase {
2929
path_parts?: {
3030
id: Id
3131
}
32-
query_parameters?: {}
3332
}

specification/cat/aliases/CatAliasesRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
expand_wildcards?: ExpandWildcards
3434
}
35-
body?: {}
3635
}

specification/cat/allocation/CatAllocationRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
bytes?: Bytes
3434
}
35-
body?: {}
3635
}

specification/cat/count/CatCountRequest.ts

-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ export interface Request extends CatRequestBase {
2929
path_parts?: {
3030
index?: Indices
3131
}
32-
query_parameters?: {}
33-
body?: {}
3432
}

specification/cat/fielddata/CatFielddataRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
bytes?: Bytes
3434
}
35-
body?: {}
3635
}

specification/cat/health/CatHealthRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ export interface Request extends CatRequestBase {
2929
include_timestamp?: boolean
3030
ts?: boolean
3131
}
32-
body?: {}
3332
}

specification/cat/help/CatHelpRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/indices/CatIndicesRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ export interface Request extends CatRequestBase {
3636
include_unloaded_segments?: boolean
3737
pri?: boolean
3838
}
39-
body?: {}
4039
}

specification/cat/master/CatMasterRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/ml_data_frame_analytics/CatDataFrameAnalyticsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends CatRequestBase {
3333
allow_no_match?: boolean
3434
bytes?: Bytes
3535
}
36-
body?: {}
3736
}

specification/cat/ml_datafeeds/CatDatafeedsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
allow_no_datafeeds?: boolean
3434
}
35-
body?: {}
3635
}

specification/cat/ml_jobs/CatJobsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ export interface Request extends CatRequestBase {
3333
allow_no_jobs?: boolean
3434
bytes?: Bytes
3535
}
36-
body?: {}
3736
}

specification/cat/ml_trained_models/CatTrainedModelsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ export interface Request extends CatRequestBase {
3636
from?: integer
3737
size?: integer
3838
}
39-
body?: {}
4039
}

specification/cat/nodeattrs/CatNodeAttributesRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/nodes/CatNodesRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ export interface Request extends CatRequestBase {
3030
bytes?: Bytes
3131
full_id?: boolean | string
3232
}
33-
body?: {}
3433
}

specification/cat/pending_tasks/CatPendingTasksRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/plugins/CatPluginsRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 0.0.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/recovery/CatRecoveryRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ export interface Request extends CatRequestBase {
3434
bytes?: Bytes
3535
detailed?: boolean
3636
}
37-
body?: {}
3837
}

specification/cat/repositories/CatRepositoriesRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { CatRequestBase } from '@cat/_types/CatBase'
2424
* @since 2.1.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends CatRequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends CatRequestBase {}

specification/cat/segments/CatSegmentsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
bytes?: Bytes
3434
}
35-
body?: {}
3635
}

specification/cat/shards/CatShardsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
bytes?: Bytes
3434
}
35-
body?: {}
3635
}

specification/cat/snapshots/CatSnapshotsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
ignore_unavailable?: boolean
3434
}
35-
body?: {}
3635
}

specification/cat/tasks/CatTasksRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
node_id?: string[]
3333
parent_task?: long
3434
}
35-
body?: {}
3635
}

specification/cat/templates/CatTemplatesRequest.ts

-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ export interface Request extends CatRequestBase {
2929
path_parts?: {
3030
name?: Name
3131
}
32-
query_parameters?: {}
33-
body?: {}
3432
}

specification/cat/thread_pool/CatThreadPoolRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends CatRequestBase {
3232
query_parameters?: {
3333
size?: Size | boolean
3434
}
35-
body?: {}
3635
}

specification/cat/transforms/CatTransformsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ export interface Request extends CatRequestBase {
3535
from?: integer
3636
size?: integer
3737
}
38-
body?: {}
3938
}

specification/ccr/put_auto_follow_pattern/PutAutoFollowPatternRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface Request extends RequestBase {
3333
path_parts?: {
3434
name: Name // param name in docs: auto_follow_pattern_name
3535
}
36-
query_parameters?: {}
3736
body?: {
3837
remote_cluster: string
3938
follow_index_pattern?: IndexPattern

specification/cluster/exists_component_template/ClusterComponentTemplateExistsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ export interface Request extends RequestBase {
4949
*/
5050
local?: boolean
5151
}
52-
body?: {}
5352
}

specification/cluster/get_settings/ClusterGetSettingsRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends RequestBase {
3232
master_timeout?: Time
3333
timeout?: Time
3434
}
35-
body?: {}
3635
}

specification/cluster/pending_tasks/ClusterPendingTasksRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ export interface Request extends RequestBase {
3131
/** @server_default 30s */
3232
master_timeout?: Time
3333
}
34-
body?: {}
3534
}

specification/enrich/execute_policy/ExecuteEnrichPolicyRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export interface Request extends RequestBase {
3232
query_parameters?: {
3333
wait_for_completion?: boolean
3434
}
35-
body?: {}
3635
}

specification/enrich/stats/EnrichStatsRequest.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ import { RequestBase } from '@_types/Base'
2424
* @since 7.5.0
2525
* @stability TODO
2626
*/
27-
export interface Request extends RequestBase {
28-
query_parameters?: {}
29-
body?: {}
30-
}
27+
export interface Request extends RequestBase {}

specification/indices/add_block/IndicesAddBlockRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export interface Request extends RequestBase {
3838
master_timeout?: Time // default: 30s
3939
timeout?: Time // default: 30s
4040
}
41-
body?: {}
4241
}
4342

4443
export enum IndicesBlockOptions {

specification/indices/analyze/IndicesAnalyzeRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface Request extends RequestBase {
3333
path_parts?: {
3434
index?: IndexName
3535
}
36-
query_parameters?: {}
3736
body?: {
3837
analyzer?: string
3938
attributes?: string[]

specification/indices/clear_cache/IndicesIndicesClearCacheRequest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ export interface Request extends RequestBase {
3838
query?: boolean
3939
request?: boolean
4040
}
41-
body?: {}
4241
}

0 commit comments

Comments
 (0)