@kubb/plugin-oas 3.0.0-alpha.0 → 3.0.0-alpha.10
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-By5WOmWB.d.ts +165 -0
- package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
- package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
- package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
- package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
- package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
- package/dist/chunk-75BIOXB7.cjs +7 -0
- package/dist/chunk-75BIOXB7.cjs.map +1 -0
- package/dist/{chunk-UKUEVTRB.cjs → chunk-IAUV3UKH.cjs} +735 -35
- package/dist/chunk-IAUV3UKH.cjs.map +1 -0
- package/dist/{chunk-QSM6A5QX.js → chunk-M347763D.js} +714 -14
- package/dist/chunk-M347763D.js.map +1 -0
- package/dist/{chunk-GUPCIAYT.js → chunk-N7EEVJA6.js} +3 -3
- package/dist/{chunk-J7IF3KA3.cjs → chunk-NU4F7G47.cjs} +4 -16
- package/dist/chunk-NU4F7G47.cjs.map +1 -0
- package/dist/{chunk-3UN2S6P2.cjs → chunk-O76YQFZB.cjs} +3 -3
- package/dist/{chunk-3UN2S6P2.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
- package/dist/chunk-SQ64ESS4.js +7 -0
- package/dist/chunk-SQ64ESS4.js.map +1 -0
- package/dist/{chunk-Y272OQMW.js → chunk-SZDO532A.js} +3 -15
- package/dist/chunk-SZDO532A.js.map +1 -0
- package/dist/components.cjs +4 -9
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +13 -7
- package/dist/components.d.ts +13 -7
- package/dist/components.js +3 -8
- package/dist/components.js.map +1 -1
- package/dist/hooks.cjs +12 -13
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +4 -4
- package/dist/hooks.d.ts +4 -4
- package/dist/hooks.js +2 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +282 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -77
- package/dist/index.d.ts +8 -77
- package/dist/index.js +274 -223
- package/dist/index.js.map +1 -1
- package/dist/{types-BP45TdiW.d.cts → types-CZTUCaE5.d.cts} +3 -6
- package/dist/{types-BP45TdiW.d.ts → types-CZTUCaE5.d.ts} +3 -6
- package/dist/utils.cjs +12 -54
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -33
- package/dist/utils.d.ts +7 -33
- package/dist/utils.js +6 -48
- package/dist/utils.js.map +1 -1
- package/package.json +12 -11
- package/src/OperationGenerator.ts +68 -32
- package/src/SchemaGenerator.ts +32 -15
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Oas.tsx +9 -3
- package/src/components/Operation.tsx +1 -1
- package/src/components/Schema.tsx +29 -31
- package/src/generator.tsx +125 -0
- package/src/hooks/useOperationManager.ts +1 -0
- package/src/index.ts +3 -9
- package/src/plugin.ts +25 -38
- package/src/types.ts +2 -6
- package/src/utils/getParams.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/dist/OperationGenerator-B0RLFu4P.d.ts +0 -60
- package/dist/OperationGenerator-CrCcKl3S.d.cts +0 -60
- package/dist/chunk-J7IF3KA3.cjs.map +0 -1
- package/dist/chunk-K4GEQ3C2.cjs +0 -698
- package/dist/chunk-K4GEQ3C2.cjs.map +0 -1
- package/dist/chunk-QSM6A5QX.js.map +0 -1
- package/dist/chunk-UKUEVTRB.cjs.map +0 -1
- package/dist/chunk-Y272OQMW.js.map +0 -1
- package/dist/chunk-ZZ7ZC4TT.js +0 -698
- package/dist/chunk-ZZ7ZC4TT.js.map +0 -1
- package/src/utils/getGroupedByTagFiles.ts +0 -82
- /package/dist/{chunk-GUPCIAYT.js.map → chunk-N7EEVJA6.js.map} +0 -0
package/src/plugin.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { createPlugin } from '@kubb/core'
|
|
|
4
4
|
import { camelCase } from '@kubb/core/transformers'
|
|
5
5
|
|
|
6
6
|
import { getSchemas } from './utils/getSchemas.ts'
|
|
7
|
+
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
7
8
|
|
|
8
9
|
import type { Config } from '@kubb/core'
|
|
9
10
|
import type { Logger } from '@kubb/core/logger'
|
|
10
11
|
import type { Oas, OasTypes } from '@kubb/oas'
|
|
11
12
|
import type { FormatOptions } from '@kubb/oas/parser'
|
|
12
13
|
import type { PluginOas } from './types.ts'
|
|
13
|
-
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
14
14
|
|
|
15
15
|
export const pluginOasName = 'plugin-oas' satisfies PluginOas['name']
|
|
16
16
|
|
|
@@ -45,9 +45,18 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
45
45
|
|
|
46
46
|
return {
|
|
47
47
|
name: pluginOasName,
|
|
48
|
+
output:
|
|
49
|
+
output === false
|
|
50
|
+
? {
|
|
51
|
+
path: '',
|
|
52
|
+
exportType: false,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
exportType: 'barrelNamed',
|
|
56
|
+
...output,
|
|
57
|
+
},
|
|
48
58
|
options,
|
|
49
|
-
|
|
50
|
-
api() {
|
|
59
|
+
context() {
|
|
51
60
|
const { config, logger } = this
|
|
52
61
|
|
|
53
62
|
return {
|
|
@@ -66,25 +75,6 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
66
75
|
contentType,
|
|
67
76
|
}
|
|
68
77
|
},
|
|
69
|
-
resolvePath(baseName) {
|
|
70
|
-
if (output === false) {
|
|
71
|
-
return undefined
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const root = path.resolve(this.config.root, this.config.output.path)
|
|
75
|
-
|
|
76
|
-
return path.resolve(root, output.path, baseName)
|
|
77
|
-
},
|
|
78
|
-
resolveName(name, type) {
|
|
79
|
-
return camelCase(name, { isFile: type === 'file' })
|
|
80
|
-
},
|
|
81
|
-
async writeFile(path, source) {
|
|
82
|
-
if (!path.endsWith('.json') || !source) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return this.fileManager.write(path, source, { sanity: false })
|
|
87
|
-
},
|
|
88
78
|
async buildStart() {
|
|
89
79
|
if (!output) {
|
|
90
80
|
return
|
|
@@ -99,31 +89,28 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
99
89
|
},
|
|
100
90
|
})
|
|
101
91
|
await oas.dereference()
|
|
92
|
+
|
|
93
|
+
const root = path.resolve(this.config.root, this.config.output.path)
|
|
102
94
|
const schemas = getSchemas({ oas, contentType })
|
|
103
95
|
|
|
104
96
|
const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
pluginKey: this.plugin.key,
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const resvoledFileName = this.resolveName({
|
|
111
|
-
name: `${name}.json`,
|
|
112
|
-
pluginKey: [pluginOasName],
|
|
113
|
-
type: 'file',
|
|
114
|
-
}) as `${string}.json`
|
|
115
|
-
|
|
116
|
-
if (!resolvedPath) {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
97
|
+
const baseName = `${camelCase(name)}.json` as `${string}.json`
|
|
98
|
+
const resolvedPath = path.resolve(root, output.path, baseName)
|
|
119
99
|
|
|
120
100
|
await this.addFile({
|
|
121
101
|
path: resolvedPath,
|
|
122
|
-
baseName
|
|
123
|
-
source: JSON.stringify(schema),
|
|
102
|
+
baseName,
|
|
124
103
|
meta: {
|
|
125
104
|
pluginKey: this.plugin.key,
|
|
126
105
|
},
|
|
106
|
+
sources: [
|
|
107
|
+
{
|
|
108
|
+
name: camelCase(name),
|
|
109
|
+
isExportable: false,
|
|
110
|
+
isIndexable: false,
|
|
111
|
+
value: JSON.stringify(schema),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
127
114
|
})
|
|
128
115
|
}
|
|
129
116
|
|
package/src/types.ts
CHANGED
|
@@ -33,6 +33,8 @@ export type Options = {
|
|
|
33
33
|
* @default 'schemas'
|
|
34
34
|
*/
|
|
35
35
|
path: string
|
|
36
|
+
extName?: KubbFile.Extname
|
|
37
|
+
exportType?: 'barrel' | 'barrelNamed' | false
|
|
36
38
|
}
|
|
37
39
|
| false
|
|
38
40
|
/**
|
|
@@ -142,9 +144,3 @@ export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | By
|
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>
|
|
145
|
-
|
|
146
|
-
declare module '@kubb/core' {
|
|
147
|
-
export interface _Register {
|
|
148
|
-
['@kubb/plugin-oas']: PluginOas
|
|
149
|
-
}
|
|
150
|
-
}
|
package/src/utils/getParams.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { isParameterObject } from '@kubb/oas'
|
|
|
2
2
|
|
|
3
3
|
import type { FunctionParamsAST } from '@kubb/core/utils'
|
|
4
4
|
import type { OasTypes } from '@kubb/oas'
|
|
5
|
-
import type { Params } from '@kubb/react'
|
|
5
|
+
import type { Params } from '@kubb/react/types'
|
|
6
6
|
import type { OperationSchema } from '../types.ts'
|
|
7
7
|
import { camelCase } from '@kubb/core/transformers'
|
|
8
8
|
/**
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { getComments } from './getComments.ts'
|
|
2
|
-
export { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'
|
|
3
2
|
export { getASTParams, getPathParams } from './getParams.ts'
|
|
4
3
|
export { getSchemaFactory } from './getSchemaFactory.ts'
|
|
5
4
|
export type { GetSchemasProps } from './getSchemas.ts'
|
|
6
5
|
export { getSchemas } from './getSchemas.ts'
|
|
7
6
|
export { refsSorter } from './refSorter.ts'
|
|
8
7
|
export { parseFromConfig } from './parseFromConfig.ts'
|
|
8
|
+
|
|
9
|
+
export { isOptional } from '@kubb/oas'
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-BP45TdiW.js';
|
|
5
|
-
|
|
6
|
-
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
7
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
8
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
9
|
-
oas: Oas;
|
|
10
|
-
exclude: Array<Exclude> | undefined;
|
|
11
|
-
include: Array<Include> | undefined;
|
|
12
|
-
override: Array<Override<TOptions>> | undefined;
|
|
13
|
-
contentType: contentType | undefined;
|
|
14
|
-
pluginManager: PluginManager;
|
|
15
|
-
/**
|
|
16
|
-
* Current plugin
|
|
17
|
-
*/
|
|
18
|
-
plugin: Plugin<TPluginOptions>;
|
|
19
|
-
mode: KubbFile.Mode;
|
|
20
|
-
};
|
|
21
|
-
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
22
|
-
#private;
|
|
23
|
-
get operationsByMethod(): OperationsByMethod;
|
|
24
|
-
set operationsByMethod(paths: OperationsByMethod);
|
|
25
|
-
getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
|
|
26
|
-
forStatusCode?: string | number;
|
|
27
|
-
resolveName?: (name: string) => string;
|
|
28
|
-
}): OperationSchemas;
|
|
29
|
-
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
30
|
-
/**
|
|
31
|
-
* Operation
|
|
32
|
-
*/
|
|
33
|
-
operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* GET
|
|
36
|
-
*/
|
|
37
|
-
get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
-
/**
|
|
39
|
-
* POST
|
|
40
|
-
*/
|
|
41
|
-
post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
-
/**
|
|
43
|
-
* PATCH
|
|
44
|
-
*/
|
|
45
|
-
patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
-
/**
|
|
47
|
-
* PUT
|
|
48
|
-
*/
|
|
49
|
-
put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
-
/**
|
|
51
|
-
* DELETE
|
|
52
|
-
*/
|
|
53
|
-
delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
54
|
-
/**
|
|
55
|
-
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
56
|
-
*/
|
|
57
|
-
all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-BP45TdiW.cjs';
|
|
5
|
-
|
|
6
|
-
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
7
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
8
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
9
|
-
oas: Oas;
|
|
10
|
-
exclude: Array<Exclude> | undefined;
|
|
11
|
-
include: Array<Include> | undefined;
|
|
12
|
-
override: Array<Override<TOptions>> | undefined;
|
|
13
|
-
contentType: contentType | undefined;
|
|
14
|
-
pluginManager: PluginManager;
|
|
15
|
-
/**
|
|
16
|
-
* Current plugin
|
|
17
|
-
*/
|
|
18
|
-
plugin: Plugin<TPluginOptions>;
|
|
19
|
-
mode: KubbFile.Mode;
|
|
20
|
-
};
|
|
21
|
-
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
22
|
-
#private;
|
|
23
|
-
get operationsByMethod(): OperationsByMethod;
|
|
24
|
-
set operationsByMethod(paths: OperationsByMethod);
|
|
25
|
-
getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
|
|
26
|
-
forStatusCode?: string | number;
|
|
27
|
-
resolveName?: (name: string) => string;
|
|
28
|
-
}): OperationSchemas;
|
|
29
|
-
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
30
|
-
/**
|
|
31
|
-
* Operation
|
|
32
|
-
*/
|
|
33
|
-
operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* GET
|
|
36
|
-
*/
|
|
37
|
-
get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
-
/**
|
|
39
|
-
* POST
|
|
40
|
-
*/
|
|
41
|
-
post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
-
/**
|
|
43
|
-
* PATCH
|
|
44
|
-
*/
|
|
45
|
-
patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
-
/**
|
|
47
|
-
* PUT
|
|
48
|
-
*/
|
|
49
|
-
put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
-
/**
|
|
51
|
-
* DELETE
|
|
52
|
-
*/
|
|
53
|
-
delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
54
|
-
/**
|
|
55
|
-
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
56
|
-
*/
|
|
57
|
-
all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-J7IF3KA3.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.15__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":[],"mappings":"AAAA,ilBAAI,SAAS,EAAE,MAAM,CAAC,MAAM;AAC5B,IAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,iBAAiB,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG;AAC3B,EAAE,MAAM,SAAS,CAAC,GAAG,CAAC;AACtB,CAAC;AACD,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,G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,4UAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-J7IF3KA3.cjs","sourcesContent":[null,"// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\nexport type GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n","import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schema,\n version,\n } as SchemaResult<TWithRef>\n }\n}\n"]}
|