kahirokunn / swagger-camelcase-properties-to-snakecase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swagger-camelcase-properties-to-snakecase

swagger camelcase properties to snakecase

Install

$ npm install -g swagger-camelcase-properties-to-snakecase

Usage

stdio

cat __tests__/nestedSwagger.yaml | npx swagger-camelcase-properties-to-snakecase

fix file

npx swagger-camelcase-properties-to-snakecase __tests__/nestedSwagger.yaml

Spec

import * as fs from 'fs'
import * as path from 'path'
import { swaggerCamelCasePropertiesToSnakeCase } from 'swagger-camelcase-properties-to-snakecase';

const nestedSwaggerYaml = fs.readFileSync(path.resolve(__dirname, './nestedSwagger.yaml')).toString().trim()
const snakeCaseNestedSwagger = fs.readFileSync(path.resolve(__dirname, './snakeCaseNestedSwagger.yaml')).toString().trim()

test('nested properties', () => {
  const result = swaggerCamelCasePropertiesToSnakeCase(nestedSwaggerYaml).trim()

  expect(result).toBe(snakeCaseNestedSwagger);
});

About

License:MIT License


Languages

Language:TypeScript 64.0%Language:JavaScript 36.0%