Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],
};
43 changes: 43 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Macos
.DS_Store

# Node
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

# local env files
.env.local
.env.*.local

# Log files
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
!.vscode/extensions.json

# dist and cache
/dist
/dist-*
/dist_*
.cache

# testing
/coverage

# next.js
.next
/out
/build

# nuxt.js
.nuxt
.nitro
.output
24 changes: 24 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { defineConfig } = require('eslint-define-config');

module.exports = defineConfig({
root: true,

env: {
browser: true,
node: true,
es2022: true,
},

parser: '@typescript-eslint/parser',

extends: [
//
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],

rules: {
'prettier/prettier': 'error',
},
});
4 changes: 4 additions & 0 deletions .husky/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```shell
chmod +x commit-msg
chmod +x pre-commit
```
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'*.ts': 'eslint --fix',
'*': 'prettier --ignore-unknown --write',
};
43 changes: 43 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Macos
.DS_Store

# Node
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

# local env files
.env.local
.env.*.local

# Log files
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
!.vscode/extensions.json

# dist and cache
/dist
/dist-*
/dist_*
.cache

# testing
/coverage

# next.js
.next
/out
/build

# nuxt.js
.nuxt
.nitro
.output
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @type {import('prettier').Config}
*/
module.exports = {
tabWidth: 2,
singleQuote: true,
};
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,44 @@

OpenAPI Specification ➡️ TypeScript

# 安装
# Install

```shell
npm i -D oas-gen-ts
```

# 使用
# Usage

## 命令行
## CLI

Create oas.config.js or oas.json in the root directory of the project, and refer to [cosmiconfig](https://www.npmjs.com/package/cosmiconfig) for the file name specification.

```ts
// oas.config.mjs
export default defineConfig({
axiosImport: `import { axios } from '@/util/axios';`,
list: [
{
name: 'pet',
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
},
],
});
```

```shell
# Generate typescript files based on configuration files
npx oas-gen-ts

# The `src/apis/pet.ts` file will be generated
```

## API

[](https://)
```ts
import { generate } from 'oas-gen-ts';

generate({
// ...
});
```
5 changes: 5 additions & 0 deletions bin/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { start } from '../dist';

await start();
Loading