Skip to content

Commit 97cd4a6

Browse files
committed
compiler: validate types found only in exceptions
1 parent d506a99 commit 97cd4a6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

compiler/src/steps/validate-model.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import * as model from '../model/metamodel'
2121
import { ValidationErrors } from '../validation-errors'
2222
import { JsonSpec } from '../model/json-spec'
2323
import assert from 'assert'
24-
import { TypeName } from '../model/metamodel'
24+
import { ResponseException, TypeName } from '../model/metamodel'
2525

2626
enum TypeDefKind {
2727
type,
@@ -497,6 +497,23 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
497497
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
498498
throw new Error(`Unknown kind: ${typeDef.body.kind}`)
499499
}
500+
501+
if (typeDef.exceptions) {
502+
for (const ex of typeDef.exceptions) {
503+
switch (ex.body.kind) {
504+
case 'properties':
505+
validateProperties(ex.body.properties, new Set<string>(), new Set<string>())
506+
break
507+
case 'value':
508+
validateValueOf(ex.body.value, new Set<string>())
509+
break
510+
case 'no_body':
511+
// Nothing to validate
512+
break
513+
}
514+
}
515+
}
516+
500517
context.pop()
501518
}
502519

0 commit comments

Comments
 (0)