// @ts-check
import path from "node:path";
import fs from "node:fs/promises";
import { cwd } from "node:process";
import { validate } from "@hyperjump/json-schema/openapi-3-1";
import YAML from "yaml";
import { parseConfiguration } from "../configs/parse-config.js";

const schemaPath = path.join(cwd(), "..", "src", "pages", "api", "schema.yaml");

run().catch((error) => {
  console.error(error);
  process.exitCode = 1;
  process.exit();
});

async function run() {
  parseConfiguration();
  // const fileContent = await fs.readFile(schemaPath, { encoding: "utf8" });
  // const parsedSchema = YAML.parse(fileContent)
  // const output = await validate(
  //   "https://spec.openapis.org/oas/3.1/schema-base",
  //   parsedSchema,
  //   // the library doesn't support values beyond `"FLAG"` and `"BASIC"`
  //   // but it's the only library in js which can validate OpenAPI 3.1 schemas
  //   "BASIC"
  // );

  // if (!output.valid) {
  //   throw new Error("Failed to validate OpenAPI Schema.")
  // }
}
