How to use the swagger-parser.resolve function in swagger-parser

To help you get started, we’ve selected a few swagger-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aimed / slushy / codegen / src / index.ts View on Github external
.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()

swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis