@kubb/plugin-oas 3.0.0-alpha.17 → 3.0.0-alpha.19
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/README.md +0 -4
- package/dist/{OperationGenerator-B5CoXmjA.d.cts → OperationGenerator-B-fD21AE.d.cts} +5 -11
- package/dist/{OperationGenerator-B5CoXmjA.d.ts → OperationGenerator-B-fD21AE.d.ts} +5 -11
- package/dist/{Schema-BsgDay0E.d.cts → Schema-2SquDHXv.d.cts} +1 -1
- package/dist/{Schema-Dvt6i_X3.d.ts → Schema-CPcUc98-.d.ts} +1 -1
- package/dist/{chunk-AWRVBD2X.js → chunk-3KSIGCJD.js} +10 -17
- package/dist/chunk-3KSIGCJD.js.map +1 -0
- package/dist/{chunk-XIFGKAM3.js → chunk-DFQJ57GH.js} +4 -35
- package/dist/chunk-DFQJ57GH.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/{chunk-IVSE3A7W.cjs → chunk-HP5WAFBU.cjs} +2 -38
- package/dist/chunk-HP5WAFBU.cjs.map +1 -0
- package/dist/{chunk-BEKIIF6H.cjs → chunk-OO5R4UIK.cjs} +5 -407
- package/dist/chunk-OO5R4UIK.cjs.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/{chunk-XON3FUPP.cjs → chunk-PWQ77NRQ.cjs} +10 -17
- package/dist/chunk-PWQ77NRQ.cjs.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-THGCWF2O.js +30 -0
- package/dist/chunk-THGCWF2O.js.map +1 -0
- package/dist/chunk-UO57DZPV.cjs +36 -0
- package/dist/chunk-UO57DZPV.cjs.map +1 -0
- package/dist/{chunk-VLHK3XAR.js → chunk-V4LP5BFJ.js} +5 -403
- package/dist/chunk-V4LP5BFJ.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +2 -2
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +3 -3
- package/dist/hooks.cjs +9 -31
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +3 -25
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +402 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +392 -5
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +8 -29
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -11
- package/dist/utils.d.ts +3 -11
- package/dist/utils.js +3 -23
- package/dist/utils.js.map +1 -1
- package/package.json +9 -12
- package/src/generators/jsonGenerator.ts +2 -0
- package/src/hooks/useSchemaManager.ts +3 -2
- package/src/types.ts +5 -11
- package/src/utils/index.ts +0 -1
- package/dist/chunk-AWRVBD2X.js.map +0 -1
- package/dist/chunk-BEKIIF6H.cjs.map +0 -1
- package/dist/chunk-CQMUJN22.cjs +0 -42
- package/dist/chunk-CQMUJN22.cjs.map +0 -1
- package/dist/chunk-FGOPORE3.js +0 -38
- package/dist/chunk-FGOPORE3.js.map +0 -1
- package/dist/chunk-FZABPEYO.cjs +0 -3176
- package/dist/chunk-FZABPEYO.cjs.map +0 -1
- package/dist/chunk-I6N3YPCE.js +0 -3171
- package/dist/chunk-I6N3YPCE.js.map +0 -1
- package/dist/chunk-IVSE3A7W.cjs.map +0 -1
- package/dist/chunk-VLHK3XAR.js.map +0 -1
- package/dist/chunk-XIFGKAM3.js.map +0 -1
- package/dist/chunk-XON3FUPP.cjs.map +0 -1
- package/src/utils/refSorter.ts +0 -13
package/README.md
CHANGED
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
[![Coverage][coverage-src]][coverage-href]
|
|
14
14
|
[![License][license-src]][license-href]
|
|
15
15
|
|
|
16
|
-
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
17
|
-
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
|
-
</p>
|
|
19
|
-
|
|
20
16
|
<h4>
|
|
21
17
|
<a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
|
|
22
18
|
<span> · </span>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, ResolveNameParams, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
1
|
+
import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
2
2
|
import * as KubbFile from '@kubb/fs/types';
|
|
3
3
|
import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react/types';
|
|
@@ -273,16 +273,10 @@ type Options = {
|
|
|
273
273
|
* @default true
|
|
274
274
|
*/
|
|
275
275
|
validate?: boolean;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
* @default 'schemas'
|
|
281
|
-
*/
|
|
282
|
-
path: string;
|
|
283
|
-
extName?: KubbFile.Extname;
|
|
284
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
285
|
-
};
|
|
276
|
+
/**
|
|
277
|
+
* @default 'schemas'
|
|
278
|
+
*/
|
|
279
|
+
output?: Output;
|
|
286
280
|
/**
|
|
287
281
|
* Which server to use from the array of `servers.url[serverIndex]`
|
|
288
282
|
* @example
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, ResolveNameParams, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
1
|
+
import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
2
2
|
import * as KubbFile from '@kubb/fs/types';
|
|
3
3
|
import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react/types';
|
|
@@ -273,16 +273,10 @@ type Options = {
|
|
|
273
273
|
* @default true
|
|
274
274
|
*/
|
|
275
275
|
validate?: boolean;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
* @default 'schemas'
|
|
281
|
-
*/
|
|
282
|
-
path: string;
|
|
283
|
-
extName?: KubbFile.Extname;
|
|
284
|
-
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
285
|
-
};
|
|
276
|
+
/**
|
|
277
|
+
* @default 'schemas'
|
|
278
|
+
*/
|
|
279
|
+
output?: Output;
|
|
286
280
|
/**
|
|
287
281
|
* Which server to use from the array of `servers.url[serverIndex]`
|
|
288
282
|
* @example
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { SchemaObject } from '@kubb/oas';
|
|
3
3
|
import { KubbNode } from '@kubb/react/types';
|
|
4
|
-
import { g as Schema$1 } from './OperationGenerator-
|
|
4
|
+
import { g as Schema$1 } from './OperationGenerator-B-fD21AE.cjs';
|
|
5
5
|
|
|
6
6
|
type SchemaContextProps = {
|
|
7
7
|
name: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { SchemaObject } from '@kubb/oas';
|
|
3
3
|
import { KubbNode } from '@kubb/react/types';
|
|
4
|
-
import { g as Schema$1 } from './OperationGenerator-
|
|
4
|
+
import { g as Schema$1 } from './OperationGenerator-B-fD21AE.js';
|
|
5
5
|
|
|
6
6
|
type SchemaContextProps = {
|
|
7
7
|
name: string;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { init_esm_shims, __toESM } from './chunk-FGOPORE3.js';
|
|
1
|
+
import { Oas } from './chunk-GF26SDHQ.js';
|
|
3
2
|
import { camelCase } from '@kubb/core/transformers';
|
|
4
3
|
import { createRoot, App } from '@kubb/react';
|
|
4
|
+
import { jsx } from '@kubb/react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
// src/generators/index.ts
|
|
7
|
-
init_esm_shims();
|
|
8
|
-
|
|
9
|
-
// src/generators/jsonGenerator.ts
|
|
10
|
-
init_esm_shims();
|
|
11
|
-
|
|
12
|
-
// src/generator.tsx
|
|
13
|
-
init_esm_shims();
|
|
14
|
-
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
15
6
|
function createGenerator(parseOptions) {
|
|
16
7
|
return parseOptions;
|
|
17
8
|
}
|
|
@@ -28,7 +19,7 @@ function createReactGenerator(parseOptions) {
|
|
|
28
19
|
});
|
|
29
20
|
const Component = parseOptions.Operations.bind(this);
|
|
30
21
|
root.render(
|
|
31
|
-
/* @__PURE__ */
|
|
22
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ jsx(Component, { operations, instance, operationsByMethod, options }) }) })
|
|
32
23
|
);
|
|
33
24
|
return root.files;
|
|
34
25
|
},
|
|
@@ -42,7 +33,7 @@ function createReactGenerator(parseOptions) {
|
|
|
42
33
|
});
|
|
43
34
|
const Component = parseOptions.Operation.bind(this);
|
|
44
35
|
root.render(
|
|
45
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ jsx(Oas.Operation, { operation, children: /* @__PURE__ */ jsx(Component, { operation, options, instance }) }) }) })
|
|
46
37
|
);
|
|
47
38
|
return root.files;
|
|
48
39
|
},
|
|
@@ -56,7 +47,7 @@ function createReactGenerator(parseOptions) {
|
|
|
56
47
|
});
|
|
57
48
|
const Component = parseOptions.Schema.bind(this);
|
|
58
49
|
root.render(
|
|
59
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, children: /* @__PURE__ */ jsx(Oas.Schema, { name: schema.name, value: schema.value, tree: schema.tree, children: /* @__PURE__ */ jsx(Component, { schema, options, instance }) }) }) })
|
|
60
51
|
);
|
|
61
52
|
return root.files;
|
|
62
53
|
}
|
|
@@ -84,12 +75,14 @@ var jsonGenerator = createGenerator({
|
|
|
84
75
|
isIndexable: false,
|
|
85
76
|
value: JSON.stringify(schema.value)
|
|
86
77
|
}
|
|
87
|
-
]
|
|
78
|
+
],
|
|
79
|
+
banner: plugin.output?.banner,
|
|
80
|
+
format: plugin.output?.footer
|
|
88
81
|
}
|
|
89
82
|
];
|
|
90
83
|
}
|
|
91
84
|
});
|
|
92
85
|
|
|
93
86
|
export { createGenerator, createReactGenerator, jsonGenerator };
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-3KSIGCJD.js.map
|
|
88
|
+
//# sourceMappingURL=chunk-3KSIGCJD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generator.tsx","../src/generators/jsonGenerator.ts"],"names":[],"mappings":";;;;;AA2CO,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAaO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI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AAA,OAAA,EAAkB,QAAoB,EAAA,CAAA,EACnE,GACF,CACF,EAAA,CAAA;AAAA,OACF,CAAA;AAEA,MAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,KACd;AAAA,GACF,CAAA;AACF,CAAA;;;AChIO,IAAM,gBAAgB,eAA2B,CAAA;AAAA,EACtD,IAAM,EAAA,YAAA;AAAA,EACN,MAAM,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAY,EAAA;AACjC,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA,GAAA;AAAA,KACnB,CAAA,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,WACpC;AAAA,SACF;AAAA,QACA,MAAA,EAAQ,OAAO,MAAQ,EAAA,MAAA;AAAA,QACvB,MAAA,EAAQ,OAAO,MAAQ,EAAA,MAAA;AAAA,OACzB;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-3KSIGCJD.js","sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n /**\n * Combine all react nodes and only render ones(to string or render)\n */\n render?: () => any\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: plugin.output?.banner,\n format: plugin.output?.footer,\n },\n ]\n },\n})\n"]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { URLPath } from '@kubb/core/utils';
|
|
4
|
-
import { parse } from '@kubb/oas/parser';
|
|
5
|
-
import { Oas, isOpenApiV3_1Document } from '@kubb/oas';
|
|
6
|
-
import yaml from '@stoplight/yaml';
|
|
1
|
+
import { isOpenApiV3_1Document } from '@kubb/oas';
|
|
7
2
|
|
|
8
3
|
// src/utils/getSchemas.ts
|
|
9
|
-
init_esm_shims();
|
|
10
4
|
function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
|
|
11
5
|
const components = oas.getDefinition().components;
|
|
12
6
|
let schemas = {};
|
|
@@ -36,31 +30,6 @@ function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies",
|
|
|
36
30
|
}
|
|
37
31
|
return schemas;
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
// src/utils/parseFromConfig.ts
|
|
41
|
-
init_esm_shims();
|
|
42
|
-
function parseFromConfig(config, options = {}, oasClass = Oas) {
|
|
43
|
-
if ("data" in config.input) {
|
|
44
|
-
if (typeof config.input.data === "object") {
|
|
45
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
46
|
-
return parse(api2, options, oasClass);
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const api2 = yaml.parse(config.input.data);
|
|
50
|
-
return parse(api2, options, oasClass);
|
|
51
|
-
} catch (e) {
|
|
52
|
-
}
|
|
53
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
54
|
-
return parse(api, options, oasClass);
|
|
55
|
-
}
|
|
56
|
-
if (new URLPath(config.input.path).isURL) {
|
|
57
|
-
return parse(config.input.path, options, oasClass);
|
|
58
|
-
}
|
|
59
|
-
return parse(resolve(config.root, config.input.path), options, oasClass);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/utils/getSchemaFactory.ts
|
|
63
|
-
init_esm_shims();
|
|
64
33
|
function getSchemaFactory(oas) {
|
|
65
34
|
return (schema) => {
|
|
66
35
|
const version = isOpenApiV3_1Document(oas.api) ? "3.1" : "3.0";
|
|
@@ -71,6 +40,6 @@ function getSchemaFactory(oas) {
|
|
|
71
40
|
};
|
|
72
41
|
}
|
|
73
42
|
|
|
74
|
-
export { getSchemaFactory, getSchemas
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
export { getSchemaFactory, getSchemas };
|
|
44
|
+
//# sourceMappingURL=chunk-DFQJ57GH.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-DFQJ57GH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":[],"mappings":";;;AAUO,SAAS,UAAA,CAAW,EAAE,GAAA,EAAK,WAAa,EAAA,QAAA,GAAW,CAAC,SAAW,EAAA,eAAA,EAAiB,WAAW,CAAA,EAA6D,EAAA;AAC7J,EAAM,MAAA,UAAA,GAAa,GAAI,CAAA,aAAA,EAAgB,CAAA,UAAA,CAAA;AAEvC,EAAA,IAAI,UAAiD,EAAC,CAAA;AAEtD,EAAI,IAAA,QAAA,CAAS,QAAS,CAAA,SAAS,CAAG,EAAA;AAChC,IAAU,OAAA,GAAA;AAAA,MACR,GAAG,OAAA;AAAA,MACH,GAAK,UAAY,EAAA,OAAA,IAAqD,EAAC;AAAA,KACzE,CAAA;AAAA,GACF;AAEA,EAAM,MAAA,aAAA,GAAgB,UAAY,EAAA,aAAA,IAAiB,EAAC,CAAA;AACpD,EAAI,IAAA,QAAA,CAAS,Q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,GAAI,CAAA,GAAG,IAAI,KAAQ,GAAA,KAAA,CAAA;AAEzD,IAAO,OAAA;AAAA,MACL,MAAA;AAAA,MACA,OAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF","file":"chunk-DFQJ57GH.js","sourcesContent":["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"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext } from '@kubb/react';
|
|
2
|
+
import { jsx } from '@kubb/react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/components/Operation.tsx
|
|
5
|
+
var OperationContext = createContext({});
|
|
6
|
+
function Operation({ operation, children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(OperationContext.Provider, { value: { operation }, children });
|
|
8
|
+
}
|
|
9
|
+
Operation.Context = OperationContext;
|
|
10
|
+
var SchemaContext = createContext({
|
|
11
|
+
name: "unknown",
|
|
12
|
+
tree: []
|
|
13
|
+
});
|
|
14
|
+
function Schema({ name, value, tree = [], children }) {
|
|
15
|
+
return /* @__PURE__ */ jsx(SchemaContext.Provider, { value: { name, schema: value, tree }, children });
|
|
16
|
+
}
|
|
17
|
+
Schema.Context = SchemaContext;
|
|
18
|
+
var OasContext = createContext({});
|
|
19
|
+
function Oas({ oas, children, operations, generator }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(OasContext.Provider, { value: { oas, generator, operations }, children });
|
|
21
|
+
}
|
|
22
|
+
Oas.Context = OasContext;
|
|
23
|
+
Oas.Operation = Operation;
|
|
24
|
+
Oas.Schema = Schema;
|
|
25
|
+
|
|
26
|
+
export { Oas, Operation, Schema };
|
|
27
|
+
//# sourceMappingURL=chunk-GF26SDHQ.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-GF26SDHQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Operation.tsx","../src/components/Schema.tsx","../src/components/Oas.tsx"],"names":["createContext","jsx"],"mappings":";;;;AAcA,IAAM,gBAAA,GAAmB,aAAqC,CAAA,EAAE,CAAA,CAAA;AAEzD,SAAS,SAAU,CAAA,EAAE,SAAW,EAAA,QAAA,EAA6B,EAAA;AAClE,EAAO,uBAAA,GAAA,CAAC,iBAAiB,QAAjB,EAAA,EAA0B,OAAO,EAAE,SAAA,IAAc,QAAS,EAAA,CAAA,CAAA;AACpE,CAAA;AAEA,SAAA,CAAU,OAAU,GAAA,gBAAA,CAAA;ACDpB,IAAM,gBAAgBA,aAAkC,CAAA;AAAA,EACtD,IAAM,EAAA,SAAA;AAAA,EACN,MAAM,EAAC;AACT,CAAC,CAAA,CAAA;AAEM,SAAS,MAAA,CAAO,EAAE,IAAM,EAAA,KAAA,EAAO,OAAO,EAAC,EAAG,UAA6B,EAAA;AAC5E,EAAA,uBAAOC,GAAAA,CAAC,aAAc,CAAA,QAAA,EAAd,EAAuB,KAAA,EAAO,EAAE,IAAA,EAAM,MAAQ,EAAA,KAAA,EAAO,IAAK,EAAA,EAAI,QAAS,EAAA,CAAA,CAAA;AACjF,CAAA;AAEA,MAAA,CAAO,OAAU,GAAA,aAAA,CAAA;ACAjB,IAAM,UAAA,GAAaD,aAA+B,CAAA,EAAE,CAAA,CAAA;AAE7C,SAAS,IAAI,EAAE,GAAA,EAAK,QAAU,EAAA,UAAA,EAAY,WAA8B,EAAA;AAC7E,EAAO,uBAAAC,GAAC,CAAA,UAAA,CAAW,QAAX,EAAA,EAAoB,KAAO,EAAA,EAAE,GAAK,EAAA,SAAA,EAAW,UAAW,EAAA,EAAI,QAAS,EAAA,CAAA,CAAA;AAC/E,CAAA;AAEA,GAAA,CAAI,OAAU,GAAA,UAAA,CAAA;AACd,GAAA,CAAI,SAAY,GAAA,SAAA,CAAA;AAChB,GAAA,CAAI,MAAS,GAAA,MAAA","file":"chunk-GF26SDHQ.js","sourcesContent":["import { createContext } from '@kubb/react'\n\nimport type { Operation as OperationType } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\n\ntype Props = {\n operation: OperationType\n children?: KubbNode\n}\n\ntype OperationContextProps = {\n operation?: OperationType\n}\n\nconst OperationContext = createContext<OperationContextProps>({})\n\nexport function Operation({ operation, children }: Props): KubbNode {\n return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>\n}\n\nOperation.Context = OperationContext\n","import { createContext } from '@kubb/react'\n\nimport type { SchemaObject } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { Schema as SchemaType } from '../SchemaMapper.ts'\n\nexport type SchemaContextProps = {\n name: string\n schema?: SchemaObject\n tree: Array<SchemaType>\n}\n\ntype Props = {\n name: string\n value?: SchemaObject\n tree?: Array<SchemaType>\n children?: KubbNode\n}\n\nconst SchemaContext = createContext<SchemaContextProps>({\n name: 'unknown',\n tree: [],\n})\n\nexport function Schema({ name, value, tree = [], children }: Props): KubbNode {\n return <SchemaContext.Provider value={{ name, schema: value, tree }}>{children}</SchemaContext.Provider>\n}\n\nSchema.Context = SchemaContext\n","import { createContext } from '@kubb/react'\n\nimport { Operation } from './Operation.tsx'\nimport { Schema } from './Schema.tsx'\n\nimport type { Oas as OasType, Operation as OperationType } from '@kubb/oas'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from '../OperationGenerator.ts'\n\ntype Props = {\n oas: OasType\n operations?: OperationType[]\n /**\n * @deprecated\n */\n generator?: Omit<OperationGenerator, 'build'>\n children?: KubbNode\n}\n\ntype OasContextProps = {\n oas?: OasType\n operations?: OperationType[]\n /**\n * @deprecated\n */\n generator?: Omit<OperationGenerator, 'build'>\n}\n\nconst OasContext = createContext<OasContextProps>({})\n\nexport function Oas({ oas, children, operations, generator }: Props): KubbNode {\n return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>\n}\n\nOas.Context = OasContext\nOas.Operation = Operation\nOas.Schema = Schema\n"]}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkCQMUJN22_cjs = require('./chunk-CQMUJN22.cjs');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var utils = require('@kubb/core/utils');
|
|
6
|
-
var parser = require('@kubb/oas/parser');
|
|
7
3
|
var oas = require('@kubb/oas');
|
|
8
|
-
var yaml = require('@stoplight/yaml');
|
|
9
|
-
|
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
|
|
12
|
-
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
13
4
|
|
|
14
5
|
// src/utils/getSchemas.ts
|
|
15
|
-
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
16
6
|
function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies", "responses"] }) {
|
|
17
7
|
const components = oas.getDefinition().components;
|
|
18
8
|
let schemas = {};
|
|
@@ -42,31 +32,6 @@ function getSchemas({ oas, contentType, includes = ["schemas", "requestBodies",
|
|
|
42
32
|
}
|
|
43
33
|
return schemas;
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
// src/utils/parseFromConfig.ts
|
|
47
|
-
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
48
|
-
function parseFromConfig(config, options = {}, oasClass = oas.Oas) {
|
|
49
|
-
if ("data" in config.input) {
|
|
50
|
-
if (typeof config.input.data === "object") {
|
|
51
|
-
const api2 = JSON.parse(JSON.stringify(config.input.data));
|
|
52
|
-
return parser.parse(api2, options, oasClass);
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const api2 = yaml__default.default.parse(config.input.data);
|
|
56
|
-
return parser.parse(api2, options, oasClass);
|
|
57
|
-
} catch (e) {
|
|
58
|
-
}
|
|
59
|
-
const api = JSON.parse(JSON.stringify(config.input.data));
|
|
60
|
-
return parser.parse(api, options, oasClass);
|
|
61
|
-
}
|
|
62
|
-
if (new utils.URLPath(config.input.path).isURL) {
|
|
63
|
-
return parser.parse(config.input.path, options, oasClass);
|
|
64
|
-
}
|
|
65
|
-
return parser.parse(path.resolve(config.root, config.input.path), options, oasClass);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/utils/getSchemaFactory.ts
|
|
69
|
-
chunkCQMUJN22_cjs.init_cjs_shims();
|
|
70
35
|
function getSchemaFactory(oas$1) {
|
|
71
36
|
return (schema) => {
|
|
72
37
|
const version = oas.isOpenApiV3_1Document(oas$1.api) ? "3.1" : "3.0";
|
|
@@ -79,6 +44,5 @@ function getSchemaFactory(oas$1) {
|
|
|
79
44
|
|
|
80
45
|
exports.getSchemaFactory = getSchemaFactory;
|
|
81
46
|
exports.getSchemas = getSchemas;
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
84
|
-
//# sourceMappingURL=chunk-IVSE3A7W.cjs.map
|
|
47
|
+
//# sourceMappingURL=chunk-HP5WAFBU.cjs.map
|
|
48
|
+
//# sourceMappingURL=chunk-HP5WAFBU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getSchemas.ts","../src/utils/getSchemaFactory.ts"],"names":["oas","isOpenApiV3_1Document"],"mappings":";;;;;AAUO,SAAS,UAAA,CAAW,EAAE,GAAA,EAAK,WAAa,EAAA,QAAA,GAAW,CAAC,SAAW,EAAA,eAAA,EAAiB,WAAW,CAAA,EAA6D,EAAA;AAC7J,EAAM,MAAA,UAAA,GAAa,GAAI,CAAA,aAAA,EAAgB,CAAA,UAAA,CAAA;AAEvC,EAAA,IAAI,UAAiD,EAAC,CAAA;AAEtD,EAAI,IAAA,QAAA,CAAS,QAAS,CAAA,SAAS,CAAG,EAAA;AAChC,IAAU,OAAA,GAAA;AAAA,MACR,GAAG,OAAA;AAAA,MACH,GAAK,UAAY,EAAA,OAAA,IAAqD,EAAC;AAAA,KACzE,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ACrBO,SAAS,iBAAmDA,KAA6D,EAAA;AAC9H,EAAA,OAAO,CAAC,MAA0B,KAAA;AAChC,IAAA,MAAM,OAAU,GAAAC,yBAAA,CAAsBD,KAAI,CAAA,GAAG,IAAI,KAAQ,GAAA,KAAA,CAAA;AAEzD,IAAO,OAAA;AAAA,MACL,MAAA;AAAA,MACA,OAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACF","file":"chunk-HP5WAFBU.cjs","sourcesContent":["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"]}
|