@kubb/plugin-oas 3.0.0-alpha.9 → 3.0.0-beta.1

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.
Files changed (99) hide show
  1. package/README.md +14 -5
  2. package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
  3. package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
  4. package/dist/{Schema-B1vcPGiK.d.ts → Schema-1iM2I0dK.d.ts} +1 -12
  5. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-5o-c5UOy.d.cts} +1 -12
  6. package/dist/chunk-ABOQ73FL.cjs +36 -0
  7. package/dist/chunk-ABOQ73FL.cjs.map +1 -0
  8. package/dist/chunk-BG77DP54.js +30 -0
  9. package/dist/chunk-BG77DP54.js.map +1 -0
  10. package/dist/chunk-GF26SDHQ.js +28 -0
  11. package/dist/chunk-GF26SDHQ.js.map +1 -0
  12. package/dist/chunk-PADR76WZ.cjs +4 -0
  13. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  14. package/dist/chunk-QAFBZLJA.cjs +48 -0
  15. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  16. package/dist/chunk-QT6ZFRNJ.cjs +752 -0
  17. package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
  18. package/dist/chunk-QWO5NQGQ.js +88 -0
  19. package/dist/chunk-QWO5NQGQ.js.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/chunk-SR63CBLH.cjs +92 -0
  23. package/dist/chunk-SR63CBLH.cjs.map +1 -0
  24. package/dist/chunk-V2JO6RHI.js +744 -0
  25. package/dist/chunk-V2JO6RHI.js.map +1 -0
  26. package/dist/chunk-XNCEFOE6.js +45 -0
  27. package/dist/chunk-XNCEFOE6.js.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -12
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +3 -6
  33. package/dist/components.d.ts +3 -6
  34. package/dist/components.js +3 -12
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +9 -0
  39. package/dist/generators.d.ts +9 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +102 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +41 -10
  45. package/dist/hooks.d.ts +41 -10
  46. package/dist/hooks.js +91 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +134 -185
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +2 -5
  51. package/dist/index.d.ts +2 -5
  52. package/dist/index.js +68 -146
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -45
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +4 -13
  57. package/dist/utils.d.ts +4 -13
  58. package/dist/utils.js +8 -44
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +11 -23
  62. package/src/SchemaGenerator.ts +68 -9
  63. package/src/SchemaMapper.ts +6 -4
  64. package/src/components/Schema.tsx +1 -99
  65. package/src/generator.tsx +22 -18
  66. package/src/generators/index.ts +1 -0
  67. package/src/generators/jsonGenerator.ts +32 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useOperationManager.ts +77 -30
  70. package/src/hooks/useSchemaManager.ts +77 -0
  71. package/src/plugin.ts +69 -56
  72. package/src/types.ts +24 -18
  73. package/src/utils/getParams.ts +1 -1
  74. package/src/utils/getSchemaFactory.ts +1 -1
  75. package/src/utils/index.ts +0 -1
  76. package/src/utils/parseFromConfig.ts +7 -7
  77. package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
  78. package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
  79. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  80. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  81. package/dist/chunk-75BIOXB7.cjs +0 -7
  82. package/dist/chunk-75BIOXB7.cjs.map +0 -1
  83. package/dist/chunk-IAUV3UKH.cjs +0 -3965
  84. package/dist/chunk-IAUV3UKH.cjs.map +0 -1
  85. package/dist/chunk-M347763D.js +0 -3965
  86. package/dist/chunk-M347763D.js.map +0 -1
  87. package/dist/chunk-N7EEVJA6.js +0 -35
  88. package/dist/chunk-N7EEVJA6.js.map +0 -1
  89. package/dist/chunk-NU4F7G47.cjs +0 -89
  90. package/dist/chunk-NU4F7G47.cjs.map +0 -1
  91. package/dist/chunk-O76YQFZB.cjs +0 -35
  92. package/dist/chunk-O76YQFZB.cjs.map +0 -1
  93. package/dist/chunk-SQ64ESS4.js +0 -7
  94. package/dist/chunk-SQ64ESS4.js.map +0 -1
  95. package/dist/chunk-SZDO532A.js +0 -89
  96. package/dist/chunk-SZDO532A.js.map +0 -1
  97. package/dist/types-CZTUCaE5.d.cts +0 -145
  98. package/dist/types-CZTUCaE5.d.ts +0 -145
  99. package/src/utils/refSorter.ts +0 -13
@@ -1,35 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-SZDO532A.js";
4
-
5
- // src/utils/parseFromConfig.ts
6
- init_esm_shims();
7
- import { resolve } from "node:path";
8
- import { URLPath } from "@kubb/core/utils";
9
- import { parse } from "@kubb/oas/parser";
10
- import { Oas } from "@kubb/oas";
11
- import yaml from "@stoplight/yaml";
12
- function parseFromConfig(config, options = {}, oasClass = Oas) {
13
- if ("data" in config.input) {
14
- if (typeof config.input.data === "object") {
15
- const api2 = JSON.parse(JSON.stringify(config.input.data));
16
- return parse(api2, options, oasClass);
17
- }
18
- try {
19
- const api2 = yaml.parse(config.input.data);
20
- return parse(api2, options, oasClass);
21
- } catch (e) {
22
- }
23
- const api = JSON.parse(JSON.stringify(config.input.data));
24
- return parse(api, options, oasClass);
25
- }
26
- if (new URLPath(config.input.path).isURL) {
27
- return parse(config.input.path, options, oasClass);
28
- }
29
- return parse(resolve(config.root, config.input.path), options, oasClass);
30
- }
31
-
32
- export {
33
- parseFromConfig
34
- };
35
- //# sourceMappingURL=chunk-N7EEVJA6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/parseFromConfig.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"],"mappings":";;;;;AAAA;AAAA,SAAS,eAAe;AAExB,SAAS,eAAe;AAExB,SAA6B,aAAa;AAG1C,SAAS,WAA0B;AACnC,OAAO,UAAU;AAEV,SAAS,gBAAgB,QAAgB,UAAyB,CAAC,GAAG,WAAuB,KAAmB;AACrH,MAAI,UAAU,OAAO,OAAO;AAC1B,QAAI,OAAO,OAAO,MAAM,SAAS,UAAU;AACzC,YAAMA,OAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,CAAC;AAC9E,aAAO,MAAMA,MAAK,SAAS,QAAQ;AAAA,IACrC;AAEA,QAAI;AACF,YAAMA,OAAc,KAAK,MAAM,OAAO,MAAM,IAAc;AAE1D,aAAO,MAAMA,MAAK,SAAS,QAAQ;AAAA,IACrC,SAAS,GAAG;AAAA,IAEZ;AAEA,UAAM,MAA4B,KAAK,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,CAAC;AAE9E,WAAO,MAAM,KAAK,SAAS,QAAQ;AAAA,EACrC;AAEA,MAAI,IAAI,QAAQ,OAAO,MAAM,IAAI,EAAE,OAAO;AACxC,WAAO,MAAM,OAAO,MAAM,MAAM,SAAS,QAAQ;AAAA,EACnD;AAEA,SAAO,MAAM,QAAQ,OAAO,MAAM,OAAO,MAAM,IAAI,GAAG,SAAS,QAAQ;AACzE;","names":["api"]}
@@ -1,89 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
31
- var init_cjs_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
33
- "use strict";
34
- }
35
- });
36
-
37
- // src/utils/getSchemas.ts
38
- init_cjs_shims();
39
- function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
40
- const components = oas.getDefinition().components;
41
- let schemas = {};
42
- if (includes.includes("schemas")) {
43
- schemas = {
44
- ...schemas,
45
- ..._optionalChain([components, 'optionalAccess', _ => _.schemas]) || {}
46
- };
47
- }
48
- const requestBodies = _optionalChain([components, 'optionalAccess', _2 => _2.requestBodies]) || {};
49
- if (includes.includes("responses")) {
50
- const responses = _optionalChain([components, 'optionalAccess', _3 => _3.responses]) || {};
51
- Object.entries(responses).forEach(([name, response]) => {
52
- if (response.content && !schemas[name]) {
53
- const firstContentType = Object.keys(response.content)[0] || "application/json";
54
- schemas[name] = _optionalChain([response, 'access', _4 => _4.content, 'optionalAccess', _5 => _5[contentType || firstContentType], 'optionalAccess', _6 => _6.schema]);
55
- }
56
- });
57
- }
58
- if (includes.includes("requestBodies")) {
59
- Object.entries(requestBodies).forEach(([name, request]) => {
60
- if (request.content && !schemas[name]) {
61
- const firstContentType = Object.keys(request.content)[0] || "application/json";
62
- schemas[name] = _optionalChain([request, 'access', _7 => _7.content, 'optionalAccess', _8 => _8[contentType || firstContentType], 'optionalAccess', _9 => _9.schema]);
63
- }
64
- });
65
- }
66
- return schemas;
67
- }
68
-
69
- // src/utils/getSchemaFactory.ts
70
- init_cjs_shims();
71
- var _oas = require('@kubb/oas');
72
- function getSchemaFactory(oas) {
73
- return (schema) => {
74
- const version = _oas.isOpenApiV3_1Document.call(void 0, oas.api) ? "3.1" : "3.0";
75
- return {
76
- schema,
77
- version
78
- };
79
- };
80
- }
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
- exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.init_cjs_shims = init_cjs_shims; exports.getSchemas = getSchemas; exports.getSchemaFactory = getSchemaFactory;
89
- //# sourceMappingURL=chunk-NU4F7G47.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-NU4F7G47.cjs","../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__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,EAAE,MAAM,CAAC,wBAAwB;AACtD,IAAI,kBAAkB,EAAE,MAAM,CAAC,mBAAmB;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,cAAc;AACxC,IAAI,aAAa,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0B;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;AHgDA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,kLAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-NU4F7G47.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"]}
@@ -1,35 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
- var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
4
-
5
- // src/utils/parseFromConfig.ts
6
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
7
- var _path = require('path');
8
- var _utils = require('@kubb/core/utils');
9
- var _parser = require('@kubb/oas/parser');
10
- var _oas = require('@kubb/oas');
11
- var _yaml = require('@stoplight/yaml'); var _yaml2 = _interopRequireDefault(_yaml);
12
- function parseFromConfig(config, options = {}, oasClass = _oas.Oas) {
13
- if ("data" in config.input) {
14
- if (typeof config.input.data === "object") {
15
- const api2 = JSON.parse(JSON.stringify(config.input.data));
16
- return _parser.parse.call(void 0, api2, options, oasClass);
17
- }
18
- try {
19
- const api2 = _yaml2.default.parse(config.input.data);
20
- return _parser.parse.call(void 0, api2, options, oasClass);
21
- } catch (e) {
22
- }
23
- const api = JSON.parse(JSON.stringify(config.input.data));
24
- return _parser.parse.call(void 0, api, options, oasClass);
25
- }
26
- if (new (0, _utils.URLPath)(config.input.path).isURL) {
27
- return _parser.parse.call(void 0, config.input.path, options, oasClass);
28
- }
29
- return _parser.parse.call(void 0, _path.resolve.call(void 0, config.root, config.input.path), options, oasClass);
30
- }
31
-
32
-
33
-
34
- exports.parseFromConfig = parseFromConfig;
35
- //# sourceMappingURL=chunk-O76YQFZB.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-O76YQFZB.cjs","../src/utils/parseFromConfig.ts"],"names":["api"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,8CAAA,CAAA;AAAA,4BAAwB;AAExB,yCAAwB;AAExB,0CAA0C;AAG1C,gCAAmC;AACnC,mFAAiB;AAEV,SAAS,eAAA,CAAgB,MAAA,EAAgB,QAAA,EAAyB,CAAC,CAAA,EAAG,SAAA,EAAuB,QAAA,EAAmB;AACrH,EAAA,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,KAAA,EAAO;AAC1B,IAAA,GAAA,CAAI,OAAO,MAAA,CAAO,KAAA,CAAM,KAAA,IAAS,QAAA,EAAU;AACzC,MAAA,MAAMA,KAAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAC9E,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC;AAEA,IAAA,IAAI;AACF,MAAA,MAAMA,KAAAA,EAAc,cAAA,CAAK,KAAA,CAAM,MAAA,CAAO,KAAA,CAAM,IAAc,CAAA;AAE1D,MAAA,OAAO,2BAAA,IAAMA,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,IACrC,EAAA,MAAA,CAAS,CAAA,EAAG;AAAA,IAEZ;AAEA,IAAA,MAAM,IAAA,EAA4B,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAA,CAAM,IAAI,CAAC,CAAA;AAE9E,IAAA,OAAO,2BAAA,GAAM,EAAK,OAAA,EAAS,QAAQ,CAAA;AAAA,EACrC;AAEA,EAAA,GAAA,CAAI,IAAI,mBAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,CAAE,KAAA,EAAO;AACxC,IAAA,OAAO,2BAAA,MAAM,CAAO,KAAA,CAAM,IAAA,EAAM,OAAA,EAAS,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,2BAAA,2BAAM,MAAQ,CAAO,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA,EAAG,OAAA,EAAS,QAAQ,CAAA;AACzE;ADLA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/chunk-O76YQFZB.cjs","sourcesContent":[null,"import { resolve } from 'node:path'\n\nimport { URLPath } from '@kubb/core/utils'\n\nimport { type FormatOptions, parse } from '@kubb/oas/parser'\n\nimport type { Config } from '@kubb/core'\nimport { Oas, type OasTypes } from '@kubb/oas'\nimport yaml from '@stoplight/yaml'\n\nexport function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {\n if ('data' in config.input) {\n if (typeof config.input.data === 'object') {\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n return parse(api, options, oasClass)\n }\n\n try {\n const api: string = yaml.parse(config.input.data as string) as string\n\n return parse(api, options, oasClass)\n } catch (e) {\n /* empty */\n }\n\n const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument\n\n return parse(api, options, oasClass)\n }\n\n if (new URLPath(config.input.path).isURL) {\n return parse(config.input.path, options, oasClass)\n }\n\n return parse(resolve(config.root, config.input.path), options, oasClass)\n}\n"]}
@@ -1,7 +0,0 @@
1
- import {
2
- init_esm_shims
3
- } from "./chunk-SZDO532A.js";
4
-
5
- // src/components/index.ts
6
- init_esm_shims();
7
- //# sourceMappingURL=chunk-SQ64ESS4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { Oas } from './Oas.tsx'\nexport { Operation } from './Operation.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;AAAA;","names":[]}
@@ -1,89 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
31
- var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
33
- "use strict";
34
- }
35
- });
36
-
37
- // src/utils/getSchemas.ts
38
- init_esm_shims();
39
- function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
40
- const components = oas.getDefinition().components;
41
- let schemas = {};
42
- if (includes.includes("schemas")) {
43
- schemas = {
44
- ...schemas,
45
- ...components?.schemas || {}
46
- };
47
- }
48
- const requestBodies = components?.requestBodies || {};
49
- if (includes.includes("responses")) {
50
- const responses = components?.responses || {};
51
- Object.entries(responses).forEach(([name, response]) => {
52
- if (response.content && !schemas[name]) {
53
- const firstContentType = Object.keys(response.content)[0] || "application/json";
54
- schemas[name] = response.content?.[contentType || firstContentType]?.schema;
55
- }
56
- });
57
- }
58
- if (includes.includes("requestBodies")) {
59
- Object.entries(requestBodies).forEach(([name, request]) => {
60
- if (request.content && !schemas[name]) {
61
- const firstContentType = Object.keys(request.content)[0] || "application/json";
62
- schemas[name] = request.content?.[contentType || firstContentType]?.schema;
63
- }
64
- });
65
- }
66
- return schemas;
67
- }
68
-
69
- // src/utils/getSchemaFactory.ts
70
- init_esm_shims();
71
- import { isOpenApiV3_1Document } from "@kubb/oas";
72
- function getSchemaFactory(oas) {
73
- return (schema) => {
74
- const version = isOpenApiV3_1Document(oas.api) ? "3.1" : "3.0";
75
- return {
76
- schema,
77
- version
78
- };
79
- };
80
- }
81
-
82
- export {
83
- __commonJS,
84
- __toESM,
85
- init_esm_shims,
86
- getSchemas,
87
- getSchemaFactory
88
- };
89
- //# sourceMappingURL=chunk-SZDO532A.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__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,145 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- extName?: KubbFile.Extname;
39
- exportType?: 'barrel' | 'barrelNamed' | false;
40
- } | false;
41
- /**
42
- * Which server to use from the array of `servers.url[serverIndex]`
43
- * @example
44
- * - `0` will return `http://petstore.swagger.io/api`
45
- * - `1` will return `http://localhost:3000`
46
- * @default 0
47
- */
48
- serverIndex?: number;
49
- /**
50
- * Define which contentType should be used.
51
- * By default, this is set based on the first used contentType..
52
- */
53
- contentType?: contentType;
54
- experimentalFilter?: FormatOptions['filterSet'];
55
- experimentalSort?: FormatOptions['sortSet'];
56
- oasClass?: typeof Oas;
57
- };
58
- /**
59
- * `propertyName` is the ref name + resolved with the nameResolver
60
- * @example `import { Pet } from './Pet'`
61
- *
62
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
63
- *
64
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
65
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
66
- */
67
- type Ref = {
68
- propertyName: string;
69
- originalName: string;
70
- path: KubbFile.OptionalPath;
71
- pluginKey?: Plugin['key'];
72
- };
73
- type Refs = Record<string, Ref>;
74
- type Resolver = {
75
- /**
76
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
77
- */
78
- name: string;
79
- baseName: KubbFile.BaseName;
80
- path: KubbFile.Path;
81
- };
82
- type OperationSchema = {
83
- /**
84
- * Converted name, contains already `PathParams`, `QueryParams`, ...
85
- */
86
- name: string;
87
- schema: SchemaObject;
88
- operation?: Operation;
89
- /**
90
- * OperationName in PascalCase, only being used in OperationGenerator
91
- */
92
- operationName?: string;
93
- description?: string;
94
- statusCode?: number;
95
- keys?: string[];
96
- keysToOmit?: string[];
97
- withData?: boolean;
98
- };
99
- type OperationSchemas = {
100
- pathParams?: OperationSchema & {
101
- keysToOmit?: never;
102
- };
103
- queryParams?: OperationSchema & {
104
- keysToOmit?: never;
105
- };
106
- headerParams?: OperationSchema & {
107
- keysToOmit?: never;
108
- };
109
- request?: OperationSchema;
110
- response: OperationSchema;
111
- statusCodes?: Array<OperationSchema>;
112
- errors?: Array<OperationSchema>;
113
- };
114
- type OperationsByMethod = Record<string, Record<HttpMethod, {
115
- operation: Operation;
116
- schemas: OperationSchemas;
117
- }>>;
118
- type ByTag = {
119
- type: 'tag';
120
- pattern: string | RegExp;
121
- };
122
- type ByOperationId = {
123
- type: 'operationId';
124
- pattern: string | RegExp;
125
- };
126
- type ByPath = {
127
- type: 'path';
128
- pattern: string | RegExp;
129
- };
130
- type ByMethod = {
131
- type: 'method';
132
- pattern: HttpMethod | RegExp;
133
- };
134
- type BySchemaName = {
135
- type: 'schemaName';
136
- pattern: string | RegExp;
137
- };
138
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
139
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
140
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
141
- options: Partial<TOptions>;
142
- };
143
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
144
-
145
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
@@ -1,145 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- extName?: KubbFile.Extname;
39
- exportType?: 'barrel' | 'barrelNamed' | false;
40
- } | false;
41
- /**
42
- * Which server to use from the array of `servers.url[serverIndex]`
43
- * @example
44
- * - `0` will return `http://petstore.swagger.io/api`
45
- * - `1` will return `http://localhost:3000`
46
- * @default 0
47
- */
48
- serverIndex?: number;
49
- /**
50
- * Define which contentType should be used.
51
- * By default, this is set based on the first used contentType..
52
- */
53
- contentType?: contentType;
54
- experimentalFilter?: FormatOptions['filterSet'];
55
- experimentalSort?: FormatOptions['sortSet'];
56
- oasClass?: typeof Oas;
57
- };
58
- /**
59
- * `propertyName` is the ref name + resolved with the nameResolver
60
- * @example `import { Pet } from './Pet'`
61
- *
62
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
63
- *
64
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
65
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
66
- */
67
- type Ref = {
68
- propertyName: string;
69
- originalName: string;
70
- path: KubbFile.OptionalPath;
71
- pluginKey?: Plugin['key'];
72
- };
73
- type Refs = Record<string, Ref>;
74
- type Resolver = {
75
- /**
76
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
77
- */
78
- name: string;
79
- baseName: KubbFile.BaseName;
80
- path: KubbFile.Path;
81
- };
82
- type OperationSchema = {
83
- /**
84
- * Converted name, contains already `PathParams`, `QueryParams`, ...
85
- */
86
- name: string;
87
- schema: SchemaObject;
88
- operation?: Operation;
89
- /**
90
- * OperationName in PascalCase, only being used in OperationGenerator
91
- */
92
- operationName?: string;
93
- description?: string;
94
- statusCode?: number;
95
- keys?: string[];
96
- keysToOmit?: string[];
97
- withData?: boolean;
98
- };
99
- type OperationSchemas = {
100
- pathParams?: OperationSchema & {
101
- keysToOmit?: never;
102
- };
103
- queryParams?: OperationSchema & {
104
- keysToOmit?: never;
105
- };
106
- headerParams?: OperationSchema & {
107
- keysToOmit?: never;
108
- };
109
- request?: OperationSchema;
110
- response: OperationSchema;
111
- statusCodes?: Array<OperationSchema>;
112
- errors?: Array<OperationSchema>;
113
- };
114
- type OperationsByMethod = Record<string, Record<HttpMethod, {
115
- operation: Operation;
116
- schemas: OperationSchemas;
117
- }>>;
118
- type ByTag = {
119
- type: 'tag';
120
- pattern: string | RegExp;
121
- };
122
- type ByOperationId = {
123
- type: 'operationId';
124
- pattern: string | RegExp;
125
- };
126
- type ByPath = {
127
- type: 'path';
128
- pattern: string | RegExp;
129
- };
130
- type ByMethod = {
131
- type: 'method';
132
- pattern: HttpMethod | RegExp;
133
- };
134
- type BySchemaName = {
135
- type: 'schemaName';
136
- pattern: string | RegExp;
137
- };
138
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
139
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
140
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
141
- options: Partial<TOptions>;
142
- };
143
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
144
-
145
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
@@ -1,13 +0,0 @@
1
- import type { Refs } from '../types.ts'
2
-
3
- type Generated = { import: { refs: Refs; name: string } }
4
-
5
- export function refsSorter<T extends Generated>(a: T, b: T): number {
6
- if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {
7
- return -1
8
- }
9
- if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {
10
- return 1
11
- }
12
- return 0
13
- }