Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
check-openapi: Use low-level YAML parser.
Anders Kaseorg7af2647d64cf
diff --git a/tools/check-openapi b/tools/check-openapiindex c30ed98a81b..555549c574b 100755--- a/tools/check-openapi+++ b/tools/check-openapi@@ -8,12 +8,17 @@ const Diff = require("diff");const ExampleValidator = require("openapi-examples-validator");const Prettier = require("prettier");const SwaggerParser = require("swagger-parser");-const {LineCounter, Scalar, YAMLMap, YAMLSeq, parseDocument, visit} = require("yaml");+const {Composer, LineCounter, Parser, Scalar, YAMLMap, YAMLSeq, visit} = require("yaml");async function checkFile(file) {const yaml = await fs.promises.readFile(file, "utf8");const lineCounter = new LineCounter();- const doc = parseDocument(yaml, {lineCounter});+ const tokens = [...new Parser(lineCounter.addNewLine).parse(yaml)];+ const docs = [...new Composer().compose(tokens)];+ if (docs.length !== 1) {+ return;+ }+ const [doc] = docs;if (doc.errors.length > 0) {for (const error of doc.errors) {console.error("%s: %s", file, error.message);