@kubb/plugin-oas 4.4.0 → 4.5.0
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/{SchemaGenerator-7wBwdv8G.js → SchemaGenerator-BwYbrh7a.js} +93 -36
- package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
- package/dist/{SchemaGenerator-DzVHk6OP.cjs → SchemaGenerator-C81yEgKY.cjs} +114 -37
- package/dist/SchemaGenerator-C81yEgKY.cjs.map +1 -0
- package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
- package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
- package/dist/{SchemaMapper-CqBW0VOy.d.ts → SchemaMapper-CgGWx6jF.d.cts} +15 -116
- package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +15 -116
- package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
- package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
- package/dist/{OperationGenerator-BZPWkxw4.d.ts → createGenerator-BvCDyuKS.d.ts} +128 -191
- package/dist/{OperationGenerator-CJTAer7l.d.cts → createGenerator-CPNglV1d.d.cts} +129 -192
- package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
- package/dist/generators-CJDEf8Kn.js.map +1 -0
- package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
- package/dist/generators-udGOxdUV.cjs.map +1 -0
- package/dist/generators.cjs +2 -7
- package/dist/generators.d.cts +8 -3
- package/dist/generators.d.ts +8 -3
- package/dist/generators.js +3 -5
- package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
- package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
- package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
- package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
- package/dist/getSchemas-32BHoMO-.js +100 -0
- package/dist/getSchemas-32BHoMO-.js.map +1 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs +113 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs.map +1 -0
- package/dist/hooks.cjs +6 -47
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +11 -45
- package/dist/hooks.d.ts +11 -45
- package/dist/hooks.js +8 -46
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -3
- package/dist/index.d.ts +58 -3
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
- package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
- package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
- package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +28 -24
- package/dist/utils.d.ts +28 -24
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +14 -17
- package/src/OperationGenerator.ts +27 -14
- package/src/SchemaGenerator.ts +25 -47
- package/src/SchemaMapper.ts +3 -1
- package/src/generators/createGenerator.ts +1 -1
- package/src/generators/index.ts +0 -1
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/generators/types.ts +13 -14
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useOas.ts +5 -11
- package/src/hooks/useOperationManager.ts +3 -5
- package/src/hooks/useSchemaManager.ts +1 -1
- package/src/index.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/getBanner.ts +1 -1
- package/src/utils/getParams.ts +1 -2
- package/src/utils/getSchemaFactory.ts +1 -2
- package/src/utils/getSchemas.ts +89 -15
- package/src/utils/index.ts +3 -4
- package/src/utils/parseFromConfig.ts +2 -6
- package/src/utils.tsx +101 -0
- package/dist/Oas-BzrQ6RGC.cjs +0 -80
- package/dist/Oas-BzrQ6RGC.cjs.map +0 -1
- package/dist/Oas-CIeHKOo0.js +0 -60
- package/dist/Oas-CIeHKOo0.js.map +0 -1
- package/dist/Schema-CjraJhJi.d.ts +0 -38
- package/dist/Schema-zcZF0UIp.d.cts +0 -38
- package/dist/SchemaGenerator-7wBwdv8G.js.map +0 -1
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +0 -1
- package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
- package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
- package/dist/components.cjs +0 -5
- package/dist/components.d.cts +0 -42
- package/dist/components.d.ts +0 -42
- package/dist/components.js +0 -3
- package/dist/generators-B27La9Vd.cjs.map +0 -1
- package/dist/generators-C61FxVIj.js.map +0 -1
- package/dist/getSchemas-Bdg6n9Qk.js +0 -55
- package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
- package/dist/getSchemas-DY8s2CSl.cjs +0 -68
- package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
- package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
- package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
- package/dist/utils-BnkB1ikY.js +0 -99
- package/dist/utils-BnkB1ikY.js.map +0 -1
- package/dist/utils-nzdccPlU.cjs +0 -119
- package/dist/utils-nzdccPlU.cjs.map +0 -1
- package/src/components/Oas.tsx +0 -35
- package/src/components/Operation.tsx +0 -20
- package/src/components/Schema.tsx +0 -38
- package/src/components/index.ts +0 -3
- package/src/generators/utils.tsx +0 -114
- package/src/hooks/useOperation.ts +0 -18
- package/src/hooks/useOperations.ts +0 -40
- package/src/hooks/useSchema.ts +0 -16
package/src/generators/utils.tsx
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { PluginFactoryOptions } from '@kubb/core'
|
|
2
|
-
import type { Operation, SchemaObject } from '@kubb/oas'
|
|
3
|
-
import { App, createReactFabric, type Fabric } from '@kubb/react-fabric'
|
|
4
|
-
import { Oas } from '../components/Oas.tsx'
|
|
5
|
-
import type { OperationGenerator } from '../OperationGenerator.ts'
|
|
6
|
-
import type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'
|
|
7
|
-
import type { Schema } from '../SchemaMapper.ts'
|
|
8
|
-
import type { ReactGenerator } from './/createReactGenerator.ts'
|
|
9
|
-
|
|
10
|
-
type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
|
|
11
|
-
fabric: Fabric
|
|
12
|
-
generator: ReactGenerator<any>
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>
|
|
17
|
-
options: TOptions['resolvedOptions']
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function buildOperations<TOptions extends PluginFactoryOptions>(
|
|
21
|
-
operations: Array<Operation>,
|
|
22
|
-
{ fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,
|
|
23
|
-
): Promise<void> {
|
|
24
|
-
if (!generator.Operations) {
|
|
25
|
-
return undefined
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
29
|
-
|
|
30
|
-
function Component() {
|
|
31
|
-
return (
|
|
32
|
-
<App meta={{ pluginManager, plugin, mode }}>
|
|
33
|
-
<Oas oas={oas} operations={operations} generator={instance}>
|
|
34
|
-
<generator.Operations operations={operations} instance={instance} options={options} />
|
|
35
|
-
</Oas>
|
|
36
|
-
</App>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const fabricChild = createReactFabric()
|
|
41
|
-
fabricChild.render(Component)
|
|
42
|
-
|
|
43
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>
|
|
47
|
-
|
|
48
|
-
export async function buildOperation<TOptions extends PluginFactoryOptions>(
|
|
49
|
-
operation: Operation,
|
|
50
|
-
{ fabric, options, instance, generator }: BuildOperationOptions<TOptions>,
|
|
51
|
-
): Promise<void> {
|
|
52
|
-
if (!generator.Operation) {
|
|
53
|
-
return undefined
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
57
|
-
|
|
58
|
-
function Component() {
|
|
59
|
-
return (
|
|
60
|
-
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
|
|
61
|
-
<Oas oas={oas} operations={[operation]} generator={instance}>
|
|
62
|
-
<Oas.Operation operation={operation}>
|
|
63
|
-
<generator.Operation operation={operation} options={options} instance={instance} />
|
|
64
|
-
</Oas.Operation>
|
|
65
|
-
</Oas>
|
|
66
|
-
</App>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
const fabricChild = createReactFabric()
|
|
70
|
-
fabricChild.render(Component)
|
|
71
|
-
|
|
72
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
|
|
76
|
-
fabric: Fabric
|
|
77
|
-
generator: ReactGenerator<any>
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated
|
|
80
|
-
*/
|
|
81
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
|
|
82
|
-
options: TOptions['resolvedOptions']
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export async function buildSchema<TOptions extends PluginFactoryOptions>(
|
|
86
|
-
schema: {
|
|
87
|
-
name: string
|
|
88
|
-
tree: Array<Schema>
|
|
89
|
-
value: SchemaObject
|
|
90
|
-
},
|
|
91
|
-
{ fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,
|
|
92
|
-
): Promise<void> {
|
|
93
|
-
if (!generator.Schema) {
|
|
94
|
-
return undefined
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { pluginManager, oas, plugin, mode } = instance.context
|
|
98
|
-
|
|
99
|
-
function Component() {
|
|
100
|
-
return (
|
|
101
|
-
<App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
|
|
102
|
-
<Oas oas={oas}>
|
|
103
|
-
<Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>
|
|
104
|
-
<generator.Schema schema={schema} options={options} instance={instance} />
|
|
105
|
-
</Oas.Schema>
|
|
106
|
-
</Oas>
|
|
107
|
-
</App>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
const fabricChild = createReactFabric()
|
|
111
|
-
fabricChild.render(Component)
|
|
112
|
-
|
|
113
|
-
await fabric.context.fileManager.add(...fabricChild.files)
|
|
114
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContext } from '@kubb/react-fabric'
|
|
2
|
-
|
|
3
|
-
import { Operation } from '../components/Operation.tsx'
|
|
4
|
-
|
|
5
|
-
import type { Operation as OperationType } from '@kubb/oas'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `useOperation` will return the current `Operation`
|
|
9
|
-
*/
|
|
10
|
-
export function useOperation(): OperationType {
|
|
11
|
-
const { operation } = useContext(Operation.Context)
|
|
12
|
-
|
|
13
|
-
if (!operation) {
|
|
14
|
-
throw new Error('Operation is not defined')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return operation
|
|
18
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useContext } from '@kubb/react-fabric'
|
|
2
|
-
|
|
3
|
-
import { Oas } from '../components/Oas.tsx'
|
|
4
|
-
|
|
5
|
-
import type { HttpMethod, Operation } from '@kubb/oas'
|
|
6
|
-
|
|
7
|
-
type UseOperationsProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Filter based on path
|
|
10
|
-
* Weight: 2
|
|
11
|
-
*/
|
|
12
|
-
path?: string
|
|
13
|
-
/**
|
|
14
|
-
* Filter based on method
|
|
15
|
-
* Weight: 1
|
|
16
|
-
*/
|
|
17
|
-
method?: HttpMethod
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* `useOperations` will return all the Operations
|
|
22
|
-
*/
|
|
23
|
-
export function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {
|
|
24
|
-
const { operations } = useContext(Oas.Context)
|
|
25
|
-
|
|
26
|
-
if (!operations) {
|
|
27
|
-
throw new Error('Operations is not defined')
|
|
28
|
-
}
|
|
29
|
-
let items = operations
|
|
30
|
-
|
|
31
|
-
if (path) {
|
|
32
|
-
items = items.filter((item) => item.path === path)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (method) {
|
|
36
|
-
items = items.filter((item) => item.method === method)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return items
|
|
40
|
-
}
|
package/src/hooks/useSchema.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useContext } from '@kubb/react-fabric'
|
|
2
|
-
|
|
3
|
-
import { Schema } from '../components/Schema.tsx'
|
|
4
|
-
|
|
5
|
-
import type { SchemaContextProps } from '../components/Schema.tsx'
|
|
6
|
-
|
|
7
|
-
type UseSchemaResult = SchemaContextProps
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* `useSchema` will return the current `schema properties`
|
|
11
|
-
*/
|
|
12
|
-
export function useSchema(): UseSchemaResult {
|
|
13
|
-
const props = useContext(Schema.Context)
|
|
14
|
-
|
|
15
|
-
return props as UseSchemaResult
|
|
16
|
-
}
|