openapi-typescript根据Swagger OpenAPI规范生成TypeScript类型

openapi-typescript这个工具可以帮你根据 Swagger OpenAPI规范生成 TypeScript 类型,挺好用的。它可以从本地文件或者远程资源获取 OpenAPI 规范,快速转化为 TypeScript 接口。支持用Prettier格式化输出,而且格式化规则还是可以自定义的哦。比如,你可以这样通过命令行读取本地文件:

npx openapi-typescript schema.yaml --output schema.ts
,或者读取远程资源:
npx openapi-typescript https://petstore.swagger.io/v2/swagger.json --output petstore.ts
。生成的类型不仅干净整洁,而且还能提高你与后端对接的效率,减少出错。你可以试试看,蛮适合需要 API 的项目,尤其是大项目里用到的 API 接口定义。

zip
openapi-typescript-main.zip 预估大小:75个文件
folder
openapi-typescript-main 文件夹
folder
.dependabot 文件夹
file
config.yml 210B
file
codecov.yml 67B
folder
.github 文件夹
folder
workflows 文件夹
file
pull_request.yml 778B
file
merge.yml 211B
file
auto_approve.yml 333B
file
tsconfig.jest.json 487B
file
.eslintrc.js 592B
file
.prettierignore 86B
folder
src 文件夹
file
types.ts 4KB
file
utils.ts 4KB
file
index.ts 1KB
folder
transform 文件夹
file
index.ts 4KB
file
paths.ts 2KB
file
parameters.ts 2KB
file
operation.ts 2KB
file
headers.ts 511B
file
schema.ts 4KB
file
responses.ts 2KB
file
tsconfig.cjs.json 489B
folder
examples 文件夹
file
stripe-openapi2.ts 1.26MB
file
stripe-openapi3.ts 1.35MB
file
CONTRIBUTING.md 3KB
file
tsconfig.json 487B
file
LICENSE 1KB
file
jest.config.js 150B
file
.prettierrc 49B
file
README.md 21KB
file
.all-contributorsrc 8KB
folder
docs 文件夹
file
migrating-from-v1.md 4KB
folder
tests 文件夹
folder
v3 文件夹
folder
specs 文件夹
file
petstore.yaml 18KB
file
stripe.yaml 2.15MB
file
null-in-enum.yaml 900B
file
manifold.yaml 57KB
file
github.yaml 2.69MB
file
petstore-openapitools.yaml 19KB
folder
expected 文件夹
file
manifold.ts 36KB
file
http.ts 36KB
file
null-in-enum.ts 721B
file
github.ts 1.38MB
file
petstore.ts 11KB
file
petstore-openapitools.ts 12KB
file
stripe.ts 1.4MB
file
index.test.ts 1KB
folder
utils 文件夹
file
index.test.ts 350B
folder
v2 文件夹
folder
specs 文件夹
file
petstore.yaml 18KB
file
stripe.yaml 1.6MB
file
null-in-enum.yaml 1020B
file
manifold.yaml 50KB
folder
expected 文件夹
file
manifold.ts 30KB
file
http.ts 30KB
file
null-in-enum.ts 684B
file
petstore.ts 9KB
file
stripe.ts 1.26MB
file
index.test.ts 1KB
file
parameters.test.ts 3KB
file
paths.test.ts 8KB
file
empty-definitions.test.ts 1KB
file
operation.test.ts 2KB
file
raw-schema.test.ts 1KB
folder
bin 文件夹
folder
fixtures 文件夹
file
.prettierrc 90B
file
prettier.config.js 100B
folder
specs 文件夹
file
petstore.yaml 18KB
folder
expected 文件夹
file
prettier-js.ts 11KB
file
stdout.ts 11KB
file
prettier-json.ts 11KB
file
cli.test.ts 1KB
file
schema.test.ts 8KB
file
.gitignore 87B
folder
bin 文件夹
folder
loaders 文件夹
file
loadFromFs.js 378B
file
loadFromHttp.js 2KB
file
index.js 2KB
file
cli.js 3KB
file
.eslintignore 16B
file
package-lock.json 499KB
file
package.json 2KB
...
zip 文件大小:1.76MB