@kubb/swagger-ts 2.0.0-beta.6 → 2.0.0-beta.8
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 -43
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +66 -17
- package/dist/components.d.ts +66 -17
- package/dist/components.js +85 -46
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +82 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +414 -12
- package/dist/index.d.ts +414 -12
- package/dist/index.js +83 -40
- 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 -25
- package/src/types.ts +26 -11
package/dist/components.d.cts
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
|
2
|
-
import { PluginFactoryOptions,
|
1
|
+
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder, OasTypes } from '@kubb/swagger';
|
2
|
+
import { PluginFactoryOptions, KubbFile, ResolveNameParams } 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
|
+
/**
|
18
|
+
* Add an extension to the generated imports and exports, default it will not use an extension
|
19
|
+
*/
|
20
|
+
extName?: KubbFile.Extname;
|
21
|
+
};
|
12
22
|
/**
|
13
23
|
* Group the TypeScript types based on the provided name.
|
14
24
|
*/
|
@@ -26,10 +36,6 @@ type Options = {
|
|
26
36
|
*/
|
27
37
|
output?: string;
|
28
38
|
};
|
29
|
-
/**
|
30
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
31
|
-
*/
|
32
|
-
exportAs?: string;
|
33
39
|
/**
|
34
40
|
* Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
|
35
41
|
*/
|
@@ -66,12 +72,19 @@ type Options = {
|
|
66
72
|
*/
|
67
73
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
68
74
|
};
|
75
|
+
/**
|
76
|
+
* Export Oas object as Oas type with import type { Infer } from `@kubb/swagger-ts/infer`
|
77
|
+
* TODO add docs
|
78
|
+
* @beta
|
79
|
+
*/
|
80
|
+
oasType?: boolean;
|
69
81
|
};
|
70
82
|
type ResolvedOptions = {
|
71
83
|
enumType: NonNullable<Options['enumType']>;
|
72
84
|
dateType: NonNullable<Options['dateType']>;
|
73
85
|
optionalType: NonNullable<Options['optionalType']>;
|
74
86
|
transformers: NonNullable<Options['transformers']>;
|
87
|
+
oasType: NonNullable<Options['oasType']>;
|
75
88
|
usedEnumNames: Record<string, number>;
|
76
89
|
};
|
77
90
|
type AppMeta = AppMeta$1;
|
@@ -86,17 +99,53 @@ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
|
|
86
99
|
build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
|
87
100
|
}
|
88
101
|
|
89
|
-
type Props$
|
102
|
+
type Props$2 = {
|
90
103
|
builder: TypeBuilder;
|
91
104
|
};
|
92
|
-
declare function Mutation({ builder, }: Props$
|
105
|
+
declare function Mutation({ builder, }: Props$2): ReactNode;
|
93
106
|
declare namespace Mutation {
|
94
|
-
var File: ({ mode }: FileProps$
|
107
|
+
var File: ({ mode }: FileProps$2) => ReactNode;
|
95
108
|
}
|
96
|
-
type FileProps$
|
109
|
+
type FileProps$2 = {
|
97
110
|
mode: KubbFile.Mode;
|
98
111
|
};
|
99
112
|
|
113
|
+
type TemplateProps = {
|
114
|
+
/**
|
115
|
+
* Name of the function
|
116
|
+
*/
|
117
|
+
name: string;
|
118
|
+
typeName: string;
|
119
|
+
api: OasTypes.OASDocument;
|
120
|
+
};
|
121
|
+
declare function Template({ name, typeName, api, }: TemplateProps): ReactNode;
|
122
|
+
declare const defaultTemplates: {
|
123
|
+
readonly default: typeof Template;
|
124
|
+
};
|
125
|
+
type Props$1 = {
|
126
|
+
name: string;
|
127
|
+
typeName: string;
|
128
|
+
/**
|
129
|
+
* This will make it possible to override the default behaviour.
|
130
|
+
*/
|
131
|
+
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
132
|
+
};
|
133
|
+
declare function Oas({ name, typeName, Template, }: Props$1): ReactNode;
|
134
|
+
declare namespace Oas {
|
135
|
+
var File: ({ name, typeName, templates }: FileProps$1) => ReactNode;
|
136
|
+
var templates: {
|
137
|
+
readonly default: typeof Template;
|
138
|
+
};
|
139
|
+
}
|
140
|
+
type FileProps$1 = {
|
141
|
+
name: string;
|
142
|
+
typeName: string;
|
143
|
+
/**
|
144
|
+
* This will make it possible to override the default behaviour.
|
145
|
+
*/
|
146
|
+
templates?: typeof defaultTemplates;
|
147
|
+
};
|
148
|
+
|
100
149
|
type Props = {
|
101
150
|
builder: TypeBuilder;
|
102
151
|
};
|
@@ -108,4 +157,4 @@ type FileProps = {
|
|
108
157
|
mode: KubbFile.Mode;
|
109
158
|
};
|
110
159
|
|
111
|
-
export { Mutation, Query };
|
160
|
+
export { Mutation, Oas, Query };
|
package/dist/components.d.ts
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder } from '@kubb/swagger';
|
2
|
-
import { PluginFactoryOptions,
|
1
|
+
import { ResolvePathOptions, Exclude, Include, Override, AppMeta as AppMeta$1, OasBuilder, OasTypes } from '@kubb/swagger';
|
2
|
+
import { PluginFactoryOptions, KubbFile, ResolveNameParams } 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
|
+
/**
|
18
|
+
* Add an extension to the generated imports and exports, default it will not use an extension
|
19
|
+
*/
|
20
|
+
extName?: KubbFile.Extname;
|
21
|
+
};
|
12
22
|
/**
|
13
23
|
* Group the TypeScript types based on the provided name.
|
14
24
|
*/
|
@@ -26,10 +36,6 @@ type Options = {
|
|
26
36
|
*/
|
27
37
|
output?: string;
|
28
38
|
};
|
29
|
-
/**
|
30
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
31
|
-
*/
|
32
|
-
exportAs?: string;
|
33
39
|
/**
|
34
40
|
* Array containing exclude paramaters to exclude/skip tags/operations/methods/paths.
|
35
41
|
*/
|
@@ -66,12 +72,19 @@ type Options = {
|
|
66
72
|
*/
|
67
73
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
68
74
|
};
|
75
|
+
/**
|
76
|
+
* Export Oas object as Oas type with import type { Infer } from `@kubb/swagger-ts/infer`
|
77
|
+
* TODO add docs
|
78
|
+
* @beta
|
79
|
+
*/
|
80
|
+
oasType?: boolean;
|
69
81
|
};
|
70
82
|
type ResolvedOptions = {
|
71
83
|
enumType: NonNullable<Options['enumType']>;
|
72
84
|
dateType: NonNullable<Options['dateType']>;
|
73
85
|
optionalType: NonNullable<Options['optionalType']>;
|
74
86
|
transformers: NonNullable<Options['transformers']>;
|
87
|
+
oasType: NonNullable<Options['oasType']>;
|
75
88
|
usedEnumNames: Record<string, number>;
|
76
89
|
};
|
77
90
|
type AppMeta = AppMeta$1;
|
@@ -86,17 +99,53 @@ declare class TypeBuilder extends OasBuilder<PluginOptions['resolvedOptions']> {
|
|
86
99
|
build(name?: string): Required<Pick<KubbFile.File, 'imports' | 'source'>>;
|
87
100
|
}
|
88
101
|
|
89
|
-
type Props$
|
102
|
+
type Props$2 = {
|
90
103
|
builder: TypeBuilder;
|
91
104
|
};
|
92
|
-
declare function Mutation({ builder, }: Props$
|
105
|
+
declare function Mutation({ builder, }: Props$2): ReactNode;
|
93
106
|
declare namespace Mutation {
|
94
|
-
var File: ({ mode }: FileProps$
|
107
|
+
var File: ({ mode }: FileProps$2) => ReactNode;
|
95
108
|
}
|
96
|
-
type FileProps$
|
109
|
+
type FileProps$2 = {
|
97
110
|
mode: KubbFile.Mode;
|
98
111
|
};
|
99
112
|
|
113
|
+
type TemplateProps = {
|
114
|
+
/**
|
115
|
+
* Name of the function
|
116
|
+
*/
|
117
|
+
name: string;
|
118
|
+
typeName: string;
|
119
|
+
api: OasTypes.OASDocument;
|
120
|
+
};
|
121
|
+
declare function Template({ name, typeName, api, }: TemplateProps): ReactNode;
|
122
|
+
declare const defaultTemplates: {
|
123
|
+
readonly default: typeof Template;
|
124
|
+
};
|
125
|
+
type Props$1 = {
|
126
|
+
name: string;
|
127
|
+
typeName: string;
|
128
|
+
/**
|
129
|
+
* This will make it possible to override the default behaviour.
|
130
|
+
*/
|
131
|
+
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
132
|
+
};
|
133
|
+
declare function Oas({ name, typeName, Template, }: Props$1): ReactNode;
|
134
|
+
declare namespace Oas {
|
135
|
+
var File: ({ name, typeName, templates }: FileProps$1) => ReactNode;
|
136
|
+
var templates: {
|
137
|
+
readonly default: typeof Template;
|
138
|
+
};
|
139
|
+
}
|
140
|
+
type FileProps$1 = {
|
141
|
+
name: string;
|
142
|
+
typeName: string;
|
143
|
+
/**
|
144
|
+
* This will make it possible to override the default behaviour.
|
145
|
+
*/
|
146
|
+
templates?: typeof defaultTemplates;
|
147
|
+
};
|
148
|
+
|
100
149
|
type Props = {
|
101
150
|
builder: TypeBuilder;
|
102
151
|
};
|
@@ -108,4 +157,4 @@ type FileProps = {
|
|
108
157
|
mode: KubbFile.Mode;
|
109
158
|
};
|
110
159
|
|
111
|
-
export { Mutation, Query };
|
160
|
+
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,9 @@ createPlugin((options) => {
|
|
3431
3486
|
const root = path.resolve(this.config.root, this.config.output.path);
|
3432
3487
|
await this.fileManager.addIndexes({
|
3433
3488
|
root,
|
3434
|
-
|
3489
|
+
output,
|
3435
3490
|
meta: { pluginKey: this.plugin.key },
|
3436
3491
|
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
3492
|
isTypeOnly: true
|
3454
3493
|
}
|
3455
3494
|
});
|
@@ -3783,7 +3822,7 @@ var TypeBuilder = class extends OasBuilder {
|
|
3783
3822
|
};
|
3784
3823
|
|
3785
3824
|
// src/components/Mutation.tsx
|
3786
|
-
var
|
3825
|
+
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
3787
3826
|
function printCombinedSchema2(name, operation, schemas) {
|
3788
3827
|
const properties = {
|
3789
3828
|
"response": factory2.createTypeReferenceNode(
|
@@ -3845,7 +3884,7 @@ function Mutation({
|
|
3845
3884
|
builder
|
3846
3885
|
}) {
|
3847
3886
|
const { source } = builder.build();
|
3848
|
-
return /* @__PURE__ */ (0,
|
3887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: source });
|
3849
3888
|
}
|
3850
3889
|
Mutation.File = function({ mode }) {
|
3851
3890
|
const { options } = usePlugin();
|
@@ -3857,7 +3896,7 @@ Mutation.File = function({ mode }) {
|
|
3857
3896
|
const operation = useOperation();
|
3858
3897
|
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
3898
|
const { source, imports } = builder.build();
|
3860
|
-
return /* @__PURE__ */ (0,
|
3899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
3861
3900
|
File,
|
3862
3901
|
{
|
3863
3902
|
baseName: file.baseName,
|
@@ -3865,9 +3904,9 @@ Mutation.File = function({ mode }) {
|
|
3865
3904
|
meta: file.meta,
|
3866
3905
|
children: [
|
3867
3906
|
mode === "directory" && imports.map((item, index) => {
|
3868
|
-
return /* @__PURE__ */ (0,
|
3907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(File.Import, { root: file.path, ...item }, index);
|
3869
3908
|
}),
|
3870
|
-
/* @__PURE__ */ (0,
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(File.Source, { children: [
|
3871
3910
|
source,
|
3872
3911
|
printCombinedSchema2(factoryName, operation, schemas)
|
3873
3912
|
] })
|
@@ -3922,6 +3961,6 @@ react/cjs/react-jsx-runtime.development.js:
|
|
3922
3961
|
*)
|
3923
3962
|
*/
|
3924
3963
|
|
3925
|
-
export { Mutation, Query };
|
3964
|
+
export { Mutation, Oas, Query };
|
3926
3965
|
//# sourceMappingURL=out.js.map
|
3927
3966
|
//# sourceMappingURL=components.js.map
|