Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shakyshane/swag2ts
https://github.com/shakyshane/swag2ts
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/shakyshane/swag2ts
- Owner: shakyShane
- Created: 2018-03-03T13:04:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-23T17:07:02.000Z (over 1 year ago)
- Last Synced: 2024-04-14T07:49:50.917Z (9 months ago)
- Language: TypeScript
- Size: 132 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Todo
## `npm install -g swag2ts`
> Automatically generate Typescript namespaces from Swagger definitions
Click to see example output
```typescript
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
```bash
# 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
- [x] GET url params
- [x] simpler local refs in definitions
- [x] array refs
- [x] test + lint + build in npm test
- [x] CLI stdin
- [x] CLI files
- [ ] API
- [x] support multiple file outputs
- [ ] support separating paths from definitions in multi-file output