@kubb/plugin-client 5.0.0-beta.31 → 5.0.0-beta.33
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/extension.yaml +16 -42
- package/package.json +6 -6
package/extension.yaml
CHANGED
|
@@ -315,31 +315,6 @@ options:
|
|
|
315
315
|
}),
|
|
316
316
|
],
|
|
317
317
|
})
|
|
318
|
-
- name: contentType
|
|
319
|
-
type: "'application/json' | (string & {})"
|
|
320
|
-
required: false
|
|
321
|
-
description: |
|
|
322
|
-
Selects which request/response media type the generator reads from the OpenAPI spec.
|
|
323
|
-
|
|
324
|
-
When omitted, Kubb picks the first JSON-compatible media type it finds (`application/json`, `application/vnd.api+json`, anything ending in `+json`). Set this when your spec defines multiple media types for the same operation and you want a non-default one.
|
|
325
|
-
examples:
|
|
326
|
-
- name: JSON API media type
|
|
327
|
-
files:
|
|
328
|
-
- lang: typescript
|
|
329
|
-
twoslash: false
|
|
330
|
-
code: |
|
|
331
|
-
import { defineConfig } from 'kubb'
|
|
332
|
-
import { pluginTs } from '@kubb/plugin-ts'
|
|
333
|
-
|
|
334
|
-
export default defineConfig({
|
|
335
|
-
input: { path: './petStore.yaml' },
|
|
336
|
-
output: { path: './src/gen' },
|
|
337
|
-
plugins: [
|
|
338
|
-
pluginTs({
|
|
339
|
-
contentType: 'application/vnd.api+json',
|
|
340
|
-
}),
|
|
341
|
-
],
|
|
342
|
-
})
|
|
343
318
|
- name: group
|
|
344
319
|
type: Group
|
|
345
320
|
required: false
|
|
@@ -895,18 +870,18 @@ options:
|
|
|
895
870
|
|
|
896
871
|
const petClient = new Pet()
|
|
897
872
|
const pet = await petClient.getPetById({ petId: 1 })
|
|
898
|
-
- name:
|
|
873
|
+
- name: sdk
|
|
899
874
|
type: '{ className: string }'
|
|
900
875
|
required: false
|
|
901
876
|
description: |
|
|
902
|
-
Generates a single
|
|
877
|
+
Generates a single SDK class that composes the per-tag client classes into one entry point. Setting `sdk` automatically enables `clientType: 'class'`, so you only need to add `group: { type: 'tag' }` to split the clients per tag.
|
|
903
878
|
|
|
904
|
-
Use this when you want a single object to hand around your app (`api.
|
|
879
|
+
Use this when you want a single object to hand around your app (`api.petController.findById`, `api.userController.login`) instead of importing each tag client separately.
|
|
905
880
|
properties:
|
|
906
881
|
- name: className
|
|
907
882
|
type: string
|
|
908
883
|
required: true
|
|
909
|
-
description: Name of the generated
|
|
884
|
+
description: Name of the generated SDK class — used as the export name and file name.
|
|
910
885
|
examples:
|
|
911
886
|
- name: A composed PetStoreClient
|
|
912
887
|
files:
|
|
@@ -925,9 +900,8 @@ options:
|
|
|
925
900
|
pluginTs(),
|
|
926
901
|
pluginClient({
|
|
927
902
|
output: { path: './clients' },
|
|
928
|
-
clientType: 'class',
|
|
929
903
|
group: { type: 'tag' },
|
|
930
|
-
|
|
904
|
+
sdk: { className: 'PetStoreClient' },
|
|
931
905
|
}),
|
|
932
906
|
],
|
|
933
907
|
})
|
|
@@ -936,19 +910,19 @@ options:
|
|
|
936
910
|
twoslash: false
|
|
937
911
|
code: |
|
|
938
912
|
import type { Client, RequestConfig } from './.kubb/client'
|
|
939
|
-
import {
|
|
940
|
-
import {
|
|
941
|
-
import {
|
|
913
|
+
import { petController } from './petController/petController'
|
|
914
|
+
import { storeController } from './storeController/storeController'
|
|
915
|
+
import { userController } from './userController/userController'
|
|
942
916
|
|
|
943
917
|
export class PetStoreClient {
|
|
944
|
-
readonly
|
|
945
|
-
readonly
|
|
946
|
-
readonly
|
|
918
|
+
readonly petController: petController
|
|
919
|
+
readonly storeController: storeController
|
|
920
|
+
readonly userController: userController
|
|
947
921
|
|
|
948
922
|
constructor(config: Partial<RequestConfig> & { client?: Client } = {}) {
|
|
949
|
-
this.
|
|
950
|
-
this.
|
|
951
|
-
this.
|
|
923
|
+
this.petController = new petController(config)
|
|
924
|
+
this.storeController = new storeController(config)
|
|
925
|
+
this.userController = new userController(config)
|
|
952
926
|
}
|
|
953
927
|
}
|
|
954
928
|
- name: usage.ts
|
|
@@ -959,8 +933,8 @@ options:
|
|
|
959
933
|
|
|
960
934
|
const api = new PetStoreClient({ baseURL: 'https://petstore.swagger.io/v2' })
|
|
961
935
|
|
|
962
|
-
const pets = await api.
|
|
963
|
-
const user = await api.
|
|
936
|
+
const pets = await api.petController.findPetsByTags({ tags: ['available'] })
|
|
937
|
+
const user = await api.userController.getUserByName({ username: 'john' })
|
|
964
938
|
- name: bundle
|
|
965
939
|
type: boolean
|
|
966
940
|
required: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.33",
|
|
4
4
|
"description": "Generate type-safe HTTP clients from your OpenAPI specification. Supports Axios, Fetch, and custom client adapters with full TypeScript inference and zero boilerplate.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"registry": "https://registry.npmjs.org/"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@kubb/core": "5.0.0-beta.
|
|
91
|
-
"@kubb/renderer-jsx": "5.0.0-beta.
|
|
92
|
-
"@kubb/plugin-ts": "5.0.0-beta.
|
|
93
|
-
"@kubb/plugin-zod": "5.0.0-beta.
|
|
90
|
+
"@kubb/core": "5.0.0-beta.33",
|
|
91
|
+
"@kubb/renderer-jsx": "5.0.0-beta.33",
|
|
92
|
+
"@kubb/plugin-ts": "5.0.0-beta.33",
|
|
93
|
+
"@kubb/plugin-zod": "5.0.0-beta.33"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"axios": "^1.16.1",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@internals/utils": "0.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@kubb/renderer-jsx": "5.0.0-beta.
|
|
101
|
+
"@kubb/renderer-jsx": "5.0.0-beta.33",
|
|
102
102
|
"axios": "^1.7.2"
|
|
103
103
|
},
|
|
104
104
|
"peerDependenciesMeta": {
|