@kubb/plugin-swr 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -38,7 +38,7 @@ var pluginSwr = core.createPlugin((options) => {
38
38
  options: {
39
39
  output,
40
40
  client: {
41
- importPath: "@kubb/plugin-client/client",
41
+ importPath: "@kubb/plugin-client/clients/axios",
42
42
  dataReturnType: "data",
43
43
  ...client
44
44
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/D;AAAA,GACE,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,aAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN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ACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/D;AAAA,GACE,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,aAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,mCAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,GAAG;AAAA,OACL;AAAA,MACA,QAAA;AAAA,MACA,KAAA,EACE,KAAU,KAAA,KAAA,GACN,KACA,GAAA;AAAA,QACE,UAAY,EAAA,KAAA;AAAA,QACZ,OAAA,EAAS,CAAC,KAAK,CAAA;AAAA,QACf,GAAG;AAAA,OACL;AAAA,MACN,WAAA;AAAA,MACA,QAAU,EAAA;AAAA,QACR,UAAY,EAAA,cAAA;AAAA,QACZ,OAAS,EAAA,CAAC,MAAQ,EAAA,KAAA,EAAO,UAAU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UAAW,EAAA;AAEvD,MAAA,IAAI,OAAS,EAAA;AACX,QAAK,IAAA,CAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,CAAO,OAAU,GAAA,OAAA;AAAA;AAEvC,MAAA,MAAM,kBAAqB,GAAA,IAAIK,4BAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var pluginSwr = createPlugin((options) => {
32
32
  options: {
33
33
  output,
34
34
  client: {
35
- importPath: "@kubb/plugin-client/client",
35
+ importPath: "@kubb/plugin-client/clients/axios",
36
36
  dataReturnType: "data",
37
37
  ...client
38
38
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAY,YAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAA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,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAY,YAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAAC,cAAA,EAAgB,iBAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/D;AAAA,GACE,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,aAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,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AK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Generator plugin-swr",
5
5
  "keywords": [
6
6
  "typescript",
@@ -64,22 +64,22 @@
64
64
  ],
65
65
  "dependencies": {
66
66
  "remeda": "^2.17.4",
67
- "@kubb/core": "3.2.0",
68
- "@kubb/fs": "3.2.0",
69
- "@kubb/oas": "3.2.0",
70
- "@kubb/plugin-client": "3.2.0",
71
- "@kubb/plugin-oas": "3.2.0",
72
- "@kubb/plugin-ts": "3.2.0",
73
- "@kubb/plugin-zod": "3.2.0",
74
- "@kubb/react": "3.2.0"
67
+ "@kubb/core": "3.3.1",
68
+ "@kubb/fs": "3.3.1",
69
+ "@kubb/oas": "3.3.1",
70
+ "@kubb/plugin-client": "3.3.1",
71
+ "@kubb/plugin-oas": "3.3.1",
72
+ "@kubb/plugin-ts": "3.3.1",
73
+ "@kubb/plugin-zod": "3.3.1",
74
+ "@kubb/react": "3.3.1"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/react": "^18.3.16",
78
78
  "react": "^18.3.1",
79
79
  "tsup": "^8.3.5",
80
80
  "typescript": "^5.7.2",
81
- "@kubb/config-ts": "3.2.0",
82
- "@kubb/config-tsup": "3.2.0"
81
+ "@kubb/config-ts": "3.3.1",
82
+ "@kubb/config-tsup": "3.3.1"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@kubb/react": "^3.0.0"
@@ -1,49 +1,48 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "swr";
3
- import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return res;
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return res
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,49 +1,48 @@
1
- import client from "axios";
2
- import useSWR from "swr";
3
- import type { RequestConfig } from "axios";
1
+ import client from 'axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig } from 'axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return res.data;
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return res.data
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,32 +1,41 @@
1
- import client from "axios";
2
- import useSWRMutation from "swr/mutation";
3
- import type { RequestConfig } from "axios";
1
+ import client from 'axios'
2
+ import useSWRMutation from 'swr/mutation'
3
+ import type { RequestConfig } from 'axios'
4
4
 
5
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
5
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
7
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
7
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @summary Updates a pet in the store with form data
11
11
  * {@link /pet/:petId}
12
12
  */
13
- async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: "POST", url: `/pet/${petId}`, params, ...config });
15
- return res.data;
13
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
15
+ return res.data
16
16
  }
17
17
 
18
- /**
18
+ /**
19
19
  * @summary Updates a pet in the store with form data
20
20
  * {@link /pet/:petId}
21
21
  */
22
- export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, options: {
23
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2];
24
- client?: Partial<RequestConfig>;
25
- shouldFetch?: boolean;
26
- } = {}) {
27
- const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {};
28
- const mutationKey = updatePetWithFormMutationKey();
29
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(shouldFetch ? mutationKey : null, async (_url) => {
30
- return updatePetWithForm(petId, params, config);
31
- }, mutationOptions);
22
+ export function useUpdatePetWithForm(
23
+ petId: UpdatePetWithFormPathParams['petId'],
24
+ params?: UpdatePetWithFormQueryParams,
25
+ options: {
26
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
27
+ client?: Partial<RequestConfig>
28
+ shouldFetch?: boolean
29
+ } = {},
30
+ ) {
31
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
32
+ const mutationKey = updatePetWithFormMutationKey()
33
+
34
+ return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
35
+ shouldFetch ? mutationKey : null,
36
+ async (_url) => {
37
+ return updatePetWithForm(petId, params, config)
38
+ },
39
+ mutationOptions,
40
+ )
32
41
  }
@@ -1,49 +1,48 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "swr";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return res.data;
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return res.data
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,49 +1,48 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "swr";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return res.data;
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return res.data
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,49 +1,48 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "swr";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return res.data;
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return res.data
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,49 +1,48 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "swr";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'swr'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
5
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
7
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
7
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
11
11
  * @summary Finds Pets by tags
12
12
  * {@link /pet/findByTags}
13
13
  */
14
- async function findPetsByTags({ params }: {
15
- params?: FindPetsByTagsQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
18
- return findPetsByTagsQueryResponse.parse(res.data);
14
+ async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
16
+ return findPetsByTagsQueryResponse.parse(res.data)
19
17
  }
20
18
 
21
- export function findPetsByTagsQueryOptions({ params }: {
22
- params?: FindPetsByTagsQueryParams;
23
- }, config: Partial<RequestConfig> = {}) {
24
- return {
25
- fetcher: async () => {
26
- return findPetsByTags({ params }, config);
27
- },
28
- };
19
+ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
20
+ return {
21
+ fetcher: async () => {
22
+ return findPetsByTags({ params }, config)
23
+ },
24
+ }
29
25
  }
30
26
 
31
- /**
27
+ /**
32
28
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
29
  * @summary Finds Pets by tags
34
30
  * {@link /pet/findByTags}
35
31
  */
36
- export function useFindPetsByTags({ params }: {
37
- params?: FindPetsByTagsQueryParams;
38
- }, options: {
39
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2];
40
- client?: Partial<RequestConfig>;
41
- shouldFetch?: boolean;
42
- } = {}) {
43
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
44
- const queryKey = findPetsByTagsQueryKey(params);
45
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
46
- ...findPetsByTagsQueryOptions({ params }, config),
47
- ...queryOptions
48
- });
32
+ export function useFindPetsByTags(
33
+ { params }: { params?: FindPetsByTagsQueryParams },
34
+ options: {
35
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
36
+ client?: Partial<RequestConfig>
37
+ shouldFetch?: boolean
38
+ } = {},
39
+ ) {
40
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
41
+
42
+ const queryKey = findPetsByTagsQueryKey(params)
43
+
44
+ return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
+ ...findPetsByTagsQueryOptions({ params }, config),
46
+ ...queryOptions,
47
+ })
49
48
  }
@@ -1,6 +1,6 @@
1
- import client from "@kubb/plugin-client/client";
1
+ import client from "@kubb/plugin-client/clients/axios";
2
2
  import useSWRMutation from "custom-swr/mutation";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { RequestConfig } from "@kubb/plugin-client/clients/axios";
4
4
 
5
5
  export const findPetsByTagsMutationKey = () => [{ "url": "/pet/findByTags" }] as const;
6
6
 
@@ -1,50 +1,53 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWR from "custom-swr";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWR from 'custom-swr'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : [])] as const;
5
+ export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams) =>
6
+ [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : [])] as const
6
7
 
7
- export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
8
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
8
9
 
9
- /**
10
+ /**
10
11
  * @summary Updates a pet in the store with form data
11
12
  * {@link /pet/:petId}
12
13
  */
13
- async function updatePetWithForm({ petId, params }: {
14
- petId: UpdatePetWithFormPathParams["petId"];
15
- params?: UpdatePetWithFormQueryParams;
16
- }, config: Partial<RequestConfig> = {}) {
17
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: "POST", url: `/pet/${petId}`, params, ...config });
18
- return res.data;
14
+ async function updatePetWithForm(
15
+ { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
16
+ config: Partial<RequestConfig> = {},
17
+ ) {
18
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
19
+ return res.data
19
20
  }
20
21
 
21
- export function updatePetWithFormQueryOptions({ petId, params }: {
22
- petId: UpdatePetWithFormPathParams["petId"];
23
- params?: UpdatePetWithFormQueryParams;
24
- }, config: Partial<RequestConfig> = {}) {
25
- return {
26
- fetcher: async () => {
27
- return updatePetWithForm({ petId, params }, config);
28
- },
29
- };
22
+ export function updatePetWithFormQueryOptions(
23
+ { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
24
+ config: Partial<RequestConfig> = {},
25
+ ) {
26
+ return {
27
+ fetcher: async () => {
28
+ return updatePetWithForm({ petId, params }, config)
29
+ },
30
+ }
30
31
  }
31
32
 
32
- /**
33
+ /**
33
34
  * @summary Updates a pet in the store with form data
34
35
  * {@link /pet/:petId}
35
36
  */
36
- export function useUpdatePetWithForm({ petId, params }: {
37
- petId: UpdatePetWithFormPathParams["petId"];
38
- params?: UpdatePetWithFormQueryParams;
39
- }, options: {
40
- query?: Parameters<typeof useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null, any>>[2];
41
- client?: Partial<RequestConfig>;
42
- shouldFetch?: boolean;
43
- } = {}) {
44
- const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {};
45
- const queryKey = updatePetWithFormQueryKey(petId, params);
46
- return useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null>(shouldFetch ? queryKey : null, {
47
- ...updatePetWithFormQueryOptions({ petId, params }, config),
48
- ...queryOptions
49
- });
37
+ export function useUpdatePetWithForm(
38
+ { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
39
+ options: {
40
+ query?: Parameters<typeof useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null, any>>[2]
41
+ client?: Partial<RequestConfig>
42
+ shouldFetch?: boolean
43
+ } = {},
44
+ ) {
45
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
46
+
47
+ const queryKey = updatePetWithFormQueryKey(petId, params)
48
+
49
+ return useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null>(shouldFetch ? queryKey : null, {
50
+ ...updatePetWithFormQueryOptions({ petId, params }, config),
51
+ ...queryOptions,
52
+ })
50
53
  }
@@ -1,32 +1,41 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWRMutation from "swr/mutation";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWRMutation from 'swr/mutation'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
5
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
7
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
7
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @summary Updates a pet in the store with form data
11
11
  * {@link /pet/:petId}
12
12
  */
13
- async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: "POST", url: `/pet/${petId}`, params, ...config });
15
- return res.data;
13
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
15
+ return res.data
16
16
  }
17
17
 
18
- /**
18
+ /**
19
19
  * @summary Updates a pet in the store with form data
20
20
  * {@link /pet/:petId}
21
21
  */
22
- export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], params?: UpdatePetWithFormQueryParams, options: {
23
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2];
24
- client?: Partial<RequestConfig>;
25
- shouldFetch?: boolean;
26
- } = {}) {
27
- const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {};
28
- const mutationKey = updatePetWithFormMutationKey();
29
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(shouldFetch ? mutationKey : null, async (_url) => {
30
- return updatePetWithForm(petId, params, config);
31
- }, mutationOptions);
22
+ export function useUpdatePetWithForm(
23
+ petId: UpdatePetWithFormPathParams['petId'],
24
+ params?: UpdatePetWithFormQueryParams,
25
+ options: {
26
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
27
+ client?: Partial<RequestConfig>
28
+ shouldFetch?: boolean
29
+ } = {},
30
+ ) {
31
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
32
+ const mutationKey = updatePetWithFormMutationKey()
33
+
34
+ return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
35
+ shouldFetch ? mutationKey : null,
36
+ async (_url) => {
37
+ return updatePetWithForm(petId, params, config)
38
+ },
39
+ mutationOptions,
40
+ )
32
41
  }
@@ -1,36 +1,45 @@
1
- import client from "@kubb/plugin-client/client";
2
- import useSWRMutation from "swr/mutation";
3
- import type { RequestConfig } from "@kubb/plugin-client/client";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import useSWRMutation from 'swr/mutation'
3
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
5
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
7
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
7
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
8
8
 
9
- /**
9
+ /**
10
10
  * @summary Updates a pet in the store with form data
11
11
  * {@link /pet/:petId}
12
12
  */
13
- async function updatePetWithForm({ petId }: {
14
- petId: UpdatePetWithFormPathParams["petId"];
15
- }, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: "POST", url: `/pet/${petId}`, params, ...config });
17
- return res.data;
13
+ async function updatePetWithForm(
14
+ { petId }: { petId: UpdatePetWithFormPathParams['petId'] },
15
+ params?: UpdatePetWithFormQueryParams,
16
+ config: Partial<RequestConfig> = {},
17
+ ) {
18
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
19
+ return res.data
18
20
  }
19
21
 
20
- /**
22
+ /**
21
23
  * @summary Updates a pet in the store with form data
22
24
  * {@link /pet/:petId}
23
25
  */
24
- export function useUpdatePetWithForm({ petId }: {
25
- petId: UpdatePetWithFormPathParams["petId"];
26
- }, params?: UpdatePetWithFormQueryParams, options: {
27
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2];
28
- client?: Partial<RequestConfig>;
29
- shouldFetch?: boolean;
30
- } = {}) {
31
- const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {};
32
- const mutationKey = updatePetWithFormMutationKey();
33
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(shouldFetch ? mutationKey : null, async (_url) => {
34
- return updatePetWithForm({ petId }, params, config);
35
- }, mutationOptions);
26
+ export function useUpdatePetWithForm(
27
+ { petId }: { petId: UpdatePetWithFormPathParams['petId'] },
28
+ params?: UpdatePetWithFormQueryParams,
29
+ options: {
30
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
31
+ client?: Partial<RequestConfig>
32
+ shouldFetch?: boolean
33
+ } = {},
34
+ ) {
35
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
36
+ const mutationKey = updatePetWithFormMutationKey()
37
+
38
+ return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
39
+ shouldFetch ? mutationKey : null,
40
+ async (_url) => {
41
+ return updatePetWithForm({ petId }, params, config)
42
+ },
43
+ mutationOptions,
44
+ )
36
45
  }
package/src/plugin.ts CHANGED
@@ -40,7 +40,7 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
40
40
  options: {
41
41
  output,
42
42
  client: {
43
- importPath: '@kubb/plugin-client/client',
43
+ importPath: '@kubb/plugin-client/clients/axios',
44
44
  dataReturnType: 'data',
45
45
  ...client,
46
46
  },