@kubb/swagger-ts 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.cjs +80 -42
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +61 -16
- package/dist/components.d.ts +61 -16
- package/dist/components.js +85 -45
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +82 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +409 -11
- package/dist/index.d.ts +409 -11
- package/dist/index.js +83 -39
- package/dist/index.js.map +1 -1
- package/dist/infer.d.ts +381 -0
- package/dist/infer.js +5 -0
- package/dist/infer.js.map +1 -0
- package/package.json +14 -8
- package/src/OperationGenerator.tsx +15 -3
- package/src/components/Oas.tsx +84 -0
- package/src/components/index.ts +1 -0
- package/src/infer/index.ts +7 -0
- package/src/infer/mappers.ts +93 -0
- package/src/infer/model.ts +38 -0
- package/src/infer/parse.ts +58 -0
- package/src/infer/requestParams.ts +170 -0
- package/src/infer/response.ts +39 -0
- package/src/infer/security.ts +158 -0
- package/src/plugin.ts +10 -24
- package/src/types.ts +21 -10
package/dist/components.d.cts
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
|
1
|
+
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder, OasTypes } from '@kubb/swagger';
|
2
2
|
import { PluginFactoryOptions, ResolveNameParams, KubbFile } from '@kubb/core';
|
3
3
|
import { ReactNode } from 'react';
|
4
4
|
|
5
5
|
type Options = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
output?: {
|
7
|
+
/**
|
8
|
+
* Relative path to save the TypeScript types.
|
9
|
+
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
10
|
+
* @default 'types'
|
11
|
+
*/
|
12
|
+
path: string;
|
13
|
+
/**
|
14
|
+
* Name to be used for the `export * as {{exportAs}} from './'`
|
15
|
+
*/
|
16
|
+
exportAs?: string;
|
17
|
+
};
|
12
18
|
/**
|
13
19
|
* Group the TypeScript types based on the provided name.
|
14
20
|
*/
|
@@ -26,10 +32,6 @@ type Options = {
|
|
26
32
|
*/
|
27
33
|
output?: string;
|
28
34
|
};
|
29
|
-
/**
|
30
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
31
|
-
*/
|
32
|
-
exportAs?: string;
|
33
35
|
/**
|
34
36
|
* Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
|
35
37
|
*/
|
@@ -66,12 +68,19 @@ type Options = {
|
|
66
68
|
*/
|
67
69
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
68
70
|
};
|
71
|
+
/**
|
72
|
+
* Export Oas object as Oas type with import type { Infer } from `@kubb/swagger-ts/infer`
|
73
|
+
* TODO add docs
|
74
|
+
* @beta
|
75
|
+
*/
|
76
|
+
oasType?: boolean;
|
69
77
|
};
|
70
78
|
type ResolvedOptions = {
|
71
79
|
enumType: NonNullable<Options['enumType']>;
|
72
80
|
dateType: NonNullable<Options['dateType']>;
|
73
81
|
optionalType: NonNullable<Options['optionalType']>;
|
74
82
|
transformers: NonNullable<Options['transformers']>;
|
83
|
+
oasType: NonNullable<Options['oasType']>;
|
75
84
|
usedEnumNames: Record<string, number>;
|
76
85
|
};
|
77
86
|
type AppMeta = AppMeta$1;
|
@@ -86,17 +95,53 @@ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
|
|
86
95
|
build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
|
87
96
|
}
|
88
97
|
|
89
|
-
type Props$
|
98
|
+
type Props$2 = {
|
90
99
|
builder: TypeBuilder;
|
91
100
|
};
|
92
|
-
declare function Mutation({ builder, }: Props$
|
101
|
+
declare function Mutation({ builder, }: Props$2): ReactNode;
|
93
102
|
declare namespace Mutation {
|
94
|
-
var File: ({ mode }: FileProps$
|
103
|
+
var File: ({ mode }: FileProps$2) => ReactNode;
|
95
104
|
}
|
96
|
-
type FileProps$
|
105
|
+
type FileProps$2 = {
|
97
106
|
mode: KubbFile.Mode;
|
98
107
|
};
|
99
108
|
|
109
|
+
type TemplateProps = {
|
110
|
+
/**
|
111
|
+
* Name of the function
|
112
|
+
*/
|
113
|
+
name: string;
|
114
|
+
typeName: string;
|
115
|
+
api: OasTypes.OASDocument;
|
116
|
+
};
|
117
|
+
declare function Template({ name, typeName, api, }: TemplateProps): ReactNode;
|
118
|
+
declare const defaultTemplates: {
|
119
|
+
readonly default: typeof Template;
|
120
|
+
};
|
121
|
+
type Props$1 = {
|
122
|
+
name: string;
|
123
|
+
typeName: string;
|
124
|
+
/**
|
125
|
+
* This will make it possible to override the default behaviour.
|
126
|
+
*/
|
127
|
+
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
128
|
+
};
|
129
|
+
declare function Oas({ name, typeName, Template, }: Props$1): ReactNode;
|
130
|
+
declare namespace Oas {
|
131
|
+
var File: ({ name, typeName, templates }: FileProps$1) => ReactNode;
|
132
|
+
var templates: {
|
133
|
+
readonly default: typeof Template;
|
134
|
+
};
|
135
|
+
}
|
136
|
+
type FileProps$1 = {
|
137
|
+
name: string;
|
138
|
+
typeName: string;
|
139
|
+
/**
|
140
|
+
* This will make it possible to override the default behaviour.
|
141
|
+
*/
|
142
|
+
templates?: typeof defaultTemplates;
|
143
|
+
};
|
144
|
+
|
100
145
|
type Props = {
|
101
146
|
builder: TypeBuilder;
|
102
147
|
};
|
@@ -108,4 +153,4 @@ type FileProps = {
|
|
108
153
|
mode: KubbFile.Mode;
|
109
154
|
};
|
110
155
|
|
111
|
-
export { Mutation, Query };
|
156
|
+
export { Mutation, Oas, Query };
|
package/dist/components.d.ts
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
|
1
|
+
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder, OasTypes } from '@kubb/swagger';
|
2
2
|
import { PluginFactoryOptions, ResolveNameParams, KubbFile } from '@kubb/core';
|
3
3
|
import { ReactNode } from 'react';
|
4
4
|
|
5
5
|
type Options = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
output?: {
|
7
|
+
/**
|
8
|
+
* Relative path to save the TypeScript types.
|
9
|
+
* When output is a file it will save all models inside that file else it will create a file per schema item.
|
10
|
+
* @default 'types'
|
11
|
+
*/
|
12
|
+
path: string;
|
13
|
+
/**
|
14
|
+
* Name to be used for the `export * as {{exportAs}} from './'`
|
15
|
+
*/
|
16
|
+
exportAs?: string;
|
17
|
+
};
|
12
18
|
/**
|
13
19
|
* Group the TypeScript types based on the provided name.
|
14
20
|
*/
|
@@ -26,10 +32,6 @@ type Options = {
|
|
26
32
|
*/
|
27
33
|
output?: string;
|
28
34
|
};
|
29
|
-
/**
|
30
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
31
|
-
*/
|
32
|
-
exportAs?: string;
|
33
35
|
/**
|
34
36
|
* Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
|
35
37
|
*/
|
@@ -66,12 +68,19 @@ type Options = {
|
|
66
68
|
*/
|
67
69
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
68
70
|
};
|
71
|
+
/**
|
72
|
+
* Export Oas object as Oas type with import type { Infer } from `@kubb/swagger-ts/infer`
|
73
|
+
* TODO add docs
|
74
|
+
* @beta
|
75
|
+
*/
|
76
|
+
oasType?: boolean;
|
69
77
|
};
|
70
78
|
type ResolvedOptions = {
|
71
79
|
enumType: NonNullable<Options['enumType']>;
|
72
80
|
dateType: NonNullable<Options['dateType']>;
|
73
81
|
optionalType: NonNullable<Options['optionalType']>;
|
74
82
|
transformers: NonNullable<Options['transformers']>;
|
83
|
+
oasType: NonNullable<Options['oasType']>;
|
75
84
|
usedEnumNames: Record<string, number>;
|
76
85
|
};
|
77
86
|
type AppMeta = AppMeta$1;
|
@@ -86,17 +95,53 @@ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
|
|
86
95
|
build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
|
87
96
|
}
|
88
97
|
|
89
|
-
type Props$
|
98
|
+
type Props$2 = {
|
90
99
|
builder: TypeBuilder;
|
91
100
|
};
|
92
|
-
declare function Mutation({ builder, }: Props$
|
101
|
+
declare function Mutation({ builder, }: Props$2): ReactNode;
|
93
102
|
declare namespace Mutation {
|
94
|
-
var File: ({ mode }: FileProps$
|
103
|
+
var File: ({ mode }: FileProps$2) => ReactNode;
|
95
104
|
}
|
96
|
-
type FileProps$
|
105
|
+
type FileProps$2 = {
|
97
106
|
mode: KubbFile.Mode;
|
98
107
|
};
|
99
108
|
|
109
|
+
type TemplateProps = {
|
110
|
+
/**
|
111
|
+
* Name of the function
|
112
|
+
*/
|
113
|
+
name: string;
|
114
|
+
typeName: string;
|
115
|
+
api: OasTypes.OASDocument;
|
116
|
+
};
|
117
|
+
declare function Template({ name, typeName, api, }: TemplateProps): ReactNode;
|
118
|
+
declare const defaultTemplates: {
|
119
|
+
readonly default: typeof Template;
|
120
|
+
};
|
121
|
+
type Props$1 = {
|
122
|
+
name: string;
|
123
|
+
typeName: string;
|
124
|
+
/**
|
125
|
+
* This will make it possible to override the default behaviour.
|
126
|
+
*/
|
127
|
+
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
128
|
+
};
|
129
|
+
declare function Oas({ name, typeName, Template, }: Props$1): ReactNode;
|
130
|
+
declare namespace Oas {
|
131
|
+
var File: ({ name, typeName, templates }: FileProps$1) => ReactNode;
|
132
|
+
var templates: {
|
133
|
+
readonly default: typeof Template;
|
134
|
+
};
|
135
|
+
}
|
136
|
+
type FileProps$1 = {
|
137
|
+
name: string;
|
138
|
+
typeName: string;
|
139
|
+
/**
|
140
|
+
* This will make it possible to override the default behaviour.
|
141
|
+
*/
|
142
|
+
templates?: typeof defaultTemplates;
|
143
|
+
};
|
144
|
+
|
100
145
|
type Props = {
|
101
146
|
builder: TypeBuilder;
|
102
147
|
};
|
@@ -108,4 +153,4 @@ type FileProps = {
|
|
108
153
|
mode: KubbFile.Mode;
|
109
154
|
};
|
110
155
|
|
111
|
-
export { Mutation, Query };
|
156
|
+
export { Mutation, Oas, Query };
|
package/dist/components.js
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
+
import { createRequire } from 'module';
|
1
2
|
import transformers2, { camelCase, pascalCase } from '@kubb/core/transformers';
|
2
3
|
import { print } from '@kubb/parser';
|
3
4
|
import * as factory2 from '@kubb/parser/factory';
|
4
5
|
import { keywordTypeNodes } from '@kubb/parser/factory';
|
5
|
-
import { usePlugin,
|
6
|
-
import {
|
6
|
+
import { usePlugin, useFile, File, usePluginManager, createRoot, Type } from '@kubb/react';
|
7
|
+
import { useOas, useSchemas, useOperationFile, useOperationName, useOperation } from '@kubb/swagger/hooks';
|
7
8
|
import { pluginName as pluginName$1, OasBuilder, OperationGenerator as OperationGenerator$1 } from '@kubb/swagger';
|
8
9
|
import { refsSorter, isReference, getSchemaFactory } from '@kubb/swagger/utils';
|
9
10
|
import { createPlugin, FileManager, PluginManager, Generator } from '@kubb/core';
|
10
11
|
import { renderTemplate, getUniqueName } from '@kubb/core/utils';
|
11
12
|
import path from 'path';
|
12
13
|
|
14
|
+
createRequire(import.meta.url);
|
15
|
+
|
13
16
|
var __create = Object.create;
|
14
17
|
var __defProp = Object.defineProperty;
|
15
18
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -3138,11 +3141,11 @@ var require_react_jsx_runtime_development = __commonJS({
|
|
3138
3141
|
return jsxWithValidation(type, props, key, false);
|
3139
3142
|
}
|
3140
3143
|
}
|
3141
|
-
var
|
3142
|
-
var
|
3144
|
+
var jsx5 = jsxWithValidationDynamic;
|
3145
|
+
var jsxs4 = jsxWithValidationStatic;
|
3143
3146
|
exports.Fragment = REACT_FRAGMENT_TYPE;
|
3144
|
-
exports.jsx =
|
3145
|
-
exports.jsxs =
|
3147
|
+
exports.jsx = jsx5;
|
3148
|
+
exports.jsxs = jsxs4;
|
3146
3149
|
})();
|
3147
3150
|
}
|
3148
3151
|
}
|
@@ -3178,9 +3181,51 @@ init_esm_shims();
|
|
3178
3181
|
// src/OperationGenerator.tsx
|
3179
3182
|
init_esm_shims();
|
3180
3183
|
|
3181
|
-
// src/components/
|
3184
|
+
// src/components/Oas.tsx
|
3182
3185
|
init_esm_shims();
|
3183
3186
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
3187
|
+
function Template({
|
3188
|
+
name,
|
3189
|
+
typeName,
|
3190
|
+
api
|
3191
|
+
}) {
|
3192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
3193
|
+
`export const ${name} = ${JSON.stringify(api, void 0, 2)} as const`,
|
3194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
3195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Type, { name: typeName, export: true, children: `Parse<typeof ${name}>` })
|
3196
|
+
] });
|
3197
|
+
}
|
3198
|
+
var defaultTemplates = { default: Template };
|
3199
|
+
function Oas({
|
3200
|
+
name,
|
3201
|
+
typeName,
|
3202
|
+
Template: Template2 = defaultTemplates.default
|
3203
|
+
}) {
|
3204
|
+
const oas = useOas();
|
3205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Template2, { name, typeName, api: oas.api });
|
3206
|
+
}
|
3207
|
+
Oas.File = function({ name, typeName, templates = defaultTemplates }) {
|
3208
|
+
const { key: pluginKey2 } = usePlugin();
|
3209
|
+
const file = useFile({ name, pluginKey: pluginKey2 });
|
3210
|
+
const Template2 = templates.default;
|
3211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
3212
|
+
File,
|
3213
|
+
{
|
3214
|
+
baseName: file.baseName,
|
3215
|
+
path: file.path,
|
3216
|
+
meta: file.meta,
|
3217
|
+
children: [
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(File.Import, { name: ["Parse"], path: "@kubb/swagger-ts/infer", isTypeOnly: true }),
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(File.Source, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { Template: Template2, name, typeName }) })
|
3220
|
+
]
|
3221
|
+
}
|
3222
|
+
);
|
3223
|
+
};
|
3224
|
+
Oas.templates = defaultTemplates;
|
3225
|
+
|
3226
|
+
// src/components/Query.tsx
|
3227
|
+
init_esm_shims();
|
3228
|
+
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
3184
3229
|
function printCombinedSchema(name, operation, schemas) {
|
3185
3230
|
const properties = {
|
3186
3231
|
"response": factory2.createTypeReferenceNode(
|
@@ -3242,7 +3287,7 @@ function Query({
|
|
3242
3287
|
builder
|
3243
3288
|
}) {
|
3244
3289
|
const { source } = builder.build();
|
3245
|
-
return /* @__PURE__ */ (0,
|
3290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: source });
|
3246
3291
|
}
|
3247
3292
|
Query.File = function({ mode }) {
|
3248
3293
|
const { options } = usePlugin();
|
@@ -3254,7 +3299,7 @@ Query.File = function({ mode }) {
|
|
3254
3299
|
const operation = useOperation();
|
3255
3300
|
const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.errors);
|
3256
3301
|
const { source, imports } = builder.build();
|
3257
|
-
return /* @__PURE__ */ (0,
|
3302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
3258
3303
|
File,
|
3259
3304
|
{
|
3260
3305
|
baseName: file.baseName,
|
@@ -3262,9 +3307,9 @@ Query.File = function({ mode }) {
|
|
3262
3307
|
meta: file.meta,
|
3263
3308
|
children: [
|
3264
3309
|
mode === "directory" && imports.map((item, index) => {
|
3265
|
-
return /* @__PURE__ */ (0,
|
3310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(File.Import, { root: file.path, ...item }, index);
|
3266
3311
|
}),
|
3267
|
-
/* @__PURE__ */ (0,
|
3312
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(File.Source, { children: [
|
3268
3313
|
source,
|
3269
3314
|
printCombinedSchema(factoryName, operation, schemas)
|
3270
3315
|
] })
|
@@ -3274,16 +3319,25 @@ Query.File = function({ mode }) {
|
|
3274
3319
|
};
|
3275
3320
|
|
3276
3321
|
// src/OperationGenerator.tsx
|
3277
|
-
var
|
3322
|
+
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
3278
3323
|
var OperationGenerator = class extends OperationGenerator$1 {
|
3279
3324
|
async all() {
|
3280
|
-
|
3325
|
+
const { oas, pluginManager, plugin } = this.context;
|
3326
|
+
if (!plugin.options.oasType) {
|
3327
|
+
return null;
|
3328
|
+
}
|
3329
|
+
const root = createRoot({ logger: pluginManager.logger });
|
3330
|
+
root.render(
|
3331
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Oas.File, { name: "oas", typeName: "Oas" }),
|
3332
|
+
{ meta: { oas, pluginManager, plugin } }
|
3333
|
+
);
|
3334
|
+
return root.files;
|
3281
3335
|
}
|
3282
3336
|
async get(operation, schemas, options) {
|
3283
3337
|
const { oas, pluginManager, plugin, mode = "directory" } = this.context;
|
3284
3338
|
const root = createRoot({ logger: pluginManager.logger });
|
3285
3339
|
root.render(
|
3286
|
-
/* @__PURE__ */ (0,
|
3340
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Query.File, { mode }),
|
3287
3341
|
{ meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } }
|
3288
3342
|
);
|
3289
3343
|
return root.files;
|
@@ -3292,7 +3346,7 @@ var OperationGenerator = class extends OperationGenerator$1 {
|
|
3292
3346
|
const { oas, pluginManager, plugin, mode = "directory" } = this.context;
|
3293
3347
|
const root = createRoot({ logger: pluginManager.logger });
|
3294
3348
|
root.render(
|
3295
|
-
/* @__PURE__ */ (0,
|
3349
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Mutation.File, { mode }),
|
3296
3350
|
{ meta: { oas, pluginManager, plugin: { ...plugin, options }, schemas, operation } }
|
3297
3351
|
);
|
3298
3352
|
return root.files;
|
@@ -3313,7 +3367,7 @@ var pluginName = "swagger-ts";
|
|
3313
3367
|
var pluginKey = [pluginName];
|
3314
3368
|
createPlugin((options) => {
|
3315
3369
|
const {
|
3316
|
-
output = "types",
|
3370
|
+
output = { path: "types" },
|
3317
3371
|
group,
|
3318
3372
|
exclude = [],
|
3319
3373
|
include,
|
@@ -3322,9 +3376,9 @@ createPlugin((options) => {
|
|
3322
3376
|
dateType = "string",
|
3323
3377
|
optionalType = "questionToken",
|
3324
3378
|
transformers: transformers5 = {},
|
3325
|
-
|
3379
|
+
oasType = false
|
3326
3380
|
} = options;
|
3327
|
-
const template = group?.output ? group.output : `${output}/{{tag}}Controller`;
|
3381
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
3328
3382
|
return {
|
3329
3383
|
name: pluginName,
|
3330
3384
|
options: {
|
@@ -3332,21 +3386,22 @@ createPlugin((options) => {
|
|
3332
3386
|
dateType,
|
3333
3387
|
enumType,
|
3334
3388
|
optionalType,
|
3389
|
+
oasType,
|
3335
3390
|
// keep the used enumnames between TypeBuilder and OperationGenerator per plugin(pluginKey)
|
3336
3391
|
usedEnumNames: {}
|
3337
3392
|
},
|
3338
3393
|
pre: [pluginName$1],
|
3339
3394
|
resolvePath(baseName, directory, options2) {
|
3340
3395
|
const root = path.resolve(this.config.root, this.config.output.path);
|
3341
|
-
const mode = FileManager.getMode(path.resolve(root, output));
|
3396
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
3342
3397
|
if (mode === "file") {
|
3343
|
-
return path.resolve(root, output);
|
3398
|
+
return path.resolve(root, output.path);
|
3344
3399
|
}
|
3345
3400
|
if (options2?.tag && group?.type === "tag") {
|
3346
3401
|
const tag = camelCase(options2.tag);
|
3347
3402
|
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
3348
3403
|
}
|
3349
|
-
return path.resolve(root, output, baseName);
|
3404
|
+
return path.resolve(root, output.path, baseName);
|
3350
3405
|
},
|
3351
3406
|
resolveName(name, type) {
|
3352
3407
|
const resolvedName = pascalCase(name);
|
@@ -3366,7 +3421,7 @@ createPlugin((options) => {
|
|
3366
3421
|
const oas = await swaggerPlugin.api.getOas();
|
3367
3422
|
const schemas = await swaggerPlugin.api.getSchemas();
|
3368
3423
|
const root = path.resolve(this.config.root, this.config.output.path);
|
3369
|
-
const mode = FileManager.getMode(path.resolve(root, output));
|
3424
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
3370
3425
|
const builder = new TypeBuilder(this.plugin.options, { oas, pluginManager: this.pluginManager });
|
3371
3426
|
builder.add(
|
3372
3427
|
Object.entries(schemas).map(([name, schema]) => ({ name, schema }))
|
@@ -3400,7 +3455,7 @@ createPlugin((options) => {
|
|
3400
3455
|
}
|
3401
3456
|
await this.addFile({
|
3402
3457
|
path: resolvedPath,
|
3403
|
-
baseName: output,
|
3458
|
+
baseName: output.path,
|
3404
3459
|
source,
|
3405
3460
|
imports: [],
|
3406
3461
|
meta: {
|
@@ -3431,25 +3486,10 @@ createPlugin((options) => {
|
|
3431
3486
|
const root = path.resolve(this.config.root, this.config.output.path);
|
3432
3487
|
await this.fileManager.addIndexes({
|
3433
3488
|
root,
|
3489
|
+
output,
|
3434
3490
|
extName: ".ts",
|
3435
3491
|
meta: { pluginKey: this.plugin.key },
|
3436
3492
|
options: {
|
3437
|
-
map: (file) => {
|
3438
|
-
return {
|
3439
|
-
...file,
|
3440
|
-
exports: file.exports?.map((item) => {
|
3441
|
-
if (exportAs) {
|
3442
|
-
return {
|
3443
|
-
...item,
|
3444
|
-
name: exportAs,
|
3445
|
-
asAlias: !!exportAs
|
3446
|
-
};
|
3447
|
-
}
|
3448
|
-
return item;
|
3449
|
-
})
|
3450
|
-
};
|
3451
|
-
},
|
3452
|
-
output,
|
3453
3493
|
isTypeOnly: true
|
3454
3494
|
}
|
3455
3495
|
});
|
@@ -3783,7 +3823,7 @@ var TypeBuilder = class extends OasBuilder {
|
|
3783
3823
|
};
|
3784
3824
|
|
3785
3825
|
// src/components/Mutation.tsx
|
3786
|
-
var
|
3826
|
+
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
3787
3827
|
function printCombinedSchema2(name, operation, schemas) {
|
3788
3828
|
const properties = {
|
3789
3829
|
"response": factory2.createTypeReferenceNode(
|
@@ -3845,7 +3885,7 @@ function Mutation({
|
|
3845
3885
|
builder
|
3846
3886
|
}) {
|
3847
3887
|
const { source } = builder.build();
|
3848
|
-
return /* @__PURE__ */ (0,
|
3888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: source });
|
3849
3889
|
}
|
3850
3890
|
Mutation.File = function({ mode }) {
|
3851
3891
|
const { options } = usePlugin();
|
@@ -3857,7 +3897,7 @@ Mutation.File = function({ mode }) {
|
|
3857
3897
|
const operation = useOperation();
|
3858
3898
|
const builder = new TypeBuilder(options, { oas, pluginManager }).add(schemas.pathParams).add(schemas.queryParams).add(schemas.headerParams).add(schemas.response).add(schemas.request).add(schemas.errors);
|
3859
3899
|
const { source, imports } = builder.build();
|
3860
|
-
return /* @__PURE__ */ (0,
|
3900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
3861
3901
|
File,
|
3862
3902
|
{
|
3863
3903
|
baseName: file.baseName,
|
@@ -3865,9 +3905,9 @@ Mutation.File = function({ mode }) {
|
|
3865
3905
|
meta: file.meta,
|
3866
3906
|
children: [
|
3867
3907
|
mode === "directory" && imports.map((item, index) => {
|
3868
|
-
return /* @__PURE__ */ (0,
|
3908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(File.Import, { root: file.path, ...item }, index);
|
3869
3909
|
}),
|
3870
|
-
/* @__PURE__ */ (0,
|
3910
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(File.Source, { children: [
|
3871
3911
|
source,
|
3872
3912
|
printCombinedSchema2(factoryName, operation, schemas)
|
3873
3913
|
] })
|
@@ -3922,6 +3962,6 @@ react/cjs/react-jsx-runtime.development.js:
|
|
3922
3962
|
*)
|
3923
3963
|
*/
|
3924
3964
|
|
3925
|
-
export { Mutation, Query };
|
3965
|
+
export { Mutation, Oas, Query };
|
3926
3966
|
//# sourceMappingURL=out.js.map
|
3927
3967
|
//# sourceMappingURL=components.js.map
|