Skip to content

Commit 92760d4

Browse files
authored
Expand body identifier use (#756)
1 parent 5d8a05f commit 92760d4

File tree

11 files changed

+35
-73
lines changed

11 files changed

+35
-73
lines changed

compiler/model/build-model.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,21 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
249249
if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') {
250250
assert(member, false, 'There is no need to use Void in requets definitions, just remove the body declaration.')
251251
} else {
252-
type.body = { kind: 'value', value: property.valueOf }
253-
const openGenerics = declaration.getTypeParameters().map(modelGenerics)
254-
if ((property.valueOf.kind === 'instance_of' && openGenerics.includes(property.valueOf.type.name)) ||
255-
property.valueOf.kind === 'array_of') {
256-
const tags = parseJsDocTags(member.getJsDocs())
257-
assert(
258-
member,
259-
tags.identifier != null,
260-
'You should configure a body @identifier'
261-
)
262-
assert(
263-
member.getJsDocs(),
264-
!pathAndQueryProperties.includes(tags.identifier),
265-
`The identifier '${tags.identifier}' already exists as a property in the path or query.`
266-
)
267-
type.body.identifier = tags.identifier
252+
const tags = parseJsDocTags(member.getJsDocs())
253+
assert(
254+
member,
255+
tags.identifier != null,
256+
'You should configure a body @identifier'
257+
)
258+
assert(
259+
member.getJsDocs(),
260+
!pathAndQueryProperties.includes(tags.identifier),
261+
`The identifier '${tags.identifier}' already exists as a property in the path or query.`
262+
)
263+
type.body = {
264+
kind: 'value',
265+
value: property.valueOf,
266+
identifier: tags.identifier
268267
}
269268
}
270269
} else if (Array.isArray(property.properties)) {

output/schema/schema.json

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

output/schema/validation-errors.json

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

output/typescript/types.ts

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/autoscaling/put_autoscaling_policy/PutAutoscalingPolicyRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ export interface Request extends RequestBase {
3030
path_parts: {
3131
name: Name
3232
}
33+
/** @identifier policy */
3334
body: AutoscalingPolicy
3435
}

specification/indices/put_settings/IndicesPutSettingsRequest.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ export interface Request extends RequestBase {
4040
preserve_existing?: boolean
4141
timeout?: Time
4242
}
43-
body: IndexSettingsBody
44-
}
45-
46-
export class IndexSettingsBody extends IndexSettings {
47-
settings?: IndexSettings
43+
/** @identifier settings */
44+
body: IndexSettings
4845
}

specification/indices/simulate_template/IndicesSimulateTemplateRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ export interface Request extends RequestBase {
4444
*/
4545
master_timeout?: Time
4646
}
47+
/** @identifier template */
4748
body?: IndexTemplate
4849
}

specification/logstash/put_pipeline/LogstashPutPipelineRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ export interface Request extends RequestBase {
3030
path_parts: {
3131
id: Id
3232
}
33+
/** @identifier pipeline */
3334
body: Pipeline
3435
}

specification/ml/validate_detector/MlValidateDetectorRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ import { RequestBase } from '@_types/Base'
2727
* @stability stable
2828
*/
2929
export interface Request extends RequestBase {
30+
/** @identifier detector */
3031
body?: Detector
3132
}

specification/rollup/rollup/RollupRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ export interface Request extends RequestBase {
3131
index: IndexName
3232
rollup_index: IndexName
3333
}
34+
/** @identifier config */
3435
body?: UserDefinedValue // TODO: This API is experimental and no docs exist describing it. Requires reverse engineering if made stable
3536
}

specification/security/put_privileges/SecurityPutPrivilegesRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ export interface Request extends RequestBase {
3232
query_parameters: {
3333
refresh?: Refresh
3434
}
35+
/** @identifier privileges */
3536
body?: Dictionary<string, Dictionary<string, Actions>>
3637
}

0 commit comments

Comments
 (0)