in packages/azure-openapi-validator/core/src/runner.ts [102:138]
async execute(swaggerPaths: string[], options: LintOptions, cb?: LintCallBack) {
const specsPromises = []
for (const spec of swaggerPaths) {
specsPromises.push(this.inventory.loadDocument(spec))
}
const documents = (await Promise.all(specsPromises)) as OpenapiDocument[]
const msgs: LintResultMessage[] = []
const sendMessage = (msg: LintResultMessage) => {
msgs.push(msg)
if (cb) {
cb(msg)
}
}
const runPromises = []
let runGlobalRuleFlag = false
for (const doc of documents) {
for (const scope of ["Global", "File"]) {
if (scope === "Global" && runGlobalRuleFlag) {
continue
} else {
runGlobalRuleFlag = true
}
const promise = this.runRules(
doc.getDocumentPath(),
doc.getObj(),
sendMessage,
options.openapiType,
await this.loader.getRuleSet(),
this.inventory,
scope as RuleScope
)
runPromises.push(promise)
}
}
await Promise.all(runPromises)
return msgs
}