Skip to content

Commit

Permalink
Merge branch 'main' into feat/supportMultiLanguages
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Feb 19, 2024
2 parents 6e39777 + 5cbc44e commit 62a7c96
Show file tree
Hide file tree
Showing 332 changed files with 2,826 additions and 2,655 deletions.
22 changes: 22 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ const pluginsSidebar = [
},
],
},
{
text: 'Build plugins',
collapsed: false,
items: [
{
text: 'unplugin-kubb <span class="new">new</span>',
collapsed: false,
link: '/plugins/unplugin/',
},
],
},
{
text: 'Swagger plugins',
collapsed: false,
Expand Down Expand Up @@ -370,6 +381,17 @@ const pluginsMenu = [
},
],
},
{
text: 'Build plugins',
collapsed: false,
items: [
{
text: 'unplugin-kubb',
collapsed: false,
link: '/plugins/unplugin/',
},
],
},
{
text: 'Swagger plugins',
items: [
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"serve": "vitepress serve"
},
"dependencies": {
"@vercel/analytics": "^1.1.2",
"@vercel/analytics": "^1.2.1",
"sitemap": "^7.1.1",
"vitepress": "^1.0.0-rc.41",
"vue": "^3.4.15"
"vitepress": "^1.0.0-rc.44",
"vue": "^3.4.19"
},
"devDependencies": {
"@types/node": "^20.11.16"
"@types/node": "^20.11.19"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
89 changes: 88 additions & 1 deletion docs/plugins/swagger-tanstack-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,96 @@ export default defineConfig({

:::

### query

Override some useQuery behaviours.

::: info type

::: code-group

```typescript [Query]
type Query = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
queryKey?: (key: unknown[]) => unknown[]
}
```
:::
::: info
Type: `Query` <br/>
::: code-group
```typescript [kubb.config.js]
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'

export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [
createSwagger({ output: false }),
createSwaggerTS({}),
createSwaggerTanstackQuery({ query: {} }),
],
})
```

:::

#### query.queryKey

Customize the queryKey, here you can specify a suffix.

::: warning
When using a string you need to use `JSON.stringify`.
:::

::: info
Type: `(key: unknown[]) => unknown[]` <br/>

::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'

export default defineConfig({
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
plugins: [
createSwagger({ output: false }),
createSwaggerTS({}),
createSwaggerTanstackQuery({
query: {
queryKey: (key: string[]) => [JSON.stringify('SUFFIX'), ...key],
},
}),
],
})
```

:::

### suspense

When set, a suspenseQuery hooks will be added. This will only work for v5 and react.
When set, a suspenseQuery hook will be added. This will only work for v5 and react.

::: info type

Expand Down
186 changes: 186 additions & 0 deletions docs/plugins/unplugin/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
---
layout: doc

title: unplugin-kubb
outline: deep
---

# unplugin-kubb <a href="https://paka.dev/npm/unplugin-kubb@latest/api">🦙</a>

Kubb plugin for Vite, webpack, esbuild, Rollup, Nuxt, Astro and Rspack.

## Installation

::: code-group

```shell [bun <img src="/feature/bun.svg"/>]
bun add unplugin-kubb @kubb/core
```

```shell [pnpm <img src="/feature/pnpm.svg"/>]
pnpm add unplugin-kubb @kubb/core
```

```shell [npm <img src="/feature/npm.svg"/>]
npm install unplugin-kubb @kubb/core
```

```shell [yarn <img src="/feature/yarn.svg"/>]
yarn add unplugin-kubb @kubb/core
```

:::

## Options

### config

Define the options for Kubb.

::: info type

```typescript [Options]
type Options = {
config: UserConfig
}
```
:::
::: info
Type: `Options` <br/>
::: code-group
```typescript [kubb.config.ts]
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'
import createSwaggerTS from '@kubb/swagger-ts'

/** @type {import('@kubb/core').UserConfig} */
export const config = {
root: '.',
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
clean: true,
},
plugins: [
createSwagger({ output: false }),
createSwaggerTS({
output: {
path: 'models',
},
}),
],
}
```

```typescript [vite.config.ts]
import react from '@vitejs/plugin-react'
import kubb from 'unplugin-kubb/vite'
import { defineConfig } from 'vite'
import { config } from './kubb.config'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
kubb({
config,
}),
],
})
```

:::

## Examples

### Vite

```ts
// vite.config.ts
import Plugin from 'unplugin-kubb/vite'

export default defineConfig({
plugins: [
Plugin({/* options */}),
],
})
```

### Rollup

```ts
// rollup.config.js
import Plugin from 'unplugin-kubb/rollup'

export default {
plugins: [
Plugin({/* options */}),
],
}
```

### webpack

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-kubb/webpack')({/* options */}),
],
}
```

### Nuxt

```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-kubb/nuxt', {/* options */}],
],
})
```

> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
### Vue CLI

```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-kubb/webpack')({/* options */}),
],
},
}
```

### esbuild

```ts
// esbuild.config.js
import { build } from 'esbuild'
import Plugin from 'unplugin-kubb/esbuild'

build({
plugins: [Plugin()],
})
```

## Depended

- [`@kubb/core`](/plugins/core/)

## Links

- [Vite](https://vitejs.dev/)
20 changes: 10 additions & 10 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@faker-js/faker": "^8.4.0",
"@faker-js/faker": "^8.4.1",
"@kubb/cli": "workspace:*",
"@kubb/core": "workspace:*",
"@kubb/swagger": "workspace:*",
Expand All @@ -32,25 +32,25 @@
"@kubb/swagger-ts": "workspace:*",
"@kubb/swagger-zod": "workspace:*",
"@kubb/swagger-zodios": "workspace:*",
"@tanstack/react-query": "^5.18.1",
"@tanstack/solid-query": "^5.18.1",
"@tanstack/svelte-query": "^5.18.1",
"@tanstack/vue-query": "^5.18.1",
"@tanstack/react-query": "^5.21.7",
"@tanstack/solid-query": "^5.21.7",
"@tanstack/svelte-query": "^5.21.7",
"@tanstack/vue-query": "^5.21.7",
"@zodios/core": "^10.9.6",
"axios": "^1.6.7",
"msw": "^1.3.2",
"react": "^18.2.0",
"solid-js": "^1.8.12",
"solid-js": "^1.8.15",
"svelte": "^3.59.2",
"swr": "^2.2.4",
"tsup": "^8.0.1",
"vue": "^3.4.15",
"swr": "^2.2.5",
"tsup": "^8.0.2",
"vue": "^3.4.19",
"zod": "^3.22.4"
},
"devDependencies": {
"@kubb/ts-config": "workspace:*",
"@kubb/tsup-config": "workspace:*",
"tsup": "^8.0.1",
"tsup": "^8.0.2",
"typescript": "~5.2.2"
},
"packageManager": "[email protected]",
Expand Down
Loading

0 comments on commit 62a7c96

Please sign in to comment.