How to use the swagger-typescript-codegen.CodeGen function in swagger-typescript-codegen

To help you get started, we’ve selected a few swagger-typescript-codegen 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 saucelabs / node-saucelabs / scripts / generate-typings.js View on Github external
const fs = require('fs')
const path = require('path')
const changeCase = require('change-case')
const CodeGen = require('swagger-typescript-codegen').CodeGen
const prettier = require('prettier')

function generateTypingsForApi(file) {
    const swagger = JSON.parse(fs.readFileSync(file, 'UTF-8'))
    const definitions = CodeGen.getTypescriptCode({
        className: 'SauceLabs',
        swagger,
        template: {
            class: fs.readFileSync('./scripts/class-definitions.mustache', 'utf-8'),
            method: fs.readFileSync('./scripts/method.mustache', 'utf-8'),
        }
    })
    const methods = CodeGen.getTypescriptCode({
        className: 'SauceLabs',
        swagger,
        template: {

swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.

Apache-2.0
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis