JSPM

@sschw/openapi-codegen-cli

2.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1404
  • Score
    100M100P100Q117989F
  • License MIT

OpenAPI Codegen cli

Package Exports

  • @sschw/openapi-codegen-cli
  • @sschw/openapi-codegen-cli/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sschw/openapi-codegen-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

This is a fork of the original project openapi-codegen by Fabien BERNARD.

OpenAPI Codegen

Getting started

  1. Add a openapi-codegen.config.ts at the root of your project
// openapi-codegen.config.ts
import { defineConfig } from "@sschw/openapi-codegen-cli";
import {
  generateSchemaTypes,
  generateReactQueryComponents,
} from "@sschw/openapi-codegen-typescript";

export default defineConfig({
  example: {
    from: {
      source: "github",
      owner: "fabien0102",
      repository: "openapi-codegen",
      ref: "main",
      specPath: "examples/spec.yaml",
    },

    // can be overridden from cli
    outputDir: "src/queries",

    to: async (context) => {
      const filenamePrefix = "example";

      // Generate all the schemas types (components & responses)
      const { schemasFiles } = await generateSchemaTypes(context, {
        filenamePrefix,
      });

      // Generate all react-query components
      await generateReactQueryComponents(context, {
        filenamePrefix,
        schemasFiles,
      });
    },
  },
});
  1. Expose openapi-codegen in your package.json
--- a/package.json
+++ b/package.json
   "scripts": {
+    "gen": "openapi-codegen",
   }
  1. Run the generator (example is the config key defined in the step 1)
$ yarn gen example
  1. Start playing! 🥳