@kubb/plugin-oas 0.0.0-canary-20240509211223
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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/OperationGenerator-DvnXUUp4.d.ts +56 -0
- package/dist/OperationGenerator-X6CTMfhG.d.cts +56 -0
- package/dist/Schema-BWPWyiQO.d.cts +39 -0
- package/dist/Schema-DFZBfjF2.d.ts +39 -0
- package/dist/SchemaGenerator-hK5SHxTI.d.ts +316 -0
- package/dist/SchemaGenerator-z_7YrAAB.d.cts +316 -0
- package/dist/chunk-2MJ2CQMI.js +61 -0
- package/dist/chunk-2MJ2CQMI.js.map +1 -0
- package/dist/chunk-3RCQ2LNT.js +81 -0
- package/dist/chunk-3RCQ2LNT.js.map +1 -0
- package/dist/chunk-55NUFNT6.cjs +68 -0
- package/dist/chunk-55NUFNT6.cjs.map +1 -0
- package/dist/chunk-ECXSQTMV.cjs +81 -0
- package/dist/chunk-ECXSQTMV.cjs.map +1 -0
- package/dist/chunk-EPTOYYAP.js +3312 -0
- package/dist/chunk-EPTOYYAP.js.map +1 -0
- package/dist/chunk-H52M2RUX.cjs +3312 -0
- package/dist/chunk-H52M2RUX.cjs.map +1 -0
- package/dist/chunk-LQ6IAWRX.js +68 -0
- package/dist/chunk-LQ6IAWRX.js.map +1 -0
- package/dist/chunk-VNFSHGSN.cjs +61 -0
- package/dist/chunk-VNFSHGSN.cjs.map +1 -0
- package/dist/components.cjs +18 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +41 -0
- package/dist/components.d.ts +41 -0
- package/dist/components.js +18 -0
- package/dist/components.js.map +1 -0
- package/dist/hooks.cjs +152 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +76 -0
- package/dist/hooks.d.ts +76 -0
- package/dist/hooks.js +152 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +985 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +985 -0
- package/dist/index.js.map +1 -0
- package/dist/types-n5zV4Q3s.d.cts +146 -0
- package/dist/types-n5zV4Q3s.d.ts +146 -0
- package/dist/utils.cjs +126 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +80 -0
- package/dist/utils.d.ts +80 -0
- package/dist/utils.js +126 -0
- package/dist/utils.js.map +1 -0
- package/package.json +107 -0
- package/src/OperationGenerator.ts +328 -0
- package/src/SchemaGenerator.ts +827 -0
- package/src/SchemaMapper.ts +145 -0
- package/src/components/Oas.tsx +31 -0
- package/src/components/Operation.tsx +21 -0
- package/src/components/Schema.tsx +156 -0
- package/src/components/index.ts +3 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useOas.ts +15 -0
- package/src/hooks/useOperation.ts +18 -0
- package/src/hooks/useOperationManager.ts +142 -0
- package/src/hooks/useOperations.ts +40 -0
- package/src/hooks/useSchema.ts +23 -0
- package/src/index.ts +30 -0
- package/src/plugin.ts +133 -0
- package/src/types.ts +147 -0
- package/src/utils/getComments.ts +15 -0
- package/src/utils/getGroupedByTagFiles.ts +81 -0
- package/src/utils/getParams.ts +57 -0
- package/src/utils/getSchemaFactory.ts +33 -0
- package/src/utils/getSchemas.ts +45 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/parseFromConfig.ts +36 -0
- package/src/utils/refSorter.ts +13 -0
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas';
|
|
2
|
+
import { KubbFile, Plugin, Config } from '@kubb/core';
|
|
3
|
+
import { Logger } from '@kubb/core/logger';
|
|
4
|
+
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
5
|
+
import { Params } from '@kubb/react';
|
|
6
|
+
import { d as OperationSchema, b as Refs } from './types-n5zV4Q3s.cjs';
|
|
7
|
+
export { G as GetSchemasProps, h as getSchemas } from './types-n5zV4Q3s.cjs';
|
|
8
|
+
import { FormatOptions } from '@kubb/oas/parser';
|
|
9
|
+
|
|
10
|
+
declare function getComments(operation: Operation): string[];
|
|
11
|
+
|
|
12
|
+
type Options = {
|
|
13
|
+
logger: Logger;
|
|
14
|
+
files: KubbFile.File[];
|
|
15
|
+
plugin: Plugin;
|
|
16
|
+
template: string;
|
|
17
|
+
exportAs: string;
|
|
18
|
+
/**
|
|
19
|
+
* Root based on root and output.path specified in the config
|
|
20
|
+
*/
|
|
21
|
+
root: string;
|
|
22
|
+
/**
|
|
23
|
+
* Output for plugin
|
|
24
|
+
*/
|
|
25
|
+
output: {
|
|
26
|
+
path: string;
|
|
27
|
+
exportAs?: string;
|
|
28
|
+
extName?: KubbFile.Extname;
|
|
29
|
+
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type FileMeta = {
|
|
33
|
+
pluginKey?: Plugin['key'];
|
|
34
|
+
tag?: string;
|
|
35
|
+
};
|
|
36
|
+
declare function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @deprecated
|
|
41
|
+
* TODO move to operationManager hook
|
|
42
|
+
*/
|
|
43
|
+
declare function getASTParams(operationSchema: OperationSchema | undefined, { typed, override, }?: {
|
|
44
|
+
typed?: boolean;
|
|
45
|
+
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
46
|
+
}): FunctionParamsAST[];
|
|
47
|
+
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
48
|
+
typed?: boolean;
|
|
49
|
+
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
50
|
+
}): Params;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Make it possible to narrow down the schema based on a specific version(3 or 3.1)
|
|
54
|
+
*/
|
|
55
|
+
type SchemaResult<TWithRef extends boolean = false> = {
|
|
56
|
+
schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {
|
|
57
|
+
nullable?: boolean;
|
|
58
|
+
'x-nullable'?: boolean;
|
|
59
|
+
};
|
|
60
|
+
version: '3.0';
|
|
61
|
+
} | {
|
|
62
|
+
schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
'x-nullable'?: boolean;
|
|
65
|
+
};
|
|
66
|
+
version: '3.1';
|
|
67
|
+
};
|
|
68
|
+
declare function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef>;
|
|
69
|
+
|
|
70
|
+
type Generated = {
|
|
71
|
+
import: {
|
|
72
|
+
refs: Refs;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare function refsSorter<T extends Generated>(a: T, b: T): number;
|
|
77
|
+
|
|
78
|
+
declare function parseFromConfig(config: Config, options?: FormatOptions): Promise<Oas>;
|
|
79
|
+
|
|
80
|
+
export { getASTParams, getComments, getGroupedByTagFiles, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas';
|
|
2
|
+
import { KubbFile, Plugin, Config } from '@kubb/core';
|
|
3
|
+
import { Logger } from '@kubb/core/logger';
|
|
4
|
+
import { FunctionParamsAST } from '@kubb/core/utils';
|
|
5
|
+
import { Params } from '@kubb/react';
|
|
6
|
+
import { d as OperationSchema, b as Refs } from './types-n5zV4Q3s.js';
|
|
7
|
+
export { G as GetSchemasProps, h as getSchemas } from './types-n5zV4Q3s.js';
|
|
8
|
+
import { FormatOptions } from '@kubb/oas/parser';
|
|
9
|
+
|
|
10
|
+
declare function getComments(operation: Operation): string[];
|
|
11
|
+
|
|
12
|
+
type Options = {
|
|
13
|
+
logger: Logger;
|
|
14
|
+
files: KubbFile.File[];
|
|
15
|
+
plugin: Plugin;
|
|
16
|
+
template: string;
|
|
17
|
+
exportAs: string;
|
|
18
|
+
/**
|
|
19
|
+
* Root based on root and output.path specified in the config
|
|
20
|
+
*/
|
|
21
|
+
root: string;
|
|
22
|
+
/**
|
|
23
|
+
* Output for plugin
|
|
24
|
+
*/
|
|
25
|
+
output: {
|
|
26
|
+
path: string;
|
|
27
|
+
exportAs?: string;
|
|
28
|
+
extName?: KubbFile.Extname;
|
|
29
|
+
exportType?: 'barrel' | 'barrelNamed' | false;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type FileMeta = {
|
|
33
|
+
pluginKey?: Plugin['key'];
|
|
34
|
+
tag?: string;
|
|
35
|
+
};
|
|
36
|
+
declare function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @deprecated
|
|
41
|
+
* TODO move to operationManager hook
|
|
42
|
+
*/
|
|
43
|
+
declare function getASTParams(operationSchema: OperationSchema | undefined, { typed, override, }?: {
|
|
44
|
+
typed?: boolean;
|
|
45
|
+
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
46
|
+
}): FunctionParamsAST[];
|
|
47
|
+
declare function getPathParams(operationSchema: OperationSchema | undefined, options?: {
|
|
48
|
+
typed?: boolean;
|
|
49
|
+
override?: (data: FunctionParamsAST) => FunctionParamsAST;
|
|
50
|
+
}): Params;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Make it possible to narrow down the schema based on a specific version(3 or 3.1)
|
|
54
|
+
*/
|
|
55
|
+
type SchemaResult<TWithRef extends boolean = false> = {
|
|
56
|
+
schema?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {
|
|
57
|
+
nullable?: boolean;
|
|
58
|
+
'x-nullable'?: boolean;
|
|
59
|
+
};
|
|
60
|
+
version: '3.0';
|
|
61
|
+
} | {
|
|
62
|
+
schema?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
'x-nullable'?: boolean;
|
|
65
|
+
};
|
|
66
|
+
version: '3.1';
|
|
67
|
+
};
|
|
68
|
+
declare function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef>;
|
|
69
|
+
|
|
70
|
+
type Generated = {
|
|
71
|
+
import: {
|
|
72
|
+
refs: Refs;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare function refsSorter<T extends Generated>(a: T, b: T): number;
|
|
77
|
+
|
|
78
|
+
declare function parseFromConfig(config: Config, options?: FormatOptions): Promise<Oas>;
|
|
79
|
+
|
|
80
|
+
export { getASTParams, getComments, getGroupedByTagFiles, getPathParams, getSchemaFactory, parseFromConfig, refsSorter };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSchemaFactory,
|
|
3
|
+
getSchemas,
|
|
4
|
+
parseFromConfig
|
|
5
|
+
} from "./chunk-3RCQ2LNT.js";
|
|
6
|
+
import {
|
|
7
|
+
init_esm_shims
|
|
8
|
+
} from "./chunk-LQ6IAWRX.js";
|
|
9
|
+
|
|
10
|
+
// src/utils/index.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
|
|
13
|
+
// src/utils/getComments.ts
|
|
14
|
+
init_esm_shims();
|
|
15
|
+
import transformers from "@kubb/core/transformers";
|
|
16
|
+
import { URLPath } from "@kubb/core/utils";
|
|
17
|
+
function getComments(operation) {
|
|
18
|
+
return [
|
|
19
|
+
operation.getDescription() && `@description ${operation.getDescription()}`,
|
|
20
|
+
operation.getSummary() && `@summary ${operation.getSummary()}`,
|
|
21
|
+
operation.path && `@link ${new URLPath(operation.path).URL}`,
|
|
22
|
+
operation.isDeprecated() && "@deprecated"
|
|
23
|
+
].filter(Boolean).map((text) => transformers.trim(text));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/utils/getGroupedByTagFiles.ts
|
|
27
|
+
init_esm_shims();
|
|
28
|
+
import { resolve } from "path";
|
|
29
|
+
import { FileManager } from "@kubb/core";
|
|
30
|
+
import { getRelativePath } from "@kubb/core/fs";
|
|
31
|
+
import transformers2 from "@kubb/core/transformers";
|
|
32
|
+
import { renderTemplate } from "@kubb/core/utils";
|
|
33
|
+
async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }) {
|
|
34
|
+
const { path, exportType = "barrel" } = output;
|
|
35
|
+
const mode = FileManager.getMode(resolve(root, path));
|
|
36
|
+
if (mode === "single" || exportType === false) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
return files.filter((file) => {
|
|
40
|
+
const name = file.meta?.pluginKey?.[0];
|
|
41
|
+
return name === plugin.name;
|
|
42
|
+
}).map((file) => {
|
|
43
|
+
if (!file.meta?.tag) {
|
|
44
|
+
logger?.emit("debug", [`Could not find a tagName for ${JSON.stringify(file, void 0, 2)}`]);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const tag = file.meta?.tag && transformers2.camelCase(file.meta.tag);
|
|
48
|
+
const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })));
|
|
49
|
+
const tagName = renderTemplate(exportAs, { tag });
|
|
50
|
+
if (tagName) {
|
|
51
|
+
return {
|
|
52
|
+
baseName: "index.ts",
|
|
53
|
+
path: resolve(root, output.path, "index.ts"),
|
|
54
|
+
source: "",
|
|
55
|
+
exports: [
|
|
56
|
+
{
|
|
57
|
+
path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
|
|
58
|
+
asAlias: true,
|
|
59
|
+
name: tagName
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
meta: {
|
|
63
|
+
pluginKey: plugin.key
|
|
64
|
+
},
|
|
65
|
+
exportable: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}).filter(Boolean);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/utils/getParams.ts
|
|
72
|
+
init_esm_shims();
|
|
73
|
+
import { isParameterObject } from "@kubb/oas";
|
|
74
|
+
function getASTParams(operationSchema, {
|
|
75
|
+
typed = false,
|
|
76
|
+
override
|
|
77
|
+
} = {}) {
|
|
78
|
+
if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return Object.entries(operationSchema.schema.properties).map(([name, schema]) => {
|
|
82
|
+
const isParam = isParameterObject(schema);
|
|
83
|
+
const data = {
|
|
84
|
+
name,
|
|
85
|
+
enabled: !!name,
|
|
86
|
+
required: isParam ? schema.required : true,
|
|
87
|
+
type: typed ? `${operationSchema.name}["${name}"]` : void 0
|
|
88
|
+
};
|
|
89
|
+
return override ? override(data) : data;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getPathParams(operationSchema, options = {}) {
|
|
93
|
+
return getASTParams(operationSchema, options).reduce((acc, curr) => {
|
|
94
|
+
if (curr.name && curr.enabled) {
|
|
95
|
+
acc[curr.name] = {
|
|
96
|
+
default: curr.default,
|
|
97
|
+
type: curr.type,
|
|
98
|
+
optional: !curr.required
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return acc;
|
|
102
|
+
}, {});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/utils/refSorter.ts
|
|
106
|
+
init_esm_shims();
|
|
107
|
+
function refsSorter(a, b) {
|
|
108
|
+
if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {
|
|
109
|
+
return -1;
|
|
110
|
+
}
|
|
111
|
+
if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
getASTParams,
|
|
118
|
+
getComments,
|
|
119
|
+
getGroupedByTagFiles,
|
|
120
|
+
getPathParams,
|
|
121
|
+
getSchemaFactory,
|
|
122
|
+
getSchemas,
|
|
123
|
+
parseFromConfig,
|
|
124
|
+
refsSorter
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../src/utils/getComments.ts","../src/utils/getGroupedByTagFiles.ts","../src/utils/getParams.ts","../src/utils/refSorter.ts"],"sourcesContent":["export { getComments } from './getComments.ts'\nexport { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'\nexport { getASTParams, getPathParams } from './getParams.ts'\nexport { getSchemaFactory } from './getSchemaFactory.ts'\nexport type { GetSchemasProps } from './getSchemas.ts'\nexport { getSchemas } from './getSchemas.ts'\nexport { refsSorter } from './refSorter.ts'\nexport { parseFromConfig } from './parseFromConfig.ts'\n","import transformers from '@kubb/core/transformers'\nimport { URLPath } from '@kubb/core/utils'\n\nimport type { Operation } from '@kubb/oas'\n\nexport function getComments(operation: Operation): string[] {\n return [\n operation.getDescription() && `@description ${operation.getDescription()}`,\n operation.getSummary() && `@summary ${operation.getSummary()}`,\n operation.path && `@link ${new URLPath(operation.path).URL}`,\n operation.isDeprecated() && '@deprecated',\n ]\n .filter(Boolean)\n .map((text) => transformers.trim(text))\n}\n","import { resolve } from 'node:path'\n\nimport { FileManager } from '@kubb/core'\nimport { getRelativePath } from '@kubb/core/fs'\nimport transformers from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\n\nimport type { KubbFile, Plugin } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype Options = {\n logger: Logger\n files: KubbFile.File[]\n plugin: Plugin\n template: string\n exportAs: string\n /**\n * Root based on root and output.path specified in the config\n */\n root: string\n /**\n * Output for plugin\n */\n output: {\n path: string\n exportAs?: string\n extName?: KubbFile.Extname\n exportType?: 'barrel' | 'barrelNamed' | false\n }\n}\n\ntype FileMeta = {\n pluginKey?: Plugin['key']\n tag?: string\n}\n\nexport async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]> {\n const { path, exportType = 'barrel' } = output\n const mode = FileManager.getMode(resolve(root, path))\n\n if (mode === 'single' || exportType === false) {\n return []\n }\n\n return files\n .filter((file) => {\n const name = file.meta?.pluginKey?.[0]\n return name === plugin.name\n })\n .map((file: KubbFile.File<FileMeta>) => {\n if (!file.meta?.tag) {\n logger?.emit('debug', [`Could not find a tagName for ${JSON.stringify(file, undefined, 2)}`])\n\n return\n }\n\n const tag = file.meta?.tag && transformers.camelCase(file.meta.tag)\n const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })))\n const tagName = renderTemplate(exportAs, { tag })\n\n if (tagName) {\n return {\n baseName: 'index.ts' as const,\n path: resolve(root, output.path, 'index.ts'),\n source: '',\n exports: [\n {\n path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,\n asAlias: true,\n name: tagName,\n },\n ],\n meta: {\n pluginKey: plugin.key,\n },\n exportable: true,\n }\n }\n })\n .filter(Boolean)\n}\n","import { isParameterObject } from '@kubb/oas'\n\nimport type { FunctionParamsAST } from '@kubb/core/utils'\nimport type { OasTypes } from '@kubb/oas'\nimport type { Params } from '@kubb/react'\nimport type { OperationSchema } from '../types.ts'\n/**\n *\n * @deprecated\n * TODO move to operationManager hook\n */\nexport function getASTParams(\n operationSchema: OperationSchema | undefined,\n {\n typed = false,\n override,\n }: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n): FunctionParamsAST[] {\n if (!operationSchema || !operationSchema.schema.properties || !operationSchema.name) {\n return []\n }\n\n return Object.entries(operationSchema.schema.properties).map(([name, schema]: [string, OasTypes.SchemaObject]) => {\n const isParam = isParameterObject(schema)\n const data: FunctionParamsAST = {\n name,\n enabled: !!name,\n required: isParam ? schema.required : true,\n type: typed ? `${operationSchema.name}[\"${name}\"]` : undefined,\n }\n\n return override ? override(data) : data\n })\n}\n\nexport function getPathParams(\n operationSchema: OperationSchema | undefined,\n options: {\n typed?: boolean\n override?: (data: FunctionParamsAST) => FunctionParamsAST\n } = {},\n) {\n return getASTParams(operationSchema, options).reduce((acc, curr) => {\n if (curr.name && curr.enabled) {\n acc[curr.name] = {\n default: curr.default,\n type: curr.type,\n optional: !curr.required,\n }\n }\n\n return acc\n }, {} as Params)\n}\n","import type { Refs } from '../types.ts'\n\ntype Generated = { import: { refs: Refs; name: string } }\n\nexport function refsSorter<T extends Generated>(a: T, b: T): number {\n if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {\n return -1\n }\n if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {\n return 1\n }\n return 0\n}\n"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,OAAO,kBAAkB;AACzB,SAAS,eAAe;AAIjB,SAAS,YAAY,WAAgC;AAC1D,SAAO;AAAA,IACL,UAAU,eAAe,KAAK,gBAAgB,UAAU,eAAe,CAAC;AAAA,IACxE,UAAU,WAAW,KAAK,YAAY,UAAU,WAAW,CAAC;AAAA,IAC5D,UAAU,QAAQ,SAAS,IAAI,QAAQ,UAAU,IAAI,EAAE,GAAG;AAAA,IAC1D,UAAU,aAAa,KAAK;AAAA,EAC9B,EACG,OAAO,OAAO,EACd,IAAI,CAAC,SAAS,aAAa,KAAK,IAAI,CAAC;AAC1C;;;ACdA;AAAA,SAAS,eAAe;AAExB,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,OAAOA,mBAAkB;AACzB,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3
|
+
"version": "0.0.0-canary-20240509211223",
|
|
4
|
+
"description": "Generator swagger",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"plugins",
|
|
8
|
+
"kubb",
|
|
9
|
+
"codegen",
|
|
10
|
+
"swagger",
|
|
11
|
+
"openapi"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git://github.com/kubb-labs/kubb.git",
|
|
16
|
+
"directory": "packages/plugin-oas"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Stijn Van Hulle <stijn@stijnvanhulle.be",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs",
|
|
26
|
+
"default": "./dist/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./utils": {
|
|
29
|
+
"import": "./dist/utils.js",
|
|
30
|
+
"require": "./dist/utils.cjs",
|
|
31
|
+
"default": "./dist/utils.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./hooks": {
|
|
34
|
+
"import": "./dist/hooks.js",
|
|
35
|
+
"require": "./dist/hooks.cjs",
|
|
36
|
+
"default": "./dist/hooks.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./components": {
|
|
39
|
+
"import": "./dist/components.js",
|
|
40
|
+
"require": "./dist/components.cjs",
|
|
41
|
+
"default": "./dist/components.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json",
|
|
44
|
+
"./*": "./*"
|
|
45
|
+
},
|
|
46
|
+
"main": "dist/index.cjs",
|
|
47
|
+
"module": "dist/index.js",
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"typesVersions": {
|
|
50
|
+
"*": {
|
|
51
|
+
"utils": [
|
|
52
|
+
"./dist/utils.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"hooks": [
|
|
55
|
+
"./dist/hooks.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"components": [
|
|
58
|
+
"./dist/components.d.ts"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"src",
|
|
64
|
+
"dist",
|
|
65
|
+
"!/**/**.test.**",
|
|
66
|
+
"!/**/__tests__/**"
|
|
67
|
+
],
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@stoplight/yaml": "^4.3.0",
|
|
70
|
+
"remeda": "^1.61.0",
|
|
71
|
+
"@kubb/core": "0.0.0-canary-20240509211223",
|
|
72
|
+
"@kubb/oas": "0.0.0-canary-20240509211223",
|
|
73
|
+
"@kubb/react": "0.0.0-canary-20240509211223"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/react": "^18.3.1",
|
|
77
|
+
"@types/react-dom": "^18.3.0",
|
|
78
|
+
"react": "^18.3.1",
|
|
79
|
+
"tsup": "^8.0.2",
|
|
80
|
+
"typescript": "^5.4.5",
|
|
81
|
+
"@kubb/config-biome": "0.0.0-canary-20240509211223",
|
|
82
|
+
"@kubb/config-ts": "0.0.0-canary-20240509211223",
|
|
83
|
+
"@kubb/config-tsup": "0.0.0-canary-20240509211223"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@kubb/react": "0.0.0-canary-20240509211223"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=18",
|
|
90
|
+
"pnpm": ">=8.15.0"
|
|
91
|
+
},
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"access": "public",
|
|
94
|
+
"registry": "https://registry.npmjs.org/"
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "tsup",
|
|
98
|
+
"clean": "npx rimraf ./dist",
|
|
99
|
+
"lint": "bun biome lint .",
|
|
100
|
+
"lint:fix": "bun biome lint --apply-unsafe .",
|
|
101
|
+
"release": "pnpm publish --no-git-check",
|
|
102
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
103
|
+
"start": "tsup --watch",
|
|
104
|
+
"test": "vitest --passWithNoTests",
|
|
105
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
106
|
+
}
|
|
107
|
+
}
|