Skip to content

Latest commit

ย 

History

History
65 lines (42 loc) ยท 1.45 KB

README_en-US.md

File metadata and controls

65 lines (42 loc) ยท 1.45 KB

ไธญๆ–‡็ฎ€ไฝ“ | English

Build Status

Generate typescript code from swagger(v3) JSON.

It will generate a typescript definition and fetch-based api client. all most out of box.

It can be applied to most scenarios, strengthen your interface calls, and eliminate annoying type declarations.

Here are some generated exquisite examples to see if it meets your taste.

Installation

install via Deno

deno install \
  -A \
  --no-check \
  --reload \
  -f \
  https://github.com/axetroy/swagger2ts/raw/v0.2.26/swagger2ts.ts

or install via npm

npm install -g @axetroy/swagger2ts

Usage

Use it with cli

swagger2ts swagger.json > api.ts
swagger2ts https://example.com/swagger.json > api.ts

Use it in Node.js api

import { generate } from "@axetroy/swagger2ts";

const output = await generate("/path/to/swagger.json");
// const output = await generate("https://example.com/swagger.json");

console.log(output);

Use it in Deno api

import { generate } from "https://github.com/axetroy/swagger2ts/raw/v0.2.26/generate.ts";

const output = await generate("/path/to/swagger.json");
// const output = await generate("https://example.com/swagger.json");

console.log(output);

License

The MIT License