UNPKG

api

Version:

Magical SDK generation from an OpenAPI definition 🪄

24 lines (23 loc) • 971 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; exports.__esModule = true; var typescript_1 = __importDefault(require("./languages/typescript")); function codegen(language, spec, specPath, identifier) { switch (language) { case 'js': throw new TypeError('An export format of CommonJS or ECMAScript is required for JavaScript compilation.'); case 'js-cjs': case 'js-esm': case 'ts': return new typescript_1["default"](spec, specPath, identifier, { outputJS: ['js-cjs', 'js-esm'].includes(language), // TS will always generate with ESM-like exports. compilerTarget: language === 'js-cjs' ? 'cjs' : 'esm' }); default: throw new TypeError("Unsupported language supplied: ".concat(language)); } } exports["default"] = codegen;