Skip to content

Commit

Permalink
docs: more documentation for client and ts plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Sep 30, 2024
1 parent 1dcfa40 commit ddc5573
Show file tree
Hide file tree
Showing 29 changed files with 486 additions and 573 deletions.
1 change: 0 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { groupIconMdPlugin, groupIconVitePlugin, localIconLoader } from 'vitepre
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
import { SitemapStream } from 'sitemap'
import { defineConfig } from 'vitepress'
import { withMermaid } from "vitepress-plugin-mermaid";

import { renderMermaidGraphsPlugin } from './mermaid';
import { transposeTables } from "./transposeTables.ts"
Expand Down
3 changes: 3 additions & 0 deletions docs/blog/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ output: {
```
- Refactor of grouping(use of name instead of output) and output based on `output` of the current plugin

[//]: # (- [`@kubb/plugin-ts`] Removal of `enumType` in favor of `enum.type`)

[//]: # (- [`@kubb/plugin-ts`] Removal of `enumSuffix` in favor of `enum.suffix`)

## Thanks

Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineConfig({
output: {
path: './clients/axios',
},
group: { type: 'tag', output: './clients/axios/{{tag}}Service' }, // [!code --]
// group: { type: 'tag', output: './clients/axios/{{tag}}Service' }, // [!code --]
group: { type: 'tag', name: ({ group }) => `${group}Service` }, // [!code ++]
}),
],
Expand Down
39 changes: 0 additions & 39 deletions docs/comparison.md

This file was deleted.

40 changes: 33 additions & 7 deletions docs/getting-started/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,40 @@ export default defineConfig({
})
```

#### output.exportType
#### output.extension
Override the extension to the generated imports and exports, by default the plugin will add an extension.

| | |
|----------:|:-------------------------|
| Type: | `Record<KubbFile.Extname, KubbFile.Extname>` |
| Required: | `false` |
| Default: | `{ '.ts': '.ts'}` |


```typescript [kubb.config.ts]
import { defineConfig } from '@kubb/core'

export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
extension: {
'.ts': '.js',
},
},
})
```

#### output.barrelType
Define what needs to exported, here you can also disable the export of barrel files.

| | |
|----------:|:-------------------------------------|
| Type: | `'barrel' \| 'barrelNamed' \| false` |
| Required: | `false` |
| Default: | `'barrelNamed'` |
| | |
|----------:|:----------------------------|
| Type: | `'all' \| 'named' \| false` |
| Required: | `false` |
| Default: | `'named'` |


```typescript [kubb.config.ts]
Expand All @@ -262,7 +288,7 @@ export default defineConfig({
output: {
path: './src/gen',
clean: true,
exportType: 'barrel',
barrelType: 'all',
},
})
```
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"@kubb/plugin-vue-query": "workspace:*",
"@kubb/plugin-zod": "workspace:*",
"@kubb/react": "workspace:*",
"@mermaid-js/mermaid-cli": "^11.2.0",
"@types/node": "^20.16.10",
"@types/react": "^18.3.10",
"@mermaid-js/mermaid-cli": "^11.2.0",
"cross-env": "^7.0.3",
"react": "^18.3.1",
"unplugin-kubb": "workspace:^",
Expand Down
10 changes: 10 additions & 0 deletions docs/plugins/core/barrelTypes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
::: code-group
```typescript [all]
export * from "./gen/petService.ts"
```
```typescript [named]
export { PetService } from "./gen/petService.ts"
```
```typescript [false]
```
:::
15 changes: 15 additions & 0 deletions docs/plugins/core/exclude.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Array containing exclude parameters to exclude/skip tags/operations/methods/paths.

| | |
|----------:|:-----------------|
| Type: | `Array<Exclude>` |
| Required: | `false` |


```typescript [Exclude]
export type Exclude = {
type: 'tag' | 'operationId' | 'path' | 'method'
pattern: string | RegExp
}
```
Empty file added docs/plugins/core/generators.md
Empty file.
26 changes: 26 additions & 0 deletions docs/plugins/core/group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Grouping makes it possible to combine files in a folder based on specific `type`.

Imagine you have the following setup:

```typescript
group: {
type: 'tag',
name({ group }){
return `${group}Controller`
}
}
```
That will create a structure like this:
```
.
├── src/
│ └── petController/
│ │ ├── addPet.ts
│ │ └── getPet.ts
│ └── storeController/
│ ├── createStore.ts
│ └── getStoreById.ts
├── petStore.yaml
├── kubb.config.ts
└── package.json
```
1 change: 1 addition & 0 deletions docs/plugins/core/groupTypes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `'tag'`: Use of operation.getTags().at(0)?.name
15 changes: 15 additions & 0 deletions docs/plugins/core/include.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Array containing include parameters to include tags/operations/methods/paths.

| | |
|----------:|:-----------------|
| Type: | `Array<Include>` |
| Required: | `false` |

```typescript [Include]
export type Include = {
type: 'tag' | 'operationId' | 'path' | 'method'
pattern: string | RegExp
}
```
15 changes: 15 additions & 0 deletions docs/plugins/core/override.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Array containing override parameters to override `options` based on tags/operations/methods/paths.

| | |
|----------:|:------------------|
| Type: | `Array<Override>` |
| Required: | `false` |


```typescript [Override]
export type Override = {
type: 'tag' | 'operationId' | 'path' | 'method'
pattern: string | RegExp
options: PluginOptions
}
```
Empty file.
Loading

0 comments on commit ddc5573

Please sign in to comment.