Skip to content

Open api support ? #3762

Closed Answered by olup
olup asked this question in Q&A
Discussion options

You must be logged in to vote

Actually it seem to work

import fs from "fs/promises";
import path from "path";

import { createDocument, Options } from "payload-openapi";
import loadConfig from "payload/dist/config/load";

(async (
  configPath?: string,
  outputPath = "doc/spec.json",
  options?: Options
) => {
  if (configPath) {
    process.env.PAYLOAD_CONFIG_PATH = configPath;
  }
  console.log("????");

  const config = await loadConfig();
  const apiDocs = await createDocument(config, options);

  await fs.mkdir(path.dirname(outputPath), { recursive: true });
  await fs.writeFile(outputPath, JSON.stringify(apiDocs, null, 2), "utf-8");
})();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by olup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant