Skip to content

Commit 00b6e32

Browse files
authored
1 parent 51a6f24 commit 00b6e32

File tree

392 files changed

+1796
-2582
lines changed

Some content is hidden

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

392 files changed

+1796
-2582
lines changed

compiler/src/model/build-model.ts

+15-21
Original file line numberDiff line numberDiff line change
@@ -313,34 +313,28 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
313313
body: { kind: 'no_body' }
314314
}
315315

316-
for (const status of declaration.getMembers()) {
316+
for (const member of declaration.getMembers()) {
317+
// we are visiting `path_parts, `query_parameters` or `body`
317318
assert(
318-
status,
319-
Node.isPropertyDeclaration(status) || Node.isPropertySignature(status),
319+
member,
320+
Node.isPropertyDeclaration(member) || Node.isPropertySignature(member),
320321
'Class and interfaces can only have property declarations or signatures'
321322
)
322-
status.getTypeNode()?.forEachChild(child => {
323-
assert(
324-
child,
325-
Node.isPropertySignature(child) || Node.isPropertyDeclaration(child),
326-
`Children should be ${ts.SyntaxKind[ts.SyntaxKind.PropertySignature]} or ${ts.SyntaxKind[ts.SyntaxKind.PropertyDeclaration]} but is ${ts.SyntaxKind[child.getKind()]} instead`
327-
)
328-
const property = visitRequestOrResponseProperty(child)
329-
if (property.name === 'body') {
330-
// the body can either by a value (eg Array<string> or an object with properties)
331-
if (property.valueOf != null) {
332-
if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') {
333-
type.body = { kind: 'no_body' }
334-
} else {
335-
type.body = { kind: 'value', value: property.valueOf }
336-
}
323+
const property = visitRequestOrResponseProperty(member)
324+
if (property.name === 'body') {
325+
// the body can either by a value (eg Array<string> or an object with properties)
326+
if (property.valueOf != null) {
327+
if (property.valueOf.kind === 'instance_of' && property.valueOf.type.name === 'Void') {
328+
type.body = { kind: 'no_body' }
337329
} else {
338-
type.body = { kind: 'properties', properties: property.properties }
330+
type.body = { kind: 'value', value: property.valueOf }
339331
}
340332
} else {
341-
assert(child, false, 'Response.body is the only Response property supported')
333+
type.body = { kind: 'properties', properties: property.properties }
342334
}
343-
})
335+
} else {
336+
assert(member, false, 'Response.body is the only Response property supported')
337+
}
344338
}
345339
}
346340

0 commit comments

Comments
 (0)