Skip to content

Commit bae6c50

Browse files
authored
Merge pull request #42 from cloudcome/feat/v0.x
chore: release 设置时区,避免 changelog 日期不正确
2 parents 9b5e009 + c8f2d75 commit bae6c50

File tree

4 files changed

+153
-266
lines changed

4 files changed

+153
-266
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
release:
1414
runs-on: ubuntu-latest
1515
steps:
16+
- uses: szenius/set-timezone@v1
17+
with:
18+
timezoneLinux: Asia/Shanghai
19+
timezoneMacos: Asia/Shanghai
20+
timezoneWindows: Asia/Shanghai
1621
- uses: google-github-actions/release-please-action@v3
1722
id: release
1823
with:

README.md

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ npm i -D oas-gen-ts
1414

1515
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.
1616

17+
The search order for configuration files is `oas.config.cjs`, `oas.config.js`, `oas.json`.
18+
1719
```ts
18-
// oas.config.mjs
20+
// oas.config.cjs
1921
export default defineConfig({
2022
axiosImport: `import { axios } from '@/util/axios';`,
2123
list: [
2224
{
23-
name: 'pet',
25+
name: 'swagger/pet',
2426
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
2527
},
2628
],
@@ -31,7 +33,63 @@ export default defineConfig({
3133
# Generate typescript files based on configuration files
3234
npx oas-gen-ts
3335

34-
# The `src/apis/pet.ts` file will be generated
36+
# The `src/apis/swagger/pet.ts` file will be generated
37+
```
38+
39+
The generated file will be exported as one function and one operation, like this:
40+
41+
```ts
42+
// src/apis/swagger/pet.ts
43+
44+
import { axios } from '@/util/axios';
45+
46+
// ...
47+
48+
export interface Pet {
49+
/**
50+
* @format int64
51+
* @example 10
52+
*/
53+
id?: number;
54+
/** @example "doggie" */
55+
name: string;
56+
category?: Category;
57+
photoUrls: string[];
58+
tags?: Tag[];
59+
/** pet status in the store */
60+
status?: 'available' | 'pending' | 'sold';
61+
}
62+
63+
// ...
64+
65+
/**
66+
* @summary Finds Pets by status
67+
* @description Multiple status values can be provided with comma separated strings
68+
* @tags pet
69+
* @request GET:/pet/findByStatus
70+
* @secure
71+
*/
72+
export async function findPetsByStatus(
73+
query?: {
74+
/**
75+
* Status values that need to be considered for filter
76+
* @default "available"
77+
*/
78+
status?: 'available' | 'pending' | 'sold';
79+
},
80+
axiosRequestConfig?: AxiosRequestConfig
81+
): AxiosReturn<Pet[]> {
82+
return axios.request({
83+
url: `${BASE_URL}/pet/findByStatus`,
84+
method: MethodType.GET,
85+
params: query,
86+
headers: formatHeaders(ContentKind.OTHER),
87+
responseType: ResponseType.Json,
88+
...axiosRequestConfig,
89+
});
90+
}
91+
92+
// ...
3593
```
3694

3795
## API
@@ -43,3 +101,24 @@ generate({
43101
// ...
44102
});
45103
```
104+
105+
# Config
106+
107+
| Name | Type | Required | Description | Default |
108+
| -------------------- | --------- | -------- | ------------------------------------------ | ----------------------------------------------- |
109+
| `cwd` | `string` | `false` | current working directory | `process.cwd()` |
110+
| `dest` | `string` | `false` | Destination directory for generated files | `src/apis` |
111+
| `axiosImport` | `string` | `false` | axios import string | Import from the official and create an instance |
112+
| `unwrapResponseData` | `boolean` | `false` | unwrap the data item from the response | `false` |
113+
| `list` | `OAS[]` | `false` | List of OpenAPI Specification declarations | `[]` |
114+
115+
`Oas`:
116+
117+
| Name | Type | Required | Description | Default |
118+
| ------------- | -------- | -------- | ----------------------------------------------- | ----------------------------------------------- |
119+
| `name` | `string` | `true` | filename, which can be a path | `process.cwd()` |
120+
| `axiosImport` | `string` | `false` | axios import string, highest priority | Import from the official and create an instance |
121+
| `url` | `string` | `false` | The remote address of the OpenAPI Specification | `undefined` |
122+
| `spec` | `Spec` | `false` | The local Objects of the OpenAPI Specification | `undefined` |
123+
124+
**At least one of `url` and `spec` exists**

0 commit comments

Comments
 (0)