Open stijnvanhulle opened 2 months ago
On your note of
"Use of the same naming for all plugins:
@kubb/plugin-ts
instead of@kubb/swagger-ts
, prefix plugin is important here."
In a similar vein, I strongly feel that the use of "swagger" anywhere should be vaulted and replaced with openapi.
I know it seems small, but seeing swagger used instead of openapi gives off a strong "stuck in the past" vibe, for an otherwise such modern and forward thinking library.
react-form-hook?
@stijnvanhulle Will it be possible to set the basePath for the client dynamically in v3? Would be a dealbreaker if you could set the basePath at runtime, not at generation.
@joakimstrandell Today(in v2 and v3) you can use serverIndex
to set the baseUrl: https://www.kubb.dev/plugins/plugin-oas/#serverindex. Other plugins like the @kubb/plugin-client
and @kubb/plugin-react-query
will use that config to set the baseURL, would that be enough or what do you mean with dynamically?
@stijnvanhulle I mean that I would like to set the path in the client during runtime, for example using some type of custom config. If I would use the server index I need to select the path when generating the client, if I understand the documentation correctly.
For example in hey-api you can set the base url like this:
import { client } from 'api';
import { config } from 'data' // custom
client.setConfig({
baseUrl: config.api.basePath,
headers: {
Authorization: '...',
'X-Csrftoken': '...',
},
});
@joakimstrandell I updated the default client
to also have getConfig
and setConfig
but in Kubb you can also override the default client. This means you can do whatever you want so long you are following the guideline where the parameters are having the same shape as RequestConfig
.
type RequestConfig<TData = unknown> = {
baseURL?: string
url?: string
method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'
params?: unknown
data?: TData | FormData
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
signal?: AbortSignal
headers?: AxiosRequestConfig['headers']
}
Transform snake_case to camelCase in generated code. Transform camelCase to snake_case before request
@RabbitShare For that I suggest using https://github.com/thim81/openapi-format
I am already thinking about the next version of Kubb and what should be done to make it better:
@kubb/plugin-ts
instead of@kubb/swagger-ts
transform
,resolveId
andwriteFile
output.exportType
to customize root barrel generationouput
options as part of every Kubb pluginasPascalConst
marked as deprecatedbarrelNamed
as default instead ofbarrel
tag
useQuery
generationhttps://rollupjs.org/plugin-development/#banner https://unplugin.unjs.io/guide https://coolify.io/docs/knowledge-base/faq