@kubb/plugin-oas 2.19.5 → 2.20.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/{OperationGenerator-BL3W1CH2.d.ts → OperationGenerator-8DNneYd8.d.ts} +4 -1
- package/dist/{OperationGenerator-B6_KXF47.d.cts → OperationGenerator-BHo9OWOG.d.cts} +4 -1
- package/dist/{chunk-3NSBUDVM.js → chunk-5PS7VSVP.js} +34 -41
- package/dist/{chunk-3NSBUDVM.js.map → chunk-5PS7VSVP.js.map} +1 -1
- package/dist/{chunk-SXUTBEJ7.js → chunk-7KC6HDZA.js} +11 -25
- package/dist/{chunk-SXUTBEJ7.js.map → chunk-7KC6HDZA.js.map} +1 -1
- package/dist/{chunk-I5KLDP43.cjs → chunk-C4DNEBEV.cjs} +65 -94
- package/dist/chunk-C4DNEBEV.cjs.map +1 -0
- package/dist/{chunk-USWJ3LIC.cjs → chunk-ERS2ZSAT.cjs} +40 -47
- package/dist/chunk-ERS2ZSAT.cjs.map +1 -0
- package/dist/{chunk-YS56QITS.cjs → chunk-GWI26OTO.cjs} +11 -25
- package/dist/chunk-GWI26OTO.cjs.map +1 -0
- package/dist/{chunk-WEZ6CODU.cjs → chunk-I5OXSD6K.cjs} +3 -3
- package/dist/{chunk-FDLHRTTS.js → chunk-N6CQRWVS.js} +2 -2
- package/dist/{chunk-CBVKDLCJ.js → chunk-YPTFMYOL.js} +45 -74
- package/dist/{chunk-CBVKDLCJ.js.map → chunk-YPTFMYOL.js.map} +1 -1
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +31 -18
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +9 -3
- package/dist/hooks.d.ts +9 -3
- package/dist/hooks.js +21 -8
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -32
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +8 -8
- package/dist/utils.js +2 -2
- package/package.json +11 -11
- package/src/OperationGenerator.ts +10 -7
- package/src/SchemaGenerator.ts +8 -2
- package/src/hooks/useOperationManager.ts +27 -7
- package/dist/chunk-I5KLDP43.cjs.map +0 -1
- package/dist/chunk-USWJ3LIC.cjs.map +0 -1
- package/dist/chunk-YS56QITS.cjs.map +0 -1
- /package/dist/{chunk-WEZ6CODU.cjs.map → chunk-I5OXSD6K.cjs.map} +0 -0
- /package/dist/{chunk-FDLHRTTS.js.map → chunk-N6CQRWVS.js.map} +0 -0
package/src/SchemaGenerator.ts
CHANGED
|
@@ -560,6 +560,12 @@ export abstract class SchemaGenerator<
|
|
|
560
560
|
type: 'type',
|
|
561
561
|
})
|
|
562
562
|
|
|
563
|
+
const nullableEnum = schema.enum.includes(null)
|
|
564
|
+
if (nullableEnum) {
|
|
565
|
+
baseItems.push({ keyword: schemaKeywords.nullable })
|
|
566
|
+
}
|
|
567
|
+
const filteredValues = schema.enum.filter((value) => value !== null)
|
|
568
|
+
|
|
563
569
|
// x-enumNames has priority
|
|
564
570
|
const extensionEnums = ['x-enumNames', 'x-enum-varnames']
|
|
565
571
|
.filter((extensionKey) => extensionKey in schema)
|
|
@@ -600,7 +606,7 @@ export abstract class SchemaGenerator<
|
|
|
600
606
|
value,
|
|
601
607
|
format: 'number',
|
|
602
608
|
}))
|
|
603
|
-
: [...new Set(
|
|
609
|
+
: [...new Set(filteredValues)].map((value: string) => {
|
|
604
610
|
return {
|
|
605
611
|
name: value,
|
|
606
612
|
value,
|
|
@@ -624,7 +630,7 @@ export abstract class SchemaGenerator<
|
|
|
624
630
|
name: enumName,
|
|
625
631
|
typeName,
|
|
626
632
|
asConst: false,
|
|
627
|
-
items: [...new Set(
|
|
633
|
+
items: [...new Set(filteredValues)].map((value: string) => ({
|
|
628
634
|
name: transformers.stringify(value),
|
|
629
635
|
value,
|
|
630
636
|
format: isNumber(value) ? 'number' : 'string',
|
|
@@ -20,14 +20,19 @@ type SchemaNames = {
|
|
|
20
20
|
query: string | undefined
|
|
21
21
|
header: string | undefined
|
|
22
22
|
}
|
|
23
|
-
responses: Record<number, string>
|
|
23
|
+
responses: { default?: string } & Record<number | string, string>
|
|
24
|
+
errors: Record<number | string, string>
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
type UseOperationManagerResult = {
|
|
27
28
|
getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string
|
|
28
29
|
getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>
|
|
29
|
-
|
|
30
|
-
getSchemas: (
|
|
30
|
+
groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames
|
|
31
|
+
getSchemas: (
|
|
32
|
+
operation: Operation,
|
|
33
|
+
params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },
|
|
34
|
+
forStatusCode?: string | number,
|
|
35
|
+
) => OperationSchemas
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
/**
|
|
@@ -72,7 +77,7 @@ export function useOperationManager(): UseOperationManagerResult {
|
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
const
|
|
80
|
+
const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {
|
|
76
81
|
const schemas = generator.getSchemas(operation)
|
|
77
82
|
|
|
78
83
|
const errors = (schemas.errors || []).reduce(
|
|
@@ -83,7 +88,7 @@ export function useOperationManager(): UseOperationManagerResult {
|
|
|
83
88
|
|
|
84
89
|
prev[acc.statusCode] = pluginManager.resolveName({
|
|
85
90
|
name: acc.name,
|
|
86
|
-
pluginKey
|
|
91
|
+
pluginKey,
|
|
87
92
|
type,
|
|
88
93
|
})
|
|
89
94
|
|
|
@@ -129,15 +134,30 @@ export function useOperationManager(): UseOperationManagerResult {
|
|
|
129
134
|
pluginKey,
|
|
130
135
|
type,
|
|
131
136
|
}),
|
|
137
|
+
['default']: pluginManager.resolveName({
|
|
138
|
+
name: schemas.response.name,
|
|
139
|
+
pluginKey,
|
|
140
|
+
type,
|
|
141
|
+
}),
|
|
132
142
|
...errors,
|
|
133
143
|
},
|
|
144
|
+
errors,
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
return {
|
|
138
149
|
getName,
|
|
139
150
|
getFile,
|
|
140
|
-
getSchemas: (operation, forStatusCode) =>
|
|
141
|
-
|
|
151
|
+
getSchemas: (operation, params, forStatusCode) =>
|
|
152
|
+
generator.getSchemas(operation, {
|
|
153
|
+
forStatusCode,
|
|
154
|
+
resolveName: (name) =>
|
|
155
|
+
pluginManager.resolveName({
|
|
156
|
+
name,
|
|
157
|
+
pluginKey: params?.pluginKey,
|
|
158
|
+
type: params?.type,
|
|
159
|
+
}),
|
|
160
|
+
}),
|
|
161
|
+
groupSchemasByName,
|
|
142
162
|
}
|
|
143
163
|
}
|