百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
O

openapi2aspida

> 编程语言
开源

将 OpenAPI 3.0 或 Swagger 2.0 定义转换为 aspida

189 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

将 OpenAPI 3.0 或 Swagger 2.0 定义转换为 aspida

OpenAPI / Swagger to aspida

Convert OpenAPI 3.0 and Swagger 2.0 definitions into aspida.

Getting Started

Compatible with yaml/json of OpenAPI3.0/Swagger2.0

bash
$ mkdir petstore-api
$ cd petstore-api
$ npx openapi2aspida -i https://petstore.swagger.io/v2/swagger.json # or ../local-swagger.yaml
# api/$api.ts was built successfully.

$ npm init -y
$ npm install @aspida/axios axios typescript ts-node @types/node

index.ts

typescript
import axiosClient from '@aspida/axios';
import api from './api/$api';
import type { Pet } from './api/@types';
(async () => {
  const client = api(axiosClient());
  const petId = 100;
  const body: Pet = {
    id: petId,
    name: 'hoge',
    photoUrls: [],
    status: 'available',
  };

  await client.pet.$post({ body });
  const pet = await client.pet._petId(petId).$get();
  console.log(pet);
})();

package.json

json
{
  "scripts": {
    "start": "ts-node index.ts"
  }
}
bash
$ npm start
# { id: 100, name: 'hoge', photoUrls: [], tags: [], status: 'available' }

Build from config file

Create config file in project root

aspida.config.js

javascript
module.exports = {
  input: 'api', // "input" of aspida is "output" for openapi2aspida
  outputEachDir: true, // Generate $api.ts in each endpoint directory
  openapi: { inputFile: 'https://petstore.swagger.io/v2/swagger.json' },
};
bash
$ npx openapi2aspida

Cli options

-i, --input

path to an OpenAPI spec file for input

-o, --outputdir

can change aspida output directory

-c, --config

path to an aspida config file

--version

displays version of openapi2aspida

example

bash
npx openapi2aspida -i=openApi/sample.yaml -o=lib/api/sample

License

openapi2aspida is licensed under a MIT License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptaspidaopenapiswaggertypescript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言