@kubb/plugin-oas 4.4.0 → 4.5.0
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/{SchemaGenerator-7wBwdv8G.js → SchemaGenerator-BwYbrh7a.js} +93 -36
- package/dist/SchemaGenerator-BwYbrh7a.js.map +1 -0
- package/dist/{SchemaGenerator-DzVHk6OP.cjs → SchemaGenerator-C81yEgKY.cjs} +114 -37
- package/dist/SchemaGenerator-C81yEgKY.cjs.map +1 -0
- package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
- package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
- package/dist/{SchemaMapper-CqBW0VOy.d.ts → SchemaMapper-CgGWx6jF.d.cts} +15 -116
- package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-Cj3vjPGs.d.ts} +15 -116
- package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
- package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
- package/dist/{OperationGenerator-BZPWkxw4.d.ts → createGenerator-BvCDyuKS.d.ts} +128 -191
- package/dist/{OperationGenerator-CJTAer7l.d.cts → createGenerator-CPNglV1d.d.cts} +129 -192
- package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
- package/dist/generators-CJDEf8Kn.js.map +1 -0
- package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
- package/dist/generators-udGOxdUV.cjs.map +1 -0
- package/dist/generators.cjs +2 -7
- package/dist/generators.d.cts +8 -3
- package/dist/generators.d.ts +8 -3
- package/dist/generators.js +3 -5
- package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
- package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
- package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
- package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
- package/dist/getSchemas-32BHoMO-.js +100 -0
- package/dist/getSchemas-32BHoMO-.js.map +1 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs +113 -0
- package/dist/getSchemas-Cl0TZ4XY.cjs.map +1 -0
- package/dist/hooks.cjs +6 -47
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +11 -45
- package/dist/hooks.d.ts +11 -45
- package/dist/hooks.js +8 -46
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -3
- package/dist/index.d.ts +58 -3
- package/dist/index.js +32 -24
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
- package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
- package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
- package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +28 -24
- package/dist/utils.d.ts +28 -24
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +14 -17
- package/src/OperationGenerator.ts +27 -14
- package/src/SchemaGenerator.ts +25 -47
- package/src/SchemaMapper.ts +3 -1
- package/src/generators/createGenerator.ts +1 -1
- package/src/generators/index.ts +0 -1
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/generators/types.ts +13 -14
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useOas.ts +5 -11
- package/src/hooks/useOperationManager.ts +3 -5
- package/src/hooks/useSchemaManager.ts +1 -1
- package/src/index.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/getBanner.ts +1 -1
- package/src/utils/getParams.ts +1 -2
- package/src/utils/getSchemaFactory.ts +1 -2
- package/src/utils/getSchemas.ts +89 -15
- package/src/utils/index.ts +3 -4
- package/src/utils/parseFromConfig.ts +2 -6
- package/src/utils.tsx +101 -0
- package/dist/Oas-BzrQ6RGC.cjs +0 -80
- package/dist/Oas-BzrQ6RGC.cjs.map +0 -1
- package/dist/Oas-CIeHKOo0.js +0 -60
- package/dist/Oas-CIeHKOo0.js.map +0 -1
- package/dist/Schema-CjraJhJi.d.ts +0 -38
- package/dist/Schema-zcZF0UIp.d.cts +0 -38
- package/dist/SchemaGenerator-7wBwdv8G.js.map +0 -1
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +0 -1
- package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
- package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
- package/dist/components.cjs +0 -5
- package/dist/components.d.cts +0 -42
- package/dist/components.d.ts +0 -42
- package/dist/components.js +0 -3
- package/dist/generators-B27La9Vd.cjs.map +0 -1
- package/dist/generators-C61FxVIj.js.map +0 -1
- package/dist/getSchemas-Bdg6n9Qk.js +0 -55
- package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
- package/dist/getSchemas-DY8s2CSl.cjs +0 -68
- package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
- package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
- package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
- package/dist/utils-BnkB1ikY.js +0 -99
- package/dist/utils-BnkB1ikY.js.map +0 -1
- package/dist/utils-nzdccPlU.cjs +0 -119
- package/dist/utils-nzdccPlU.cjs.map +0 -1
- package/src/components/Oas.tsx +0 -35
- package/src/components/Operation.tsx +0 -20
- package/src/components/Schema.tsx +0 -38
- package/src/components/index.ts +0 -3
- package/src/generators/utils.tsx +0 -114
- package/src/hooks/useOperation.ts +0 -18
- package/src/hooks/useOperations.ts +0 -40
- package/src/hooks/useSchema.ts +0 -16
|
@@ -1,49 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as contentType, i as SchemaKeywordMapper, l as HttpMethod, m as SchemaObject$1, p as Operation$1, t as Schema, u as OasTypes } from "./SchemaMapper-Cj3vjPGs.js";
|
|
2
2
|
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
|
+
import { ConsolaInstance, LogLevel } from "consola";
|
|
5
|
+
import { OASDocument, SchemaObject, User } from "oas/types";
|
|
6
|
+
import { Operation } from "oas/operation";
|
|
7
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
7
8
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
8
9
|
import BaseOas from "oas";
|
|
9
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
10
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
11
11
|
|
|
12
|
-
//#region ../oas/src/types.d.ts
|
|
13
|
-
type contentType = 'application/json' | (string & {});
|
|
14
|
-
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
15
|
-
'x-nullable'?: boolean;
|
|
16
|
-
$ref?: string;
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region ../oas/src/Oas.d.ts
|
|
20
|
-
type Options$3 = {
|
|
21
|
-
contentType?: contentType;
|
|
22
|
-
discriminator?: 'strict' | 'inherit';
|
|
23
|
-
};
|
|
24
|
-
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
25
|
-
#private;
|
|
26
|
-
document: TOAS;
|
|
27
|
-
constructor({
|
|
28
|
-
oas,
|
|
29
|
-
user
|
|
30
|
-
}: {
|
|
31
|
-
oas: TOAS | OASDocument | string;
|
|
32
|
-
user?: User;
|
|
33
|
-
});
|
|
34
|
-
setOptions(options: Options$3): void;
|
|
35
|
-
get options(): Options$3;
|
|
36
|
-
get($ref: string): any;
|
|
37
|
-
getKey($ref: string): string | undefined;
|
|
38
|
-
set($ref: string, value: unknown): false | undefined;
|
|
39
|
-
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
40
|
-
dereferenceWithRef(schema?: unknown): any;
|
|
41
|
-
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
42
|
-
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
43
|
-
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
44
|
-
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
12
|
//#region ../core/src/BaseGenerator.d.ts
|
|
48
13
|
/**
|
|
49
14
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
@@ -181,7 +146,7 @@ type Config<TInput = Input> = {
|
|
|
181
146
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
182
147
|
* @default { '.ts': '.ts'}
|
|
183
148
|
*/
|
|
184
|
-
extension?: Record<Extname, Extname | ''>;
|
|
149
|
+
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
185
150
|
/**
|
|
186
151
|
* Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
|
|
187
152
|
* @default 'named'
|
|
@@ -312,7 +277,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
312
277
|
* @type hookFirst
|
|
313
278
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
314
279
|
*/
|
|
315
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
280
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
|
316
281
|
/**
|
|
317
282
|
* Resolve to a name based on a string.
|
|
318
283
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -330,8 +295,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
330
295
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
331
296
|
type ResolvePathParams<TOptions = object> = {
|
|
332
297
|
pluginKey?: Plugin['key'];
|
|
333
|
-
baseName: BaseName;
|
|
334
|
-
mode?: Mode;
|
|
298
|
+
baseName: KubbFile.BaseName;
|
|
299
|
+
mode?: KubbFile.Mode;
|
|
335
300
|
/**
|
|
336
301
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
337
302
|
*/
|
|
@@ -356,8 +321,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
356
321
|
*/
|
|
357
322
|
fileManager: FileManager;
|
|
358
323
|
pluginManager: PluginManager;
|
|
359
|
-
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
360
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
324
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
|
|
325
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
361
326
|
resolveName: (params: ResolveNameParams) => string;
|
|
362
327
|
logger: Logger;
|
|
363
328
|
/**
|
|
@@ -421,7 +386,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
421
386
|
result: Result;
|
|
422
387
|
plugin: Plugin;
|
|
423
388
|
};
|
|
424
|
-
type Options$
|
|
389
|
+
type Options$3 = {
|
|
425
390
|
fabric: Fabric;
|
|
426
391
|
logger: Logger;
|
|
427
392
|
/**
|
|
@@ -436,8 +401,8 @@ type Events = {
|
|
|
436
401
|
};
|
|
437
402
|
type GetFileProps<TOptions = object> = {
|
|
438
403
|
name: string;
|
|
439
|
-
mode?: Mode;
|
|
440
|
-
extname: Extname;
|
|
404
|
+
mode?: KubbFile.Mode;
|
|
405
|
+
extname: KubbFile.Extname;
|
|
441
406
|
pluginKey: Plugin['key'];
|
|
442
407
|
options?: TOptions;
|
|
443
408
|
};
|
|
@@ -448,18 +413,18 @@ declare class PluginManager {
|
|
|
448
413
|
readonly config: Config;
|
|
449
414
|
readonly executed: Array<Executer>;
|
|
450
415
|
readonly logger: Logger;
|
|
451
|
-
readonly options: Options$
|
|
452
|
-
constructor(config: Config, options: Options$
|
|
416
|
+
readonly options: Options$3;
|
|
417
|
+
constructor(config: Config, options: Options$3);
|
|
453
418
|
getFile<TOptions = object>({
|
|
454
419
|
name,
|
|
455
420
|
mode,
|
|
456
421
|
extname,
|
|
457
422
|
pluginKey,
|
|
458
423
|
options
|
|
459
|
-
}: GetFileProps<TOptions>): File<{
|
|
424
|
+
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
460
425
|
pluginKey: Plugin['key'];
|
|
461
426
|
}>;
|
|
462
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
427
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
463
428
|
resolveName: (params: ResolveNameParams) => string;
|
|
464
429
|
/**
|
|
465
430
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -556,44 +521,33 @@ type FileMetaBase = {
|
|
|
556
521
|
pluginKey?: Plugin['key'];
|
|
557
522
|
};
|
|
558
523
|
//#endregion
|
|
559
|
-
//#region src/
|
|
560
|
-
type
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
operation?: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
564
|
-
schema?: (props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
565
|
-
};
|
|
566
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
567
|
-
name: string;
|
|
568
|
-
type: 'core';
|
|
569
|
-
operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
570
|
-
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
571
|
-
schema: (props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
572
|
-
};
|
|
573
|
-
declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): CoreGenerator<TOptions>;
|
|
574
|
-
//#endregion
|
|
575
|
-
//#region src/generators/createReactGenerator.d.ts
|
|
576
|
-
type UserGenerator<TOptions extends PluginFactoryOptions> = {
|
|
577
|
-
name: string;
|
|
578
|
-
Operations?: (props: OperationsProps<TOptions>) => KubbNode;
|
|
579
|
-
Operation?: (props: OperationProps<TOptions>) => KubbNode;
|
|
580
|
-
Schema?: (props: SchemaProps<TOptions>) => KubbNode;
|
|
581
|
-
};
|
|
582
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
583
|
-
name: string;
|
|
584
|
-
type: 'react';
|
|
585
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
586
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
587
|
-
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
524
|
+
//#region ../oas/src/Oas.d.ts
|
|
525
|
+
type Options$2 = {
|
|
526
|
+
contentType?: contentType;
|
|
527
|
+
discriminator?: 'strict' | 'inherit';
|
|
588
528
|
};
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
529
|
+
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
530
|
+
#private;
|
|
531
|
+
document: TOAS;
|
|
532
|
+
constructor({
|
|
533
|
+
oas,
|
|
534
|
+
user
|
|
535
|
+
}: {
|
|
536
|
+
oas: TOAS | OASDocument | string;
|
|
537
|
+
user?: User;
|
|
538
|
+
});
|
|
539
|
+
setOptions(options: Options$2): void;
|
|
540
|
+
get options(): Options$2;
|
|
541
|
+
get($ref: string): any;
|
|
542
|
+
getKey($ref: string): string | undefined;
|
|
543
|
+
set($ref: string, value: unknown): false | undefined;
|
|
544
|
+
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
545
|
+
dereferenceWithRef(schema?: unknown): any;
|
|
546
|
+
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
547
|
+
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
548
|
+
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
549
|
+
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
550
|
+
}
|
|
597
551
|
//#endregion
|
|
598
552
|
//#region src/types.d.ts
|
|
599
553
|
type ResolvePathOptions = {
|
|
@@ -668,7 +622,7 @@ type Options$1 = {
|
|
|
668
622
|
type Ref = {
|
|
669
623
|
propertyName: string;
|
|
670
624
|
originalName: string;
|
|
671
|
-
path: OptionalPath;
|
|
625
|
+
path: KubbFile.OptionalPath;
|
|
672
626
|
pluginKey?: Plugin['key'];
|
|
673
627
|
};
|
|
674
628
|
type Refs = Record<string, Ref>;
|
|
@@ -677,8 +631,8 @@ type Resolver = {
|
|
|
677
631
|
* Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
|
|
678
632
|
*/
|
|
679
633
|
name: string;
|
|
680
|
-
baseName: BaseName;
|
|
681
|
-
path: Path;
|
|
634
|
+
baseName: KubbFile.BaseName;
|
|
635
|
+
path: KubbFile.Path;
|
|
682
636
|
};
|
|
683
637
|
type OperationSchema = {
|
|
684
638
|
/**
|
|
@@ -747,13 +701,41 @@ type ResolvedOptions = Options$1 & {
|
|
|
747
701
|
};
|
|
748
702
|
type PluginOas = PluginFactoryOptions<'plugin-oas', Options$1, ResolvedOptions, API, ResolvePathOptions>;
|
|
749
703
|
//#endregion
|
|
750
|
-
//#region src/
|
|
751
|
-
|
|
704
|
+
//#region src/OperationGenerator.d.ts
|
|
705
|
+
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
706
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
707
|
+
fabric: Fabric;
|
|
708
|
+
oas: Oas;
|
|
709
|
+
exclude: Array<Exclude$1> | undefined;
|
|
710
|
+
include: Array<Include> | undefined;
|
|
711
|
+
override: Array<Override<TOptions>> | undefined;
|
|
712
|
+
contentType: contentType | undefined;
|
|
713
|
+
pluginManager: PluginManager;
|
|
714
|
+
/**
|
|
715
|
+
* Current plugin
|
|
716
|
+
*/
|
|
717
|
+
plugin: Plugin<TPluginOptions>;
|
|
718
|
+
mode: KubbFile.Mode;
|
|
719
|
+
};
|
|
720
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
721
|
+
#private;
|
|
722
|
+
getSchemas(operation: Operation$1, {
|
|
723
|
+
resolveName
|
|
724
|
+
}?: {
|
|
725
|
+
resolveName?: (name: string) => string;
|
|
726
|
+
}): OperationSchemas;
|
|
727
|
+
getOperations(): Promise<Array<{
|
|
728
|
+
path: string;
|
|
729
|
+
method: HttpMethod;
|
|
730
|
+
operation: Operation$1;
|
|
731
|
+
}>>;
|
|
732
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
733
|
+
}
|
|
752
734
|
//#endregion
|
|
753
735
|
//#region src/SchemaGenerator.d.ts
|
|
754
736
|
type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
|
|
755
|
-
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<File<TFileMeta> | Array<File<TFileMeta>> | null>;
|
|
756
|
-
type Context
|
|
737
|
+
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
738
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
757
739
|
fabric: Fabric;
|
|
758
740
|
oas: Oas;
|
|
759
741
|
pluginManager: PluginManager;
|
|
@@ -761,7 +743,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
761
743
|
* Current plugin
|
|
762
744
|
*/
|
|
763
745
|
plugin: Plugin<TPluginOptions>;
|
|
764
|
-
mode: Mode;
|
|
746
|
+
mode: KubbFile.Mode;
|
|
765
747
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
766
748
|
override: Array<Override<TOptions>> | undefined;
|
|
767
749
|
contentType?: contentType;
|
|
@@ -795,7 +777,7 @@ type SchemaProps$1 = {
|
|
|
795
777
|
name?: string;
|
|
796
778
|
parentName?: string;
|
|
797
779
|
};
|
|
798
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context
|
|
780
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
799
781
|
#private;
|
|
800
782
|
refs: Refs;
|
|
801
783
|
/**
|
|
@@ -804,82 +786,52 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
804
786
|
* optionally adds a union with null.
|
|
805
787
|
*/
|
|
806
788
|
parse(props: SchemaProps$1): Schema[];
|
|
807
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
808
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
809
789
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
810
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
811
790
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
812
791
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
813
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
792
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
814
793
|
}
|
|
815
794
|
//#endregion
|
|
816
|
-
//#region src/generators/
|
|
817
|
-
type
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
*/
|
|
823
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
824
|
-
options: TOptions['resolvedOptions'];
|
|
825
|
-
};
|
|
826
|
-
declare function buildOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation$1>, {
|
|
827
|
-
fabric,
|
|
828
|
-
options,
|
|
829
|
-
instance,
|
|
830
|
-
generator
|
|
831
|
-
}: BuildOperationsOptions<TOptions>): Promise<void>;
|
|
832
|
-
type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>;
|
|
833
|
-
declare function buildOperation<TOptions extends PluginFactoryOptions>(operation: Operation$1, {
|
|
834
|
-
fabric,
|
|
835
|
-
options,
|
|
836
|
-
instance,
|
|
837
|
-
generator
|
|
838
|
-
}: BuildOperationOptions<TOptions>): Promise<void>;
|
|
839
|
-
type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
|
|
840
|
-
fabric: Fabric;
|
|
841
|
-
generator: ReactGenerator<any>;
|
|
842
|
-
/**
|
|
843
|
-
* @deprecated
|
|
844
|
-
*/
|
|
845
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
846
|
-
options: TOptions['resolvedOptions'];
|
|
795
|
+
//#region src/generators/createReactGenerator.d.ts
|
|
796
|
+
type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
|
|
797
|
+
name: string;
|
|
798
|
+
Operations?: (props: OperationsProps<TOptions>) => KubbNode;
|
|
799
|
+
Operation?: (props: OperationProps<TOptions>) => KubbNode;
|
|
800
|
+
Schema?: (props: SchemaProps<TOptions>) => KubbNode;
|
|
847
801
|
};
|
|
848
|
-
|
|
802
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
849
803
|
name: string;
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
804
|
+
type: 'react';
|
|
805
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
806
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
807
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
808
|
+
};
|
|
809
|
+
/****
|
|
810
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
811
|
+
*
|
|
812
|
+
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
813
|
+
*
|
|
814
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
815
|
+
*/
|
|
816
|
+
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): ReactGenerator<TOptions>;
|
|
862
817
|
//#endregion
|
|
863
818
|
//#region src/generators/types.d.ts
|
|
864
819
|
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
869
|
-
options: TOptions['resolvedOptions'];
|
|
820
|
+
config: Config;
|
|
821
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
822
|
+
plugin: Plugin<TOptions>;
|
|
870
823
|
operations: Array<Operation$1>;
|
|
871
824
|
};
|
|
872
825
|
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
877
|
-
options: TOptions['resolvedOptions'];
|
|
826
|
+
config: Config;
|
|
827
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
828
|
+
plugin: Plugin<TOptions>;
|
|
878
829
|
operation: Operation$1;
|
|
879
830
|
};
|
|
880
831
|
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
881
|
-
|
|
882
|
-
|
|
832
|
+
config: Config;
|
|
833
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
834
|
+
plugin: Plugin<TOptions>;
|
|
883
835
|
schema: {
|
|
884
836
|
name: string;
|
|
885
837
|
tree: Array<Schema>;
|
|
@@ -888,36 +840,21 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
|
888
840
|
};
|
|
889
841
|
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
890
842
|
//#endregion
|
|
891
|
-
//#region src/
|
|
892
|
-
type
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
include: Array<Include> | undefined;
|
|
898
|
-
override: Array<Override<TOptions>> | undefined;
|
|
899
|
-
contentType: contentType | undefined;
|
|
900
|
-
pluginManager: PluginManager;
|
|
901
|
-
/**
|
|
902
|
-
* Current plugin
|
|
903
|
-
*/
|
|
904
|
-
plugin: Plugin<TPluginOptions>;
|
|
905
|
-
mode: Mode;
|
|
843
|
+
//#region src/generators/createGenerator.d.ts
|
|
844
|
+
type UserGenerator<TOptions extends PluginFactoryOptions> = {
|
|
845
|
+
name: string;
|
|
846
|
+
operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
847
|
+
operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
848
|
+
schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
906
849
|
};
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
path: string;
|
|
916
|
-
method: HttpMethod;
|
|
917
|
-
operation: Operation$1;
|
|
918
|
-
}>>;
|
|
919
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
920
|
-
}
|
|
850
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
851
|
+
name: string;
|
|
852
|
+
type: 'core';
|
|
853
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
854
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
855
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
856
|
+
};
|
|
857
|
+
declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
|
|
921
858
|
//#endregion
|
|
922
|
-
export {
|
|
923
|
-
//# sourceMappingURL=
|
|
859
|
+
export { PluginFactoryOptions as A, ResolvePathOptions as C, Config as D, FileMetaBase as E, UserPluginWithLifeCycle as M, Output as O, Refs as S, Oas as T, OperationSchemas as _, createReactGenerator as a, PluginOas as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchema as g, Include as h, ReactGenerator as i, ResolveNameParams as j, Plugin as k, SchemaGeneratorOptions as l, Exclude$1 as m, createGenerator as n, GetSchemaGeneratorOptions as o, API as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Options$1 as v, Resolver as w, Ref as x, Override as y };
|
|
860
|
+
//# sourceMappingURL=createGenerator-BvCDyuKS.d.ts.map
|