Files
NPMplus/backend/validate-schema.js

17 lines
464 B
JavaScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
import SwaggerParser from "@apidevtools/swagger-parser";
import { getCompiledSchema } from "./schema/index.js";
getCompiledSchema().then(async (swaggerJSON) => {
try {
const api = await SwaggerParser.validate(swaggerJSON);
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
console.log(" Schema is valid");
} catch (e) {
console.error(e);
console.log("", e.message, "\n");
process.exit(1);
}
});