@kubb/plugin-oas 3.0.0-alpha.6 → 3.0.0-alpha.8
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-Dzs1oRvm.d.ts → OperationGenerator-DeXrfGDC.d.ts} +2 -2
- package/dist/{OperationGenerator-Do52cvD0.d.cts → OperationGenerator-DhJ0MBKc.d.cts} +2 -2
- package/dist/{Schema-C90zFdkU.d.ts → Schema-B1vcPGiK.d.ts} +2 -4
- package/dist/{Schema-DDVEcNcu.d.cts → Schema-DoSFh7Qd.d.cts} +2 -4
- package/dist/{SchemaMapper-BM1IGWqD.d.cts → SchemaMapper-sGcY1xL5.d.cts} +0 -1
- package/dist/{SchemaMapper-BM1IGWqD.d.ts → SchemaMapper-sGcY1xL5.d.ts} +0 -1
- package/dist/chunk-75BIOXB7.cjs +7 -0
- package/dist/{chunk-7KIEQOVZ.cjs.map → chunk-75BIOXB7.cjs.map} +1 -1
- package/dist/{chunk-UJNAXXVE.js → chunk-MUI5DWM3.js} +458 -465
- package/dist/{chunk-UJNAXXVE.js.map → chunk-MUI5DWM3.js.map} +1 -1
- package/dist/{chunk-Y4V7HHX7.js → chunk-N7EEVJA6.js} +3 -3
- package/dist/{chunk-P42X362U.cjs → chunk-NU4F7G47.cjs} +4 -16
- package/dist/chunk-NU4F7G47.cjs.map +1 -0
- package/dist/{chunk-QLJIL3U5.cjs → chunk-O76YQFZB.cjs} +3 -3
- package/dist/{chunk-QLJIL3U5.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
- package/dist/{chunk-TWKZEVSM.js → chunk-SQ64ESS4.js} +2 -2
- package/dist/{chunk-UB552H4J.js → chunk-SZDO532A.js} +3 -15
- package/dist/{chunk-UB552H4J.js.map → chunk-SZDO532A.js.map} +1 -1
- package/dist/{chunk-RQZBFORW.cjs → chunk-VSVVTCQB.cjs} +481 -488
- package/dist/chunk-VSVVTCQB.cjs.map +1 -0
- package/dist/components.cjs +4 -4
- package/dist/components.d.cts +4 -4
- package/dist/components.d.ts +4 -4
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +12 -12
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +3 -3
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +2 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +112 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +83 -86
- package/dist/index.js.map +1 -1
- package/dist/{types-C2RXaY0_.d.cts → types-CZTUCaE5.d.cts} +2 -0
- package/dist/{types-C2RXaY0_.d.ts → types-CZTUCaE5.d.ts} +2 -0
- package/dist/utils.cjs +9 -54
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -35
- package/dist/utils.d.ts +5 -35
- package/dist/utils.js +2 -47
- package/dist/utils.js.map +1 -1
- package/package.json +9 -9
- package/src/SchemaGenerator.ts +2 -2
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Schema.tsx +8 -4
- package/src/hooks/useOperationManager.ts +1 -0
- package/src/plugin.ts +11 -0
- package/src/types.ts +2 -0
- package/src/utils/index.ts +0 -1
- package/dist/chunk-7KIEQOVZ.cjs +0 -7
- package/dist/chunk-P42X362U.cjs.map +0 -1
- package/dist/chunk-RQZBFORW.cjs.map +0 -1
- package/src/utils/getGroupedByTagFiles.ts +0 -84
- /package/dist/{chunk-Y4V7HHX7.js.map → chunk-N7EEVJA6.js.map} +0 -0
- /package/dist/{chunk-TWKZEVSM.js.map → chunk-SQ64ESS4.js.map} +0 -0
package/dist/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFromConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N7EEVJA6.js";
|
|
4
4
|
import {
|
|
5
5
|
getSchemaFactory,
|
|
6
6
|
getSchemas,
|
|
7
7
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SZDO532A.js";
|
|
9
9
|
|
|
10
10
|
// src/utils/index.ts
|
|
11
11
|
init_esm_shims();
|
|
@@ -23,50 +23,6 @@ function getComments(operation) {
|
|
|
23
23
|
].filter(Boolean).map((text) => transformers.trim(text));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// src/utils/getGroupedByTagFiles.ts
|
|
27
|
-
init_esm_shims();
|
|
28
|
-
import { resolve } from "path";
|
|
29
|
-
import { FileManager } from "@kubb/core";
|
|
30
|
-
import transformers2 from "@kubb/core/transformers";
|
|
31
|
-
import { renderTemplate } from "@kubb/core/utils";
|
|
32
|
-
import { getRelativePath } from "@kubb/fs";
|
|
33
|
-
async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }) {
|
|
34
|
-
const { path, exportType = "barrel" } = output;
|
|
35
|
-
const mode = FileManager.getMode(resolve(root, path));
|
|
36
|
-
if (mode === "single" || exportType === false) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
return files.filter((file) => {
|
|
40
|
-
const name = file.meta?.pluginKey?.[0];
|
|
41
|
-
return name === plugin.name;
|
|
42
|
-
}).map((file) => {
|
|
43
|
-
if (!file.meta?.tag) {
|
|
44
|
-
logger?.emit("debug", { logs: [`Could not find a tagName for ${JSON.stringify(file, void 0, 2)}`] });
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const tag = file.meta?.tag && transformers2.camelCase(file.meta.tag);
|
|
48
|
-
const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })));
|
|
49
|
-
const tagName = renderTemplate(exportAs, { tag });
|
|
50
|
-
if (tagName) {
|
|
51
|
-
return {
|
|
52
|
-
baseName: "index.ts",
|
|
53
|
-
path: resolve(root, output.path, "index.ts"),
|
|
54
|
-
exports: [
|
|
55
|
-
{
|
|
56
|
-
path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
|
|
57
|
-
asAlias: true,
|
|
58
|
-
name: tagName
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
meta: {
|
|
62
|
-
pluginKey: plugin.key
|
|
63
|
-
},
|
|
64
|
-
sources: []
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}).filter(Boolean);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
26
|
// src/utils/getParams.ts
|
|
71
27
|
init_esm_shims();
|
|
72
28
|
import { isParameterObject } from "@kubb/oas";
|
|
@@ -116,7 +72,6 @@ function refsSorter(a, b) {
|
|
|
116
72
|
export {
|
|
117
73
|
getASTParams,
|
|
118
74
|
getComments,
|
|
119
|
-
getGroupedByTagFiles,
|
|
120
75
|
getPathParams,
|
|
121
76
|
getSchemaFactory,
|
|
122
77
|
getSchemas,
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"sourcesContent":["export { getComments } from './getComments.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react/types'\nimport type { OperationSchema } from '../types.ts'\nimport { camelCase } from '@kubb/core/transformers'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[camelCase(curr.name)] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,kBAAkB;AACzB,SAAS,eAAe;AAIjB,SAAS,YAAY,WAAgC;AAC1D,SAAO;AAAA,IACL,UAAU,eAAe,KAAK,gBAAgB,UAAU,eAAe,CAAC;AAAA,IACxE,UAAU,WAAW,KAAK,YAAY,UAAU,WAAW,CAAC;AAAA,IAC5D,UAAU,QAAQ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AACA,MAAI,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,SAAS,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,QAAQ;AAC3E,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"description": "Generator swagger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@stoplight/yaml": "^4.3.0",
|
|
70
70
|
"remeda": "^2.11.0",
|
|
71
|
-
"@kubb/core": "3.0.0-alpha.
|
|
72
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
73
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
74
|
-
"@kubb/react": "3.0.0-alpha.
|
|
71
|
+
"@kubb/core": "3.0.0-alpha.8",
|
|
72
|
+
"@kubb/fs": "3.0.0-alpha.8",
|
|
73
|
+
"@kubb/oas": "3.0.0-alpha.8",
|
|
74
|
+
"@kubb/react": "3.0.0-alpha.8"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/react": "^18.3.4",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"react": "^18.3.1",
|
|
80
80
|
"tsup": "^8.2.4",
|
|
81
81
|
"typescript": "^5.5.4",
|
|
82
|
-
"@kubb/config-biome": "3.0.0-alpha.
|
|
83
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
84
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
82
|
+
"@kubb/config-biome": "3.0.0-alpha.8",
|
|
83
|
+
"@kubb/config-ts": "3.0.0-alpha.8",
|
|
84
|
+
"@kubb/config-tsup": "3.0.0-alpha.8"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@kubb/react": "3.0.0-alpha.
|
|
87
|
+
"@kubb/react": "3.0.0-alpha.8"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=20"
|
package/src/SchemaGenerator.ts
CHANGED
|
@@ -13,8 +13,8 @@ import type * as KubbFile from '@kubb/fs/types'
|
|
|
13
13
|
|
|
14
14
|
import type { Oas, OpenAPIV3, SchemaObject, contentType } from '@kubb/oas'
|
|
15
15
|
import type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'
|
|
16
|
-
import type { OperationSchema, Override, Refs } from './types.ts'
|
|
17
16
|
import type { Parser } from './parser.tsx'
|
|
17
|
+
import type { OperationSchema, Override, Refs } from './types.ts'
|
|
18
18
|
|
|
19
19
|
export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
|
|
20
20
|
|
|
@@ -361,7 +361,7 @@ export class SchemaGenerator<
|
|
|
361
361
|
return [
|
|
362
362
|
{
|
|
363
363
|
keyword: schemaKeywords.ref,
|
|
364
|
-
args: { name: ref.propertyName, path: ref?.path
|
|
364
|
+
args: { name: ref.propertyName, path: ref?.path },
|
|
365
365
|
},
|
|
366
366
|
]
|
|
367
367
|
}
|
package/src/SchemaMapper.ts
CHANGED
|
@@ -51,7 +51,7 @@ export type SchemaKeywordMapper = {
|
|
|
51
51
|
union: { keyword: 'union'; args: Schema[] }
|
|
52
52
|
ref: {
|
|
53
53
|
keyword: 'ref'
|
|
54
|
-
args: { name: string; path: KubbFile.OptionalPath
|
|
54
|
+
args: { name: string; path: KubbFile.OptionalPath }
|
|
55
55
|
}
|
|
56
56
|
matches: { keyword: 'matches'; args?: string }
|
|
57
57
|
boolean: { keyword: 'boolean' }
|
|
@@ -44,7 +44,12 @@ Schema.File = function ({ output, isTypeOnly, children }: FileProps): ReactNode
|
|
|
44
44
|
const { name } = useSchema()
|
|
45
45
|
|
|
46
46
|
if (mode === 'single') {
|
|
47
|
-
const baseName =
|
|
47
|
+
const baseName = `${pluginManager.resolveName({
|
|
48
|
+
name,
|
|
49
|
+
pluginKey: plugin.key,
|
|
50
|
+
type: 'file',
|
|
51
|
+
})}.ts` as const
|
|
52
|
+
|
|
48
53
|
const resolvedPath = pluginManager.resolvePath({
|
|
49
54
|
baseName: '',
|
|
50
55
|
pluginKey: plugin.key,
|
|
@@ -97,10 +102,9 @@ Schema.File = function ({ output, isTypeOnly, children }: FileProps): ReactNode
|
|
|
97
102
|
|
|
98
103
|
type SchemaImportsProps = {
|
|
99
104
|
isTypeOnly?: boolean
|
|
100
|
-
extName?: KubbFile.Extname
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
Schema.Imports = ({ isTypeOnly
|
|
107
|
+
Schema.Imports = ({ isTypeOnly }: SchemaImportsProps): ReactNode => {
|
|
104
108
|
const { tree } = useSchema()
|
|
105
109
|
const { path: root } = useFile()
|
|
106
110
|
|
|
@@ -114,7 +118,7 @@ Schema.Imports = ({ isTypeOnly, extName }: SchemaImportsProps): ReactNode => {
|
|
|
114
118
|
return undefined
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
return <File.Import key={i} root={root} name={[item.args.name]} path={item.args.path} isTypeOnly={
|
|
121
|
+
return <File.Import key={i} root={root} name={[item.args.name]} path={item.args.path} isTypeOnly={isTypeOnly} />
|
|
118
122
|
})
|
|
119
123
|
.filter(Boolean)}
|
|
120
124
|
</>
|
|
@@ -57,6 +57,7 @@ export function useOperationManager(): UseOperationManagerResult {
|
|
|
57
57
|
const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {
|
|
58
58
|
// needed for the `output.group`
|
|
59
59
|
const tag = operation.getTags().at(0)?.name
|
|
60
|
+
//TODO replace with group
|
|
60
61
|
const name = getName(operation, { type: 'file', pluginKey })
|
|
61
62
|
|
|
62
63
|
const file = pluginManager.getFile({
|
package/src/plugin.ts
CHANGED
|
@@ -45,6 +45,16 @@ 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
59
|
context() {
|
|
50
60
|
const { config, logger } = this
|
|
@@ -97,6 +107,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
97
107
|
{
|
|
98
108
|
name: camelCase(name),
|
|
99
109
|
isExportable: false,
|
|
110
|
+
isIndexable: false,
|
|
100
111
|
value: JSON.stringify(schema),
|
|
101
112
|
},
|
|
102
113
|
],
|
package/src/types.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
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'
|
package/dist/chunk-7KIEQOVZ.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-P42X362U.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.1__jiti@1.21.6_postcss@8.4.41_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,E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/B,SAAS,gBAAA,CAAmD,GAAA,EAA6D;AAC9H,EAAA,OAAO,CAAC,MAAA,EAAA,GAA0B;AAChC,IAAA,MAAM,QAAA,EAAU,wCAAA,GAAsB,CAAI,GAAG,EAAA,EAAI,MAAA,EAAQ,KAAA;AAEzD,IAAA,OAAO;AAAA,MACL,MAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF;AHwDA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,4UAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-P42X362U.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"]}
|