Open api support ?

default discord avatar
olup7 months ago
1 1

I saw there is an openapi plugin for payload that unfortunately does not seem to support v2. Is there anything else that I would have missed ? Cheers.

  • Selected Answer
    default discord avatar
    olup7 months ago

    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;
      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");
Star on GitHub


Chat on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.