Giter Club home page Giter Club logo

sw2ts's Introduction

sw2ts

travis ci badge version license downloads downloads-month

Description

transform swagger.json to interfaces of typescript.

Install

npm install sw2ts

Usage

cli

  • init --- options
    • -i,--input,swagger.json path
    • -o,--output,output dir, default: ./
sw2ts init -i ./example/swagger.json -o ./

node

const sw2ts = require('sw2ts');
const swagger = require('./swagger.json');
sw2ts(swagger, __dirname);

Examlpe

here

swagger.json

click here

routes.ts

click here

import { RootObject as GetPetFindByStatus } from './GET/pet/findByStatus';
import { RootObject as GetPetFindByTags } from './GET/pet/findByTags';
import { RootObject as GetPetPetId } from './GET/pet/:petId';
import { RootObject as GetStoreInventory } from './GET/store/inventory';
import { RootObject as GetStoreOrderOrderId } from './GET/store/order/:orderId';
import { RootObject as GetUserLogin } from './GET/user/login';
import { RootObject as GetUserLogout } from './GET/user/logout';
import { RootObject as GetUserUsername } from './GET/user/:username';
import { RootObject as PostPet } from './POST/pet';
import { RootObject as PostPetPetId } from './POST/pet/:petId';
import { RootObject as PostPetPetIdUploadImage } from './POST/pet/:petId/uploadImage';
import { RootObject as PostStoreOrder } from './POST/store/order';
import { RootObject as PostUser } from './POST/user';
import { RootObject as PostUserCreateWithArray } from './POST/user/createWithArray';
import { RootObject as PostUserCreateWithList } from './POST/user/createWithList';
import { RootObject as PutPet } from './PUT/pet';
import { RootObject as PutUserUsername } from './PUT/user/:username';
import { RootObject as DeletePetPetId } from './DELETE/pet/:petId';
import { RootObject as DeleteStoreOrderOrderId } from './DELETE/store/order/:orderId';
import { RootObject as DeleteUserUsername } from './DELETE/user/:username';

export interface IGetRoutes {
  '/pet/findByStatus': GetPetFindByStatus;
  '/pet/findByTags': GetPetFindByTags;
  '/pet/:petId': GetPetPetId;
  '/store/inventory': GetStoreInventory;
  '/store/order/:orderId': GetStoreOrderOrderId;
  '/user/login': GetUserLogin;
  '/user/logout': GetUserLogout;
  '/user/:username': GetUserUsername;
} 

export interface IPostRoutes {
  '/pet': PostPet;
  '/pet/:petId': PostPetPetId;
  '/pet/:petId/uploadImage': PostPetPetIdUploadImage;
  '/store/order': PostStoreOrder;
  '/user': PostUser;
  '/user/createWithArray': PostUserCreateWithArray;
  '/user/createWithList': PostUserCreateWithList;
} 

export interface IPutRoutes {
  '/pet': PutPet;
  '/user/:username': PutUserUsername;
} 

export interface IDeleteRoutes {
  '/pet/:petId': DeletePetPetId;
  '/store/order/:orderId': DeleteStoreOrderOrderId;
  '/user/:username': DeleteUserUsername;
} 

sw2ts's People

Contributors

shanamaid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.