0.2.36 • Published 1 year ago

@axetroy/swagger2ts v0.2.36

Weekly downloads
14
License
ISC
Repository
github
Last release
1 year ago

中文简体 | English

Build Status

从 swagger(v3) 的 JSON 文件生成 typescript 代码。

它会生成 typescript 的声明和基于 fetch 的运行时。几乎开箱即用。

它能够适用于绝大多数场景,强健你的接口调用,省去烦人的类型声明。

这里有一些生成好的精美例子,看看是否符合您的胃口

安装

通过 Deno 安装

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

或者通过 npm 安装

npm install -g @axetroy/swagger2ts

使用

使用命令行工具

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

通过 nodejs 函数调用

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);

通过 Deno 函数调用

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);

开源许可

The MIT License

0.2.36

1 year ago

0.2.34

1 year ago

0.2.33

1 year ago

0.2.27

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.32

1 year ago

0.2.29

1 year ago

0.2.28

1 year ago

0.2.24

4 years ago

0.2.22

4 years ago

0.2.21

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.6

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago