Open api support ?

default discord avatar
olup
last month
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.

  • default discord avatar
    olup
    last month

    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");
    })();
    
Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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