Files

20 lines
521 B
JavaScript
Raw Permalink Normal View History

2025-09-02 21:43:00 +10:00
#!/usr/bin/node
2024-10-10 15:53:11 +10:00
2025-09-02 21:43:00 +10:00
import SwaggerParser from "@apidevtools/swagger-parser";
import chalk from "chalk";
import { getCompiledSchema } from "./schema/index.js";
const log = console.log;
getCompiledSchema().then(async (swaggerJSON) => {
2024-10-10 15:53:11 +10:00
try {
const api = await SwaggerParser.validate(swaggerJSON);
2025-09-02 21:43:00 +10:00
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
log(chalk.green(" Schema is valid"));
2024-10-10 15:53:11 +10:00
} catch (e) {
console.error(e);
2025-09-02 21:43:00 +10:00
log(chalk.red("", e.message), "\n");
2024-10-10 15:53:11 +10:00
process.exit(1);
}
});