@kubb/plugin-oas 2.25.1 → 2.25.3
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/{Schema-DefwBJMc.d.ts → Schema-CkGDfE-r.d.ts} +1 -1
- package/dist/{Schema-an5hOrjZ.d.cts → Schema-CxKiczSe.d.cts} +1 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-BLcXlDBz.d.cts} +0 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-BLcXlDBz.d.ts} +0 -1
- package/dist/{chunk-6QFVU3BI.js → chunk-7NYIF73B.js} +4 -4
- package/dist/{chunk-6QFVU3BI.js.map → chunk-7NYIF73B.js.map} +1 -1
- package/dist/{chunk-KGR7UP2W.js → chunk-C7EB64G2.js} +6 -3
- package/dist/chunk-C7EB64G2.js.map +1 -0
- package/dist/{chunk-M62LERKB.cjs → chunk-IOHUYXT5.cjs} +25 -22
- package/dist/chunk-IOHUYXT5.cjs.map +1 -0
- package/dist/{chunk-PHNRHM3I.cjs → chunk-P42X362U.cjs} +3 -3
- package/dist/chunk-P42X362U.cjs.map +1 -0
- package/dist/{chunk-DHPXS6V7.cjs → chunk-QLJIL3U5.cjs} +3 -3
- package/dist/{chunk-DHPXS6V7.cjs.map → chunk-QLJIL3U5.cjs.map} +1 -1
- package/dist/{chunk-NLQIW5KR.cjs → chunk-REUEIIL3.cjs} +25 -25
- package/dist/{chunk-NLQIW5KR.cjs.map → chunk-REUEIIL3.cjs.map} +1 -1
- package/dist/{chunk-E4NYDEAU.js → chunk-UB552H4J.js} +3 -3
- package/dist/chunk-UB552H4J.js.map +1 -0
- package/dist/{chunk-7BYOJGO3.js → chunk-Y4V7HHX7.js} +2 -2
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +13 -13
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +3 -3
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/utils.cjs +8 -8
- package/dist/utils.js +2 -2
- package/package.json +11 -11
- package/src/SchemaGenerator.ts +6 -2
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Schema.tsx +1 -3
- package/dist/chunk-E4NYDEAU.js.map +0 -1
- package/dist/chunk-KGR7UP2W.js.map +0 -1
- package/dist/chunk-M62LERKB.cjs.map +0 -1
- package/dist/chunk-PHNRHM3I.cjs.map +0 -1
- /package/dist/{chunk-7BYOJGO3.js.map → chunk-Y4V7HHX7.js.map} +0 -0
|
@@ -35,9 +35,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
35
35
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
36
36
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
37
37
|
|
|
38
|
-
// ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.
|
|
38
|
+
// ../../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/esm_shims.js
|
|
39
39
|
var init_esm_shims = __esm({
|
|
40
|
-
"../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.
|
|
40
|
+
"../../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/esm_shims.js"() {
|
|
41
41
|
"use strict";
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -98,4 +98,4 @@ export {
|
|
|
98
98
|
getSchemas,
|
|
99
99
|
getSchemaFactory
|
|
100
100
|
};
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-UB552H4J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../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/esm_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAUO,SAAS,WAAW,EAAE,KAAK,aAAa,WAAW,CAAC,WAAW,iBAAiB,WAAW,EAAE,GAA2D;AAC7J,QAAM,aAAa,IAAI,cAAc,EAAE;AAEvC,MAAI,UAAiD,CAAC;AAEtD,MAAI,SAAS,SAAS,SAAS,GAAG;AAChC,cAAU;AAAA,MACR,GAAG;AAAA,MACH,GAAK,YAAY,WAAqD,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,iBAAiB,CAAC;AACpD,MAAI,SAAS,SAAS,WAAW,GAAG;AAClC,UAAM,YAAY,YAAY,aAAa,CAAC;AAE5C,WAAO,QAAQ,SAAS,EAAE,QAAQ,CAAC,CAAC,MAAM,QAAQ,MAAyC;AACzF,UAAI,SAAS,WAAW,CAAC,QAAQ,IAAI,GAAG;AACtC,cAAM,mBAAmB,OAAO,KAAK,SAAS,OAAO,EAAE,CAAC,KAAK;AAC7D,gBAAQ,IAAI,IAAI,SAAS,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACvE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,WAAO,QAAQ,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,OAAO,MAA4C;AAC/F,UAAI,QAAQ,WAAW,CAAC,QAAQ,IAAI,GAAG;AACrC,cAAM,mBAAmB,OAAO,KAAK,QAAQ,OAAO,EAAE,CAAC,KAAK;AAC5D,gBAAQ,IAAI,IAAI,QAAQ,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACtE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;AC5CA;AAAA,SAAS,6BAA6B;AAuB/B,SAAS,iBAAmD,KAA6D;AAC9H,SAAO,CAAC,WAA0B;AAChC,UAAM,UAAU,sBAAsB,IAAI,GAAG,IAAI,QAAQ;AAEzD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_esm_shims
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UB552H4J.js";
|
|
4
4
|
|
|
5
5
|
// src/utils/parseFromConfig.ts
|
|
6
6
|
init_esm_shims();
|
|
@@ -32,4 +32,4 @@ function parseFromConfig(config, options = {}, oasClass = Oas) {
|
|
|
32
32
|
export {
|
|
33
33
|
parseFromConfig
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-Y4V7HHX7.js.map
|
package/dist/components.cjs
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunkREUEIIL3cjs = require('./chunk-REUEIIL3.cjs');
|
|
6
|
+
require('./chunk-IOHUYXT5.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
10
10
|
|
|
11
11
|
// src/components/index.ts
|
|
12
|
-
|
|
12
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
exports.Oas =
|
|
17
|
+
exports.Oas = _chunkREUEIIL3cjs.Oas; exports.Operation = _chunkREUEIIL3cjs.Operation; exports.Schema = _chunkREUEIIL3cjs.Schema;
|
|
18
18
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-CxKiczSe.cjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react';
|
|
5
5
|
import { a as OperationGenerator } from './OperationGenerator-BV6QRtkW.cjs';
|
|
6
6
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-
|
|
7
|
+
import './SchemaMapper-BLcXlDBz.cjs';
|
|
8
8
|
import '@kubb/core';
|
|
9
9
|
import './types-Db0qp8u-.cjs';
|
|
10
10
|
import '@kubb/oas/parser';
|
package/dist/components.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-CkGDfE-r.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react';
|
|
5
5
|
import { a as OperationGenerator } from './OperationGenerator-DO5tNGuT.js';
|
|
6
6
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-
|
|
7
|
+
import './SchemaMapper-BLcXlDBz.js';
|
|
8
8
|
import '@kubb/core';
|
|
9
9
|
import './types-Db0qp8u-.js';
|
|
10
10
|
import '@kubb/oas/parser';
|
package/dist/components.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
Oas,
|
|
3
3
|
Operation,
|
|
4
4
|
Schema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-7NYIF73B.js";
|
|
6
|
+
import "./chunk-C7EB64G2.js";
|
|
7
7
|
import {
|
|
8
8
|
init_esm_shims
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UB552H4J.js";
|
|
10
10
|
|
|
11
11
|
// src/components/index.ts
|
|
12
12
|
init_esm_shims();
|
package/dist/hooks.cjs
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunkREUEIIL3cjs = require('./chunk-REUEIIL3.cjs');
|
|
6
|
+
require('./chunk-IOHUYXT5.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
10
10
|
|
|
11
11
|
// src/hooks/index.ts
|
|
12
|
-
|
|
12
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
13
13
|
|
|
14
14
|
// src/hooks/useOas.ts
|
|
15
|
-
|
|
15
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
16
16
|
var _react = require('@kubb/react');
|
|
17
17
|
function useOas() {
|
|
18
|
-
const { oas } = _react.useContext.call(void 0,
|
|
18
|
+
const { oas } = _react.useContext.call(void 0, _chunkREUEIIL3cjs.Oas.Context);
|
|
19
19
|
if (!oas) {
|
|
20
20
|
throw new Error("Oas is not defined");
|
|
21
21
|
}
|
|
@@ -23,10 +23,10 @@ function useOas() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// src/hooks/useOperation.ts
|
|
26
|
-
|
|
26
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
27
27
|
|
|
28
28
|
function useOperation() {
|
|
29
|
-
const { operation } = _react.useContext.call(void 0,
|
|
29
|
+
const { operation } = _react.useContext.call(void 0, _chunkREUEIIL3cjs.Operation.Context);
|
|
30
30
|
if (!operation) {
|
|
31
31
|
throw new Error("Operation is not defined");
|
|
32
32
|
}
|
|
@@ -34,11 +34,11 @@ function useOperation() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// src/hooks/useOperationManager.ts
|
|
37
|
-
|
|
37
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
38
38
|
|
|
39
39
|
function useOperationManager() {
|
|
40
40
|
const { plugin, pluginManager } = _react.useApp.call(void 0, );
|
|
41
|
-
const { generator } = _react.useContext.call(void 0,
|
|
41
|
+
const { generator } = _react.useContext.call(void 0, _chunkREUEIIL3cjs.Oas.Context);
|
|
42
42
|
if (!generator) {
|
|
43
43
|
throw new Error(`'generator' is not defined`);
|
|
44
44
|
}
|
|
@@ -139,10 +139,10 @@ function useOperationManager() {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// src/hooks/useOperations.ts
|
|
142
|
-
|
|
142
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
143
143
|
|
|
144
144
|
function useOperations({ method, path } = {}) {
|
|
145
|
-
const { operations } = _react.useContext.call(void 0,
|
|
145
|
+
const { operations } = _react.useContext.call(void 0, _chunkREUEIIL3cjs.Oas.Context);
|
|
146
146
|
if (!operations) {
|
|
147
147
|
throw new Error("Operations is not defined");
|
|
148
148
|
}
|
|
@@ -161,5 +161,5 @@ function useOperations({ method, path } = {}) {
|
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
|
|
164
|
-
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema =
|
|
164
|
+
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkREUEIIL3cjs.useSchema;
|
|
165
165
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.d.cts
CHANGED
|
@@ -2,11 +2,11 @@ import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
|
2
2
|
import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
|
|
3
3
|
import * as KubbFile from '@kubb/fs/types';
|
|
4
4
|
import { f as OperationSchemas } from './types-Db0qp8u-.cjs';
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-CxKiczSe.cjs';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-BLcXlDBz.cjs';
|
|
10
10
|
|
|
11
11
|
declare function useOas(): Oas;
|
|
12
12
|
|
package/dist/hooks.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
|
2
2
|
import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
|
|
3
3
|
import * as KubbFile from '@kubb/fs/types';
|
|
4
4
|
import { f as OperationSchemas } from './types-Db0qp8u-.js';
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-CkGDfE-r.js';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-BLcXlDBz.js';
|
|
10
10
|
|
|
11
11
|
declare function useOas(): Oas;
|
|
12
12
|
|
package/dist/hooks.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
Oas,
|
|
3
3
|
Operation,
|
|
4
4
|
useSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-7NYIF73B.js";
|
|
6
|
+
import "./chunk-C7EB64G2.js";
|
|
7
7
|
import {
|
|
8
8
|
init_esm_shims
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-UB552H4J.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/index.ts
|
|
12
12
|
init_esm_shims();
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQLJIL3U5cjs = require('./chunk-QLJIL3U5.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkIOHUYXT5cjs = require('./chunk-IOHUYXT5.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -13,13 +13,13 @@ var _chunkM62LERKBcjs = require('./chunk-M62LERKB.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
|
-
|
|
19
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
20
20
|
|
|
21
21
|
// src/plugin.ts
|
|
22
|
-
|
|
22
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
23
23
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
24
24
|
var _core = require('@kubb/core');
|
|
25
25
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
@@ -36,7 +36,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
36
36
|
} = options;
|
|
37
37
|
const getOas = async ({ config, logger, formatOptions }) => {
|
|
38
38
|
try {
|
|
39
|
-
const oas = await
|
|
39
|
+
const oas = await _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
|
|
40
40
|
if (validate) {
|
|
41
41
|
await oas.valdiate();
|
|
42
42
|
}
|
|
@@ -44,7 +44,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
44
44
|
} catch (e) {
|
|
45
45
|
const error = e;
|
|
46
46
|
logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
|
|
47
|
-
return
|
|
47
|
+
return _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, {}, oasClass);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
return {
|
|
@@ -58,7 +58,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
58
58
|
},
|
|
59
59
|
async getSchemas({ includes } = {}) {
|
|
60
60
|
const oas = await this.getOas();
|
|
61
|
-
return
|
|
61
|
+
return _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType, includes });
|
|
62
62
|
},
|
|
63
63
|
async getBaseURL() {
|
|
64
64
|
const oasInstance = await this.getOas();
|
|
@@ -97,7 +97,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
await oas.dereference();
|
|
100
|
-
const schemas =
|
|
100
|
+
const schemas = _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType });
|
|
101
101
|
const mapSchema = async ([name, schema]) => {
|
|
102
102
|
const resolvedPath = this.resolvePath({
|
|
103
103
|
baseName: `${name}.json`,
|
|
@@ -127,21 +127,21 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
// src/OperationGenerator.ts
|
|
130
|
-
|
|
130
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
|
|
134
134
|
var OperationGenerator = class extends _core.Generator {
|
|
135
135
|
constructor() {
|
|
136
136
|
super(...arguments);
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
_chunkP42X362Ucjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
|
|
138
|
+
_chunkP42X362Ucjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
|
|
139
139
|
}
|
|
140
140
|
get operationsByMethod() {
|
|
141
|
-
return
|
|
141
|
+
return _chunkP42X362Ucjs.__privateGet.call(void 0, this, _operationsByMethod);
|
|
142
142
|
}
|
|
143
143
|
set operationsByMethod(paths) {
|
|
144
|
-
|
|
144
|
+
_chunkP42X362Ucjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
|
|
145
145
|
}
|
|
146
146
|
getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
|
|
147
147
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
@@ -224,9 +224,9 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
224
224
|
const methods = Object.keys(method);
|
|
225
225
|
methods.forEach((method2) => {
|
|
226
226
|
const operation = oas.operation(path2, method2);
|
|
227
|
-
if (operation &&
|
|
228
|
-
const isExcluded =
|
|
229
|
-
const isIncluded = this.context.include ?
|
|
227
|
+
if (operation && _chunkP42X362Ucjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get)[method2]) {
|
|
228
|
+
const isExcluded = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
|
|
229
|
+
const isIncluded = this.context.include ? _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
|
|
230
230
|
if (isIncluded && !isExcluded) {
|
|
231
231
|
if (!acc[path2]) {
|
|
232
232
|
acc[path2] = {};
|
|
@@ -247,8 +247,8 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
247
247
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
248
248
|
methods.forEach((method) => {
|
|
249
249
|
const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
|
|
250
|
-
const options =
|
|
251
|
-
const promiseMethod = _optionalChain([
|
|
250
|
+
const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
|
|
251
|
+
const promiseMethod = _optionalChain([_chunkP42X362Ucjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
|
|
252
252
|
...this.options,
|
|
253
253
|
...options
|
|
254
254
|
})]);
|
|
@@ -403,5 +403,5 @@ var src_default = definePluginDefault;
|
|
|
403
403
|
|
|
404
404
|
|
|
405
405
|
|
|
406
|
-
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator =
|
|
406
|
+
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkIOHUYXT5cjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkIOHUYXT5cjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkIOHUYXT5cjs.schemaKeywords;
|
|
407
407
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -5,8 +5,8 @@ export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as Opera
|
|
|
5
5
|
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-BV6QRtkW.cjs';
|
|
6
6
|
import * as KubbFile from '@kubb/fs/types';
|
|
7
7
|
import { SchemaObject, Oas, contentType } from '@kubb/oas';
|
|
8
|
-
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-
|
|
9
|
-
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-
|
|
8
|
+
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-BLcXlDBz.cjs';
|
|
9
|
+
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-BLcXlDBz.cjs';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
declare const pluginOasName = "plugin-oas";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { A as API, E as Exclude, I as Include, f as OperationSchemas, g as Opera
|
|
|
5
5
|
export { G as GetOperationGeneratorOptions, a as OperationGenerator, O as OperationMethodResult } from './OperationGenerator-DO5tNGuT.js';
|
|
6
6
|
import * as KubbFile from '@kubb/fs/types';
|
|
7
7
|
import { SchemaObject, Oas, contentType } from '@kubb/oas';
|
|
8
|
-
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-
|
|
9
|
-
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-
|
|
8
|
+
import { S as Schema, a as SchemaKeywordMapper } from './SchemaMapper-BLcXlDBz.js';
|
|
9
|
+
export { b as SchemaKeyword, c as SchemaKeywordBase, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-BLcXlDBz.js';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
declare const pluginOasName = "plugin-oas";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFromConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y4V7HHX7.js";
|
|
4
4
|
import {
|
|
5
5
|
SchemaGenerator,
|
|
6
6
|
isKeyword,
|
|
7
7
|
schemaKeywords
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-C7EB64G2.js";
|
|
9
9
|
import {
|
|
10
10
|
__privateAdd,
|
|
11
11
|
__privateGet,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__privateSet,
|
|
14
14
|
getSchemas,
|
|
15
15
|
init_esm_shims
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UB552H4J.js";
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
init_esm_shims();
|
package/dist/utils.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQLJIL3U5cjs = require('./chunk-QLJIL3U5.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
9
9
|
|
|
10
10
|
// src/utils/index.ts
|
|
11
|
-
|
|
11
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
12
12
|
|
|
13
13
|
// src/utils/getComments.ts
|
|
14
|
-
|
|
14
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
15
15
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
16
16
|
var _utils = require('@kubb/core/utils');
|
|
17
17
|
function getComments(operation) {
|
|
@@ -24,7 +24,7 @@ function getComments(operation) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/utils/getGroupedByTagFiles.ts
|
|
27
|
-
|
|
27
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
28
28
|
var _path = require('path');
|
|
29
29
|
var _core = require('@kubb/core');
|
|
30
30
|
|
|
@@ -69,7 +69,7 @@ async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs,
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/utils/getParams.ts
|
|
72
|
-
|
|
72
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
73
73
|
var _oas = require('@kubb/oas');
|
|
74
74
|
|
|
75
75
|
function getASTParams(operationSchema, {
|
|
@@ -104,7 +104,7 @@ function getPathParams(operationSchema, options = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/utils/refSorter.ts
|
|
107
|
-
|
|
107
|
+
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
108
108
|
function refsSorter(a, b) {
|
|
109
109
|
if (_optionalChain([Object, 'access', _10 => _10.keys, 'call', _11 => _11(a.import.refs), 'optionalAccess', _12 => _12.length]) < _optionalChain([Object, 'access', _13 => _13.keys, 'call', _14 => _14(b.import.refs), 'optionalAccess', _15 => _15.length])) {
|
|
110
110
|
return -1;
|
|
@@ -123,5 +123,5 @@ function refsSorter(a, b) {
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getGroupedByTagFiles = getGroupedByTagFiles; exports.getPathParams = getPathParams; exports.getSchemaFactory =
|
|
126
|
+
exports.getASTParams = getASTParams; exports.getComments = getComments; exports.getGroupedByTagFiles = getGroupedByTagFiles; exports.getPathParams = getPathParams; exports.getSchemaFactory = _chunkP42X362Ucjs.getSchemaFactory; exports.getSchemas = _chunkP42X362Ucjs.getSchemas; exports.parseFromConfig = _chunkQLJIL3U5cjs.parseFromConfig; exports.refsSorter = refsSorter;
|
|
127
127
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseFromConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y4V7HHX7.js";
|
|
4
4
|
import {
|
|
5
5
|
getSchemaFactory,
|
|
6
6
|
getSchemas,
|
|
7
7
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UB552H4J.js";
|
|
9
9
|
|
|
10
10
|
// src/utils/index.ts
|
|
11
11
|
init_esm_shims();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-oas",
|
|
3
|
-
"version": "2.25.
|
|
3
|
+
"version": "2.25.3",
|
|
4
4
|
"description": "Generator swagger",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -67,24 +67,24 @@
|
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@stoplight/yaml": "^4.3.0",
|
|
70
|
-
"remeda": "^2.
|
|
71
|
-
"@kubb/core": "2.25.
|
|
72
|
-
"@kubb/fs": "2.25.
|
|
73
|
-
"@kubb/oas": "2.25.
|
|
74
|
-
"@kubb/react": "2.25.
|
|
70
|
+
"remeda": "^2.11.0",
|
|
71
|
+
"@kubb/core": "2.25.3",
|
|
72
|
+
"@kubb/fs": "2.25.3",
|
|
73
|
+
"@kubb/oas": "2.25.3",
|
|
74
|
+
"@kubb/react": "2.25.3"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@types/react": "^18.3.
|
|
77
|
+
"@types/react": "^18.3.4",
|
|
78
78
|
"@types/react-dom": "^18.3.0",
|
|
79
79
|
"react": "^18.3.1",
|
|
80
80
|
"tsup": "^8.2.4",
|
|
81
81
|
"typescript": "^5.5.4",
|
|
82
|
-
"@kubb/config-biome": "2.25.
|
|
83
|
-
"@kubb/config-ts": "2.25.
|
|
84
|
-
"@kubb/config-tsup": "2.25.
|
|
82
|
+
"@kubb/config-biome": "2.25.3",
|
|
83
|
+
"@kubb/config-ts": "2.25.3",
|
|
84
|
+
"@kubb/config-tsup": "2.25.3"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@kubb/react": "2.25.
|
|
87
|
+
"@kubb/react": "2.25.3"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=18"
|
package/src/SchemaGenerator.ts
CHANGED
|
@@ -85,7 +85,7 @@ export abstract class SchemaGenerator<
|
|
|
85
85
|
const defaultSchemas = this.#parseSchemaObject(props)
|
|
86
86
|
const schemas = options.transformers?.schema?.(props, defaultSchemas) || defaultSchemas || []
|
|
87
87
|
|
|
88
|
-
return uniqueWith
|
|
88
|
+
return uniqueWith(schemas, isDeepEqual)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][] {
|
|
@@ -360,7 +360,7 @@ export abstract class SchemaGenerator<
|
|
|
360
360
|
return [
|
|
361
361
|
{
|
|
362
362
|
keyword: schemaKeywords.ref,
|
|
363
|
-
args: { name: ref.propertyName, path: ref?.path
|
|
363
|
+
args: { name: ref.propertyName, path: ref?.path },
|
|
364
364
|
},
|
|
365
365
|
]
|
|
366
366
|
}
|
|
@@ -809,6 +809,10 @@ export abstract class SchemaGenerator<
|
|
|
809
809
|
].filter(Boolean)
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
+
if (!['boolean', 'object', 'number', 'string', 'integer'].includes(schema.type)) {
|
|
813
|
+
this.context.pluginManager.logger.emit('warning', `Schema type '${schema.type}' is not valid for schema ${parentName}.${name}`)
|
|
814
|
+
}
|
|
815
|
+
|
|
812
816
|
// 'string' | 'number' | 'integer' | 'boolean'
|
|
813
817
|
return [{ keyword: schema.type }, ...baseItems]
|
|
814
818
|
}
|
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' }
|
|
@@ -118,9 +118,7 @@ Schema.Imports = ({ isTypeOnly, extName }: SchemaImportsProps): ReactNode => {
|
|
|
118
118
|
return undefined
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
return
|
|
122
|
-
<File.Import key={i} extName={extName} root={root} name={[item.args.name]} path={item.args.path} isTypeOnly={item.args.isTypeOnly ?? isTypeOnly} />
|
|
123
|
-
)
|
|
121
|
+
return <File.Import key={i} extName={extName} root={root} name={[item.args.name]} path={item.args.path} isTypeOnly={isTypeOnly} />
|
|
124
122
|
})
|
|
125
123
|
.filter(Boolean)}
|
|
126
124
|
</>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.5_@types+node@20.14.14__jiti@1.21.6_postcss@8.4.40_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js","../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAUO,SAAS,WAAW,EAAE,KAAK,aAAa,WAAW,CAAC,WAAW,iBAAiB,WAAW,EAAE,GAA2D;AAC7J,QAAM,aAAa,IAAI,cAAc,EAAE;AAEvC,MAAI,UAAiD,CAAC;AAEtD,MAAI,SAAS,SAAS,SAAS,GAAG;AAChC,cAAU;AAAA,MACR,GAAG;AAAA,MACH,GAAK,YAAY,WAAqD,CAAC;AAAA,IACzE;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,iBAAiB,CAAC;AACpD,MAAI,SAAS,SAAS,WAAW,GAAG;AAClC,UAAM,YAAY,YAAY,aAAa,CAAC;AAE5C,WAAO,QAAQ,SAAS,EAAE,QAAQ,CAAC,CAAC,MAAM,QAAQ,MAAyC;AACzF,UAAI,SAAS,WAAW,CAAC,QAAQ,IAAI,GAAG;AACtC,cAAM,mBAAmB,OAAO,KAAK,SAAS,OAAO,EAAE,CAAC,KAAK;AAC7D,gBAAQ,IAAI,IAAI,SAAS,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACvE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,WAAO,QAAQ,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,OAAO,MAA4C;AAC/F,UAAI,QAAQ,WAAW,CAAC,QAAQ,IAAI,GAAG;AACrC,cAAM,mBAAmB,OAAO,KAAK,QAAQ,OAAO,EAAE,CAAC,KAAK;AAC5D,gBAAQ,IAAI,IAAI,QAAQ,UAAU,eAAe,gBAAgB,GAAG;AAAA,MACtE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;AC5CA;AAAA,SAAS,6BAA6B;AAuB/B,SAAS,iBAAmD,KAA6D;AAC9H,SAAO,CAAC,WAA0B;AAChC,UAAM,UAAU,sBAAsB,IAAI,GAAG,IAAI,QAAQ;AAEzD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|