Skip to content

Commit

Permalink
Merge pull request #511 from kubb-project/feat/overrideBy
Browse files Browse the repository at this point in the history
feat: `overrideBy` to specify different options per `operationId | tag | path | method`
  • Loading branch information
stijnvanhulle authored Oct 20, 2023
2 parents 6cc3f70 + fb42958 commit 18d2be7
Show file tree
Hide file tree
Showing 69 changed files with 3,220 additions and 729 deletions.
25 changes: 16 additions & 9 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export default defineConfig({
markdown: {
theme: {
light: 'github-light',
dark: 'github-dark',
dark: 'nord',
},
lineNumbers: true,
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
Expand Down Expand Up @@ -162,14 +163,6 @@ export default defineConfig({
text: '@kubb/cli',
link: '/plugins/cli',
},
{
text: '@kubb/parser',
link: '/plugins/parser',
},
{
text: '@kubb/react <span class="beta">under construction</span>',
link: '/plugins/react',
},
{
text: 'Swagger plugins',
collapsed: false,
Expand Down Expand Up @@ -219,6 +212,20 @@ export default defineConfig({
},
],
},
{
text: 'Internal plugins',
collapsed: false,
items: [
{
text: '@kubb/parser',
link: '/plugins/parser',
},
{
text: '@kubb/react <span class="beta">under construction</span>',
link: '/plugins/react',
},
],
},
],
},
{
Expand Down
16 changes: 16 additions & 0 deletions docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
--vp-c-brand-dark: #854811;
--vp-c-brand-darker: #854811;
--vp-c-brand-dimm: rgba(100, 108, 255, 0.08);
--vp-c-brand-1: var(--vp-c-brand);
--vp-badge-tip-text: var(--vp-c-indigo-1);
}


/**
* Component: Button
* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -86,6 +89,11 @@
--docsearch-primary-color: var(--vp-c-brand) !important;
}

.details {
padding-bottom: 2rem;
position: relative;
}

.details a {
color: var(--vp-c-brand);
}
Expand Down Expand Up @@ -125,6 +133,10 @@
background-color: var(--vp-c-mute);
transition: color 0.5s, background-color 0.5s;
}
.learn-more {
position: absolute;
bottom: 0;
}

.item .VPFeature {
transition: transform 0.25s ease 0s, filter 0.25s ease 0s, box-shadow 0.25s ease 0s;
Expand All @@ -142,6 +154,10 @@
align-items: baseline;
}

.vp-doc h1 a {
text-decoration: none;
}

.vp-code-group .tabs img {
padding-left: 0.5rem;
align-items: center;
Expand Down
8 changes: 4 additions & 4 deletions docs/configuration/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Kubb is configured with a configuation file (preferably with `kubb.config.js`).
::: tip
When using a `import` statement you need to set `"type": "module"` in your `package.json`.

You can also rename your file to `kubb.config.mjs` to use the module way of importing files in Node.
You can also rename your file to `kubb.config.mjs` to use ESM or `kubb.config.cjs for CJS.
:::

### DefineConfig
Expand Down Expand Up @@ -54,7 +54,7 @@ export default defineConfig({

#### Conditional config

If the config needs to be conditionally determined based on CLI options flags, it can export as a function instead.
If the config needs to be conditionally determined based on CLI options flags, it can be exported as a function instead.<br/>
Here you can choose between returning the config options synchronously or asynchronously.

``` typescript
Expand Down Expand Up @@ -141,7 +141,7 @@ You can use a [JSON schema](https://github.com/kubb-project/kubb/blob/main/packa

```json [kubb.json]
{
"$schema": "@kubb/core/schemas/config.json",
"$schema": "@kubb/core/schemas.json",
"root": ".",
"input": {
"path": "./petStore.yaml"
Expand All @@ -163,7 +163,7 @@ You can use a [JSON schema](https://github.com/kubb-project/kubb/blob/main/packa

```json [kubb.json]
{
"$schema": "@kubb/core/schemas/config.json",
"$schema": "@kubb/core/schemas.json",
"root": ".",
"input": {
"path": "./petStore.yaml"
Expand Down
59 changes: 40 additions & 19 deletions docs/configuration/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ By setting the following options you can override the default behaviour of Kubb
## root
Project root directory. Can be an absolute path, or a path relative from the location of the config file itself.

::: info
Type: `string` <br/>
Default: `process.cwd()`
Default: `process.cwd()` <br/>

::: code-group

Expand All @@ -30,15 +31,16 @@ export default defineConfig({
}
})
```

:::

## input
You can use `input.path` or `input.data` depending on the needs you have.

### path
Path to be used as the input. Can be an absolute path, or a path relative from the defined root option.
Define your Swagger/OpenAPI file.<br/>
This can be an absolute path or a path relative to the `root`.

::: info
Type: `string` <br/>
Required: `true`

Expand All @@ -56,10 +58,12 @@ export default defineConfig({
}
})
```
:::

### data
String or object containing the data that you would normally import.
`string` or `object` containing your Swagger/OpenAPI

::: info
Type: `string | unknown` <br/>
Required: `true`

Expand All @@ -79,13 +83,14 @@ export default defineConfig({
}
})
```

:::

## output
### path
Path to be used to export all generated files. Can be an absolute path, or a path relative from the defined root option.
Path to be used to export all generated files.<br/>
This can be an absolute path, or a path relative from the defined `root` option.

::: info
Type: `string` <br/>
Required: `true`

Expand All @@ -103,11 +108,12 @@ export default defineConfig({
}
})
```

:::

### clean
Remove previous generated files and folders.
Clean output directory before each build.

::: info
Type: `boolean` <br/>

::: code-group
Expand All @@ -125,12 +131,12 @@ export default defineConfig({
},
})
```

:::

### write
Enabled or disable the writing to the filesystem.
Write files to the fileSystem.

::: info
Type: `boolean` <br/>
Default: `true`

Expand All @@ -150,7 +156,6 @@ export default defineConfig({
},
})
```

:::

## plugins
Expand All @@ -160,6 +165,7 @@ Sometimes a plugin is depended on another plugin, if that's the case you will ge
### plugins[index]

#### TypeScript
::: info

Type: `Plugin` <br/>

Expand All @@ -179,16 +185,16 @@ export default defineConfig({
plugins: [createSwagger({ })],
})
```

:::

#### JSON
When using JSON the structure will be a little bit different.
Here we are using the same syntax like how [Babel](https://babeljs.io/docs/en/plugins/) make it possible to use plugins with extra options.
When using JSON, the structure will be a little bit different.
Here we are using the same syntax like how [Babel](https://babeljs.io/docs/en/plugins/) makes it possible to use plugins with extra options.

```
[NAME PLUGIN, {...options}]
[PLUGIN, {...options}]
```

::: info
::: code-group

```json [kubb.json]
Expand All @@ -212,16 +218,16 @@ Here we are using the same syntax like how [Babel](https://babeljs.io/docs/en/pl
]
}
```

:::

## hooks
Hooks that will be called when a specific action is triggered in Kubb.

### done
Hook that will be triggerend at the end of all executions.
Useful for running Prettier or ESLint after all files has been created.
Hook that will be triggered at the end of Kubb's generation.<br/>
Useful for running Prettier or ESLint to format/lint your code.

::: info
Type: `string | string[]` <br/>

::: code-group
Expand All @@ -242,4 +248,19 @@ export default defineConfig({
})
```

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

export default defineConfig({
hooks: {
done: "npx prettier --write ."
},
input: {
path: './petStore.yaml',
},
output: {
path: './src/gen',
},
})
```
:::
22 changes: 11 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,50 @@ features:
src: ./feature/typescript.svg
height: 24
title: TypeScript
details: Out-of-box <a href="https://www.typescriptlang.org/">TypeScript</a> (with JSDoc) support.
details: Out-of-box <a href="https://www.typescriptlang.org/">TypeScript</a> (with JSDoc) support. <div class="learn-more"><a href="/plugins/swagger-ts">Learn more</a></div>
- icon:
src: ./feature/tanstack.svg
height: 24
title: Tanstack Query
details: Creates hooks for all supported <a href="https://tanstack.com/query/latest">Tanstack-Query</a> frameworks (React, Solid, Svelte, Vue).
details: Creates hooks for all supported <a href="https://tanstack.com/query/latest">Tanstack-Query</a> frameworks (React, Solid, Svelte, Vue). <div class="learn-more"><a href="/plugins/swagger-tanstack-query">Learn more</a></div>
- icon:
dark: ./feature/swr-dark.svg
light: ./feature/swr-light.svg
height: 24
title: SWR
details: Creates React Hooks for Data Fetching with <a href="https://swr.vercel.app/">SWR</a>.
details: Creates React Hooks for Data Fetching with <a href="https://swr.vercel.app/">SWR</a>. <div class="learn-more"><a href="/plugins/swagger-swr">Learn more</a></div>
- icon:
src: ./feature/axios.svg
title: Axios
details: <a href="https://axios-http.com/">Promise based HTTP calls</a> with a custom Client to set baseURL, headers, ... options.
details: <a href="https://axios-http.com/">Promise based HTTP calls</a> with a custom Client to set baseURL, headers, ... options. <div class="learn-more"><a href="/plugins/swagger-client/">Learn more</a></div>
- icon:
src: ./feature/msw.svg
title: MSW <span class="new">new</span>
details: Use of <a href="https://mswjs.io/">MSW</a> to create API mocks based on faker data.
details: Use of <a href="https://mswjs.io/">MSW</a> to create API mocks based on faker data. <div class="learn-more"><a href="/plugins/swagger-msw">Learn more</a></div>
- icon:
src: ./feature/zod.svg
height: 24
title: Zod
details: Validates your data with the power of <a href="https://zod.dev/">Zod</a> schemas.
details: Validates your data with the power of <a href="https://zod.dev/">Zod</a> schemas. <div class="learn-more"><a href="/plugins/swagger-zod">Learn more</a></div>
- icon:
src: ./feature/zodios.svg
title: Zodios
details: <a href="https://www.zodios.org"/>End-to-end typesafe REST API toolbox</a> created based on our <a href="https://zod.dev/">Zod</a> plugin.
details: <a href="https://www.zodios.org"/>End-to-end typesafe REST API toolbox</a> created based on our <a href="https://zod.dev/">Zod</a> plugin. <div class="learn-more"><a href="/plugins/swagger-zodios">Learn more</a></div>
- icon:
src: https://fakerjs.dev/logo.svg
title: Faker <span class="new">new</span>
details: Use of <a href="https://fakerjs.dev/">Fake.js</a> to create mock data that can be used to create fake API calls.
details: Use of <a href="https://fakerjs.dev/">Fake.js</a> to create mock data that can be used to create fake API calls. <div class="learn-more"><a href="/plugins/swagger-faker">Learn more</a></div>
- icon:
src: ./feature/json.svg
title: JSON Schemas
details: Reuse the JSON schemas that are created inside your Swagger/OpenAPI file.
details: Reuse the JSON schemas that are created inside your Swagger/OpenAPI file. <div class="learn-more"><a href="/plugins/swagger">Learn more</a></div>
- icon:
src: ./feature/cli.svg
title: CLI support
details: Log and see what is happening with the <span class="code">Kubb</span> CLI command.
details: Log and see what is happening with the <span class="code">Kubb</span> CLI command. <div class="learn-more"><a href="/plugins/cli">Learn more</a></div>
- icon:
dark: ./feature/plugins-dark.svg
light: ./feature/plugins-light.svg
title: Extensible with plugins
details: Create your own plugin or fork and change one of the default plugins with your own flavour without the need of forking the full project.
details: Create your own plugin or fork and change one of the default plugins with your own flavour without the need of forking the full project. <div class="learn-more"><a href="/plugins/introduction">Learn more</a></div>
---
6 changes: 2 additions & 4 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ Main features ✨:
- Plugins system based on Rollup, esbuild,
- CLI support.

## Installation

<Badge type="tip" :text="version" />
## Installation <Badge type="tip" :text="version" />
You can install Kubb via [NPM](https://www.npmjs.com/).

::: code-group
Expand All @@ -59,7 +57,7 @@ yarn add @kubb/cli @kubb/core

:::

<Badge type="warning" text="canary" />
### <Badge type="warning" text="canary" />
Kubb also publishes a canary version on every commit to the main branch. <br/>
To install the canary version:

Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"@vercel/analytics": "^1.1.1",
"sitemap": "^7.1.1",
"vitepress": "1.0.0-rc.22",
"vue": "^3.3.4"
"vue": "^3.3.6"
},
"devDependencies": {
"@types/node": "^20.8.6"
"@types/node": "^20.8.7"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading

1 comment on commit 18d2be7

@vercel
Copy link

@vercel vercel bot commented on 18d2be7 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kubb – ./

www.kubb.dev
kubb-git-main-kubb.vercel.app
kubb-kubb.vercel.app
kubb.dev

Please sign in to comment.