Open api support ?

default discord avatar
olup9 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
    olup9 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;
      }
      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");
    })();
    
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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