Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.action(async (api, outDir, generatorNames = Generators.ResourcesGenerator.name) => {
try {
const document = (await SwaggerParser.bundle(api)) as OpenAPIV3.Document
const references = await SwaggerParser.resolve(api)
if (document.openapi.startsWith('2')) {
throw new Error('Slushy currently only supports OpenApi v3 documents.')
}
const tsModule = new TSModule()
const generators: GeneratorConstructor[] = generatorNames
.split(',')
.map((generatorName: keyof typeof Generators) => Generators[generatorName])
if (!generators.every(Boolean)) {
throw new Error(`Invalid generator, only allowed values are: ${Object.keys(Generators).join(', ')}`)
}
const requiredGenerators = getRequiredGenerators(generators)
for (const Generator of requiredGenerators) {
const generator = new Generator()