Skip to content

shakyShane/swag2ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo

npm install -g swag2ts

Automatically generate Typescript namespaces from Swagger definitions

Click to see example output
export namespace AcmeManageBasketAddToBasketV1Put {
  export const description = "";
  export const method = "PUT";
  export const operationId = "acmeManageBasketAddToBasketV1AddProductPut";
  export const path = "/V1/baskets/mine/add";
  export interface Body {
      productId: number;
      qty: number;
      purchaseType: string;
  }
  export type Response = Response200 | Response401 | ResponseDefault;
  export type Response200 = string;
  export type Response401 = Definitions.AcmeErrorResponse;
}
export namespace Definitions {
  export interface AcmeErrorResponse {
      message: string;
  }
}

Quick-start

# install
npm install -g swag2ts
# or 
yarn global add swag2ts

# run against a single JSON file
swag2ts dir/myfile.json

# or pipe json to it
curl http://some.swagger.api/schema | swag2ts --stdin

Todo

  • GET url params
  • simpler local refs in definitions
  • array refs
  • test + lint + build in npm test
  • CLI stdin
  • CLI files
  • API
  • support multiple file outputs
  • support separating paths from definitions in multi-file output

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published