Skip to content

Commit 0c12949

Browse files
committed
chore: update documentation and configuration examples to use the official Petstore API URL for consistency across guides
1 parent 5903ed9 commit 0c12949

13 files changed

Lines changed: 53 additions & 35 deletions

File tree

docs/.config/docs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# yaml-language-server: $schema=https://unpkg.com/undocs/schema/config.json
22

3+
# 保留 server API(playground /api/generate),否则静态构建会返回 405
4+
nitro:
5+
static: false
6+
37
name: genapi
48
shortDescription: Lightweight API code generator—only the code you need, nothing extra.
59
description: A lightweight API code generator that generates only the code you want from OpenAPI and other specs, with no bloat.
0 Bytes
Binary file not shown.

docs/1.guide/1.index.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ Or install dependencies manually:
1414

1515
Running init starts an interactive wizard:
1616

17-
1. **Choose Preset**: axios, fetch, ky, got, ofetch, TanStack React Query, TanStack Vue Query, Pinia Colada, Uni
18-
2. **Choose output mode**: TS, JS, or Schema (only fetch and ofetch support Schema; TanStack Query and Colada are TS-only)
19-
3. **Overwrite confirmation**: If config exists, you'll be asked whether to overwrite
20-
4. **Dependency installation**: Option to install dependencies now or later
17+
1. **Choose Preset**: fetch, ofetch, axios, ky, got, @tanstack/react-query, @tanstack/vue-query, @pinia/colada, @uni-helper/uni-network
18+
3. **Overwrite confirmation**: If `genapi.config.ts` already exists, you'll be asked whether to overwrite
19+
4. **Dependencies**: `@genapi/core` and `@genapi/presets` are installed automatically; Schema mode also adds `fetchdts`
2120

2221
This creates `genapi.config.ts` or `genapi.config.js` in the project root. Then update `input` to your API doc URL.
2322

@@ -32,14 +31,14 @@ import { axios } from '@genapi/presets'
3231
export default defineConfig({
3332
// preset: pipeline object (e.g. axios.ts) or string (e.g. 'swag-axios-ts')
3433
preset: axios.ts,
35-
input: 'http://example.com/api-docs',
34+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
3635
output: {
3736
main: 'src/api/index.ts',
3837
type: 'src/api/index.type.ts',
3938
},
4039
meta: {
4140
baseURL: 'import.meta.env.VITE_APP_BASE_API',
42-
responseType: 'T extends { data?: infer V } ? V : void',
41+
// responseType: 'T extends { data?: infer V } ? V : void',
4342
},
4443
})
4544
```

docs/1.guide/2.configuration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { axios } from '@genapi/presets'
1818

1919
export default defineConfig({
2020
preset: axios.ts,
21-
input: 'http://example.com/api-docs',
21+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
2222
output: {
2323
main: 'src/api/index.ts',
2424
type: 'src/api/index.type.ts',
@@ -35,12 +35,12 @@ Preset configuration that defines how APIs are generated. You can use either a *
3535
**Pipeline object (recommended):**
3636

3737
```ts
38-
import { axios, tanstackQuery, colada } from '@genapi/presets'
38+
import { axios, tanstackQuery } from '@genapi/presets'
3939

4040
preset: axios.ts // or axios.js
4141
preset: tanstackQuery.react
4242
preset: tanstackQuery.vue
43-
preset: colada // or tanstackQuery.colada
43+
preset: tanstackQuery.colada
4444
```
4545

4646
**Preset string** (default is `'swag-axios-ts'`):
@@ -50,7 +50,7 @@ preset: colada // or tanstackQuery.colada
5050

5151
**HTTP clients (.ts / .js):** axios, fetch, ky, got, ofetch, uni
5252

53-
**Data layer (TypeScript only):** tanstackQuery.react, tanstackQuery.vue, colada
53+
**Data layer (TypeScript only):** tanstackQuery.react, tanstackQuery.vue, tanstackQuery.colada
5454

5555
### input
5656

docs/1.guide/3.presets.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ import { tanstackQuery } from '@genapi/presets'
9797

9898
export default defineConfig({
9999
preset: tanstackQuery.react,
100-
input: 'http://example.com/api-docs',
100+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
101101
output: { main: 'src/api/index.ts' },
102102
})
103103
```
@@ -125,7 +125,7 @@ import { tanstackQuery } from '@genapi/presets'
125125

126126
export default defineConfig({
127127
preset: tanstackQuery.vue,
128-
input: 'http://example.com/api-docs',
128+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
129129
output: { main: 'src/api/index.ts' },
130130
})
131131
```
@@ -134,24 +134,13 @@ export default defineConfig({
134134

135135
Uses [@pinia/colada](https://pinia-colada.esm.dev/) for type-safe query/mutation with Vue + Pinia (API: `key` + `query` / `mutation`):
136136

137-
```ts
138-
import { colada } from '@genapi/presets'
139-
140-
export default defineConfig({
141-
preset: colada,
142-
input: 'http://example.com/api-docs',
143-
output: { main: 'src/api/index.ts' },
144-
})
145-
```
146-
147-
Or use from the tanstack namespace:
148-
149137
```ts
150138
import { tanstackQuery } from '@genapi/presets'
151139

152140
export default defineConfig({
153141
preset: tanstackQuery.colada,
154-
// ...
142+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
143+
output: { main: 'src/api/index.ts' },
155144
})
156145
```
157146

@@ -185,7 +174,7 @@ export function usePostPets() {
185174
| UniApp | `uni.ts` |
186175
| React + server state | `tanstackQuery.react` |
187176
| Vue + server state | `tanstackQuery.vue` |
188-
| Vue + Pinia data layer | `colada` or `tanstackQuery.colada` |
177+
| Vue + Pinia data layer | `tanstackQuery.colada` |
189178

190179
## Next Steps
191180

docs/2.api/1.index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { defineConfig } from '@genapi/core'
1414

1515
### @genapi/presets
1616

17-
Presets package: HTTP client and data-layer pipelines (axios, fetch, ky, got, ofetch, uni, tanstackQuery, colada).
17+
Presets package: HTTP client and data-layer pipelines (axios, fetch, ky, got, ofetch, uni, tanstackQuery with react/vue/colada).
1818

1919
```ts
2020
import { axios, fetch, tanstackQuery } from '@genapi/presets'
@@ -63,7 +63,7 @@ import type { ApiPipeline } from '@genapi/shared'
6363

6464
const config: ApiPipeline.Config = {
6565
preset: 'swag-axios-ts', // or a pipeline function, e.g. axios.ts
66-
input: 'http://example.com/api-docs',
66+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
6767
output: { main: 'src/api/index.ts', type: 'src/api/index.type.ts' },
6868
meta: {},
6969
patch: {},

packages/core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Defines GenAPI config for `genapi.config.ts` / `genapi.config.js`. Supports sing
7979
```ts
8080
export default defineConfig({
8181
preset: axios.ts,
82-
input: 'http://example.com/api-docs',
82+
input: 'https://petstore3.swagger.io/api/v3/openapi.json',
8383
output: { main: 'src/api/index.ts', type: 'src/api/index.type.ts' },
8484
})
8585
```

packages/core/src/cli/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const PRESETS: Record<string, PresetConfig> = {
2525
// 框架集成:通常有固定模式,且仅支持 TS
2626
'react-query': { label: '@tanstack/react-query', pkg: 'tanstackQuery', fixedMode: 'react', features: ['ts'] },
2727
'vue-query': { label: '@tanstack/vue-query', pkg: 'tanstackQuery', fixedMode: 'vue', features: ['ts'] },
28-
'colada': { label: '@pinia/colada', pkg: 'colada', features: ['ts'] },
28+
'colada': { label: '@pinia/colada', pkg: 'tanstackQuery', fixedMode: 'colada', features: ['ts'] },
2929
'uni-network': { label: '@uni-helper/uni-network', pkg: 'uni', features: ['ts', 'js'] },
3030
}
3131

packages/core/src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { ApiPipeline } from '@genapi/shared'
1010
* ```ts
1111
* export default defineConfig({
1212
* preset: axios.ts,
13-
* input: 'http://example.com/api-docs',
13+
* input: 'https://petstore3.swagger.io/api/v3/openapi.json',
1414
* output: { main: 'src/api/index.ts', type: 'src/api/index.type.ts' },
1515
* })
1616
* ```

packages/presets/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {
2222
* @example
2323
* ```ts
2424
* import presets from '@genapi/presets'
25-
* // presets.axios, presets.fetch, presets.ofetch, presets.tanstackQuery, presets.uni, presets.colada
25+
* // presets.axios, presets.fetch, presets.ofetch, presets.tanstackQuery, presets.uni; colada: presets.tanstackQuery.colada
2626
* ```
2727
*/
2828
export default {

0 commit comments

Comments
 (0)