@kubb/plugin-oas 4.5.1 → 4.5.3
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-BwYbrh7a.js → SchemaGenerator-BAE9VJgN.js} +6 -6
- package/dist/SchemaGenerator-BAE9VJgN.js.map +1 -0
- package/dist/{SchemaGenerator-C81yEgKY.cjs → SchemaGenerator-JB63cfsY.cjs} +7 -7
- package/dist/SchemaGenerator-JB63cfsY.cjs.map +1 -0
- package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -1
- package/dist/{createGenerator-BvCDyuKS.d.ts → SchemaMapper-BtvCVaPJ.d.ts} +327 -345
- package/dist/SchemaMapper-D30tqRoX.js.map +1 -1
- package/dist/{createGenerator-CPNglV1d.d.cts → SchemaMapper-DhH_z_t3.d.cts} +327 -345
- package/dist/createGenerator-CZv5P-nq.d.ts +319 -0
- package/dist/createGenerator-Dd3Q2BgZ.d.cts +319 -0
- package/dist/{generators-udGOxdUV.cjs → generators-DTxTiYOL.cjs} +1 -1
- package/dist/{generators-udGOxdUV.cjs.map → generators-DTxTiYOL.cjs.map} +1 -1
- package/dist/{generators-CJDEf8Kn.js → generators-v153n8vw.js} +1 -1
- package/dist/{generators-CJDEf8Kn.js.map → generators-v153n8vw.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +3 -3
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +34 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +33 -27
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/utils.cjs +2 -4
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -14
- package/dist/utils.d.ts +5 -14
- package/dist/utils.js +2 -3
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/SchemaGenerator.ts +1 -1
- package/src/SchemaMapper.ts +1 -1
- package/src/hooks/useOperationManager.ts +4 -2
- package/src/index.ts +20 -0
- package/src/plugin.ts +19 -19
- package/src/types.ts +13 -7
- package/src/utils/index.ts +0 -1
- package/src/utils.tsx +3 -3
- package/dist/SchemaGenerator-BwYbrh7a.js.map +0 -1
- package/dist/SchemaGenerator-C81yEgKY.cjs.map +0 -1
- package/dist/SchemaMapper-CgGWx6jF.d.cts +0 -297
- package/dist/SchemaMapper-Cj3vjPGs.d.ts +0 -297
- package/dist/parseFromConfig-BkUoWC2U.js +0 -22
- package/dist/parseFromConfig-BkUoWC2U.js.map +0 -1
- package/dist/parseFromConfig-EjsCZ0-8.cjs +0 -32
- package/dist/parseFromConfig-EjsCZ0-8.cjs.map +0 -1
- package/src/utils/parseFromConfig.ts +0 -39
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
1
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
3
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import * as OasTypes from "oas/types";
|
|
5
|
+
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
6
|
+
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
7
|
+
import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 } from "openapi-types";
|
|
8
8
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
9
9
|
import BaseOas from "oas";
|
|
10
|
-
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
10
|
|
|
12
11
|
//#region ../core/src/BaseGenerator.d.ts
|
|
13
12
|
/**
|
|
@@ -75,6 +74,21 @@ type Logger = {
|
|
|
75
74
|
type PossiblePromise<T> = Promise<T> | T;
|
|
76
75
|
//#endregion
|
|
77
76
|
//#region ../core/src/types.d.ts
|
|
77
|
+
declare global {
|
|
78
|
+
namespace Kubb {
|
|
79
|
+
interface PluginContext {}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Config used in `kubb.config.ts`
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* import { defineConfig } from '@kubb/core'
|
|
87
|
+
* export default defineConfig({
|
|
88
|
+
* ...
|
|
89
|
+
* })
|
|
90
|
+
*/
|
|
91
|
+
|
|
78
92
|
type InputPath = {
|
|
79
93
|
/**
|
|
80
94
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -229,11 +243,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
229
243
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
230
244
|
*/
|
|
231
245
|
post?: Array<string>;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} : {
|
|
235
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
236
|
-
});
|
|
246
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
247
|
+
};
|
|
237
248
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
238
249
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
239
250
|
/**
|
|
@@ -259,25 +270,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
259
270
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
260
271
|
*/
|
|
261
272
|
options: TOptions['resolvedOptions'];
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
276
|
+
*/
|
|
277
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
278
|
+
};
|
|
267
279
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
268
280
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
269
281
|
/**
|
|
270
282
|
* Start of the lifecycle of a plugin.
|
|
271
283
|
* @type hookParallel
|
|
272
284
|
*/
|
|
273
|
-
|
|
285
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
274
286
|
/**
|
|
275
287
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
276
288
|
* Options can als be included.
|
|
277
289
|
* @type hookFirst
|
|
278
290
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
279
291
|
*/
|
|
280
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
292
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
281
293
|
/**
|
|
282
294
|
* Resolve to a name based on a string.
|
|
283
295
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -285,11 +297,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
285
297
|
* @example ('pet') => 'Pet'
|
|
286
298
|
*/
|
|
287
299
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
288
|
-
/**
|
|
289
|
-
* End of the plugin lifecycle.
|
|
290
|
-
* @type hookParallel
|
|
291
|
-
*/
|
|
292
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
293
300
|
};
|
|
294
301
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
295
302
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -316,24 +323,15 @@ type ResolveNameParams = {
|
|
|
316
323
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
317
324
|
fabric: Fabric;
|
|
318
325
|
config: Config;
|
|
319
|
-
/**
|
|
320
|
-
* @deprecated
|
|
321
|
-
*/
|
|
322
|
-
fileManager: FileManager;
|
|
323
326
|
pluginManager: PluginManager;
|
|
324
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
325
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
326
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
327
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
327
328
|
logger: Logger;
|
|
328
|
-
|
|
329
|
-
* All plugins
|
|
330
|
-
*/
|
|
331
|
-
plugins: Plugin[];
|
|
329
|
+
mode: KubbFile.Mode;
|
|
332
330
|
/**
|
|
333
331
|
* Current plugin
|
|
334
332
|
*/
|
|
335
333
|
plugin: Plugin<TOptions>;
|
|
336
|
-
};
|
|
334
|
+
} & Kubb.PluginContext;
|
|
337
335
|
/**
|
|
338
336
|
* Specify the export location for the files and define the behavior of the output
|
|
339
337
|
*/
|
|
@@ -386,7 +384,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
386
384
|
result: Result;
|
|
387
385
|
plugin: Plugin;
|
|
388
386
|
};
|
|
389
|
-
type Options$
|
|
387
|
+
type Options$1 = {
|
|
390
388
|
fabric: Fabric;
|
|
391
389
|
logger: Logger;
|
|
392
390
|
/**
|
|
@@ -408,13 +406,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
408
406
|
};
|
|
409
407
|
declare class PluginManager {
|
|
410
408
|
#private;
|
|
411
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
412
409
|
readonly events: EventEmitter<Events>;
|
|
413
410
|
readonly config: Config;
|
|
414
411
|
readonly executed: Array<Executer>;
|
|
415
412
|
readonly logger: Logger;
|
|
416
|
-
readonly options: Options$
|
|
417
|
-
constructor(config: Config, options: Options$
|
|
413
|
+
readonly options: Options$1;
|
|
414
|
+
constructor(config: Config, options: Options$1);
|
|
415
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
416
|
+
get plugins(): Array<Plugin>;
|
|
418
417
|
getFile<TOptions = object>({
|
|
419
418
|
name,
|
|
420
419
|
mode,
|
|
@@ -424,7 +423,7 @@ declare class PluginManager {
|
|
|
424
423
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
425
424
|
pluginKey: Plugin['key'];
|
|
426
425
|
}>;
|
|
427
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
426
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
428
427
|
resolveName: (params: ResolveNameParams) => string;
|
|
429
428
|
/**
|
|
430
429
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -512,17 +511,22 @@ declare class PluginManager {
|
|
|
512
511
|
}): Promise<void>;
|
|
513
512
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
514
513
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
515
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
516
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
517
514
|
}
|
|
518
515
|
//#endregion
|
|
519
|
-
//#region ../core/src/
|
|
516
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
520
517
|
type FileMetaBase = {
|
|
521
518
|
pluginKey?: Plugin['key'];
|
|
522
519
|
};
|
|
523
520
|
//#endregion
|
|
521
|
+
//#region ../oas/src/types.d.ts
|
|
522
|
+
type contentType = 'application/json' | (string & {});
|
|
523
|
+
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
524
|
+
'x-nullable'?: boolean;
|
|
525
|
+
$ref?: string;
|
|
526
|
+
};
|
|
527
|
+
//#endregion
|
|
524
528
|
//#region ../oas/src/Oas.d.ts
|
|
525
|
-
type Options
|
|
529
|
+
type Options = {
|
|
526
530
|
contentType?: contentType;
|
|
527
531
|
discriminator?: 'strict' | 'inherit';
|
|
528
532
|
};
|
|
@@ -536,8 +540,8 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
536
540
|
oas: TOAS | OASDocument | string;
|
|
537
541
|
user?: User;
|
|
538
542
|
});
|
|
539
|
-
setOptions(options: Options
|
|
540
|
-
get options(): Options
|
|
543
|
+
setOptions(options: Options): void;
|
|
544
|
+
get options(): Options;
|
|
541
545
|
get($ref: string): any;
|
|
542
546
|
getKey($ref: string): string | undefined;
|
|
543
547
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -549,312 +553,290 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
549
553
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
550
554
|
}
|
|
551
555
|
//#endregion
|
|
552
|
-
//#region src/
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
//#region ../oas/src/utils.d.ts
|
|
557
|
+
declare function isOptional(schema?: SchemaObject): boolean;
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/SchemaMapper.d.ts
|
|
560
|
+
type SchemaKeywordMapper = {
|
|
561
|
+
object: {
|
|
562
|
+
keyword: 'object';
|
|
563
|
+
args: {
|
|
564
|
+
properties: {
|
|
565
|
+
[x: string]: Schema[];
|
|
566
|
+
};
|
|
567
|
+
additionalProperties: Schema[];
|
|
568
|
+
strict?: boolean;
|
|
569
|
+
};
|
|
558
570
|
};
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
type API = {
|
|
562
|
-
getOas: () => Promise<Oas>;
|
|
563
|
-
getBaseURL: () => Promise<string | undefined>;
|
|
564
|
-
};
|
|
565
|
-
type Options$1 = {
|
|
566
|
-
/**
|
|
567
|
-
* Validate your input(see kubb.config) based on '@readme/openapi-parser'.
|
|
568
|
-
* @default true
|
|
569
|
-
*/
|
|
570
|
-
validate?: boolean;
|
|
571
|
-
/**
|
|
572
|
-
* Specify the export location for the files and define the behavior of the output
|
|
573
|
-
* @default { path: 'schemas', barrelType: 'named' }
|
|
574
|
-
*/
|
|
575
|
-
output?: Output<Oas>;
|
|
576
|
-
/**
|
|
577
|
-
* Group the JSON files based on the provided name.
|
|
578
|
-
*/
|
|
579
|
-
group?: Group;
|
|
580
|
-
/**
|
|
581
|
-
* Which server to use from the array of `servers.url[serverIndex]`
|
|
582
|
-
* @example
|
|
583
|
-
* - `0` will return `http://petstore.swagger.io/api`
|
|
584
|
-
* - `1` will return `http://localhost:3000`
|
|
585
|
-
*/
|
|
586
|
-
serverIndex?: number;
|
|
587
|
-
/**
|
|
588
|
-
* Define which contentType should be used.
|
|
589
|
-
* By default, the first JSON valid mediaType will be used
|
|
590
|
-
*/
|
|
591
|
-
contentType?: contentType;
|
|
592
|
-
/**
|
|
593
|
-
* Defines how the discriminator value should be interpreted during processing.
|
|
594
|
-
*
|
|
595
|
-
* @default 'strict'
|
|
596
|
-
*
|
|
597
|
-
* @example
|
|
598
|
-
* - `inherit`: Replaces the `oneOf` schema with the schema referenced by `discriminator.mapping[key]`.
|
|
599
|
-
* - `strict`: Uses the `oneOf` schemas as defined, without modification.
|
|
600
|
-
*
|
|
601
|
-
* @see https://github.com/kubb-labs/kubb/issues/1736
|
|
602
|
-
*/
|
|
603
|
-
discriminator?: 'strict' | 'inherit';
|
|
604
|
-
/**
|
|
605
|
-
* Override some behaviour of the Oas class instance, see '@kubb/oas'
|
|
606
|
-
*/
|
|
607
|
-
oasClass?: typeof Oas;
|
|
608
|
-
/**
|
|
609
|
-
* Define some generators next to the JSON generation
|
|
610
|
-
*/
|
|
611
|
-
generators?: Array<Generator<PluginOas>>;
|
|
612
|
-
};
|
|
613
|
-
/**
|
|
614
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
615
|
-
* @example import { Pet } from './Pet'
|
|
616
|
-
*
|
|
617
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
618
|
-
*
|
|
619
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
620
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
621
|
-
*/
|
|
622
|
-
type Ref = {
|
|
623
|
-
propertyName: string;
|
|
624
|
-
originalName: string;
|
|
625
|
-
path: KubbFile.OptionalPath;
|
|
626
|
-
pluginKey?: Plugin['key'];
|
|
627
|
-
};
|
|
628
|
-
type Refs = Record<string, Ref>;
|
|
629
|
-
type Resolver = {
|
|
630
|
-
/**
|
|
631
|
-
* Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
|
|
632
|
-
*/
|
|
633
|
-
name: string;
|
|
634
|
-
baseName: KubbFile.BaseName;
|
|
635
|
-
path: KubbFile.Path;
|
|
636
|
-
};
|
|
637
|
-
type OperationSchema = {
|
|
638
|
-
/**
|
|
639
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
640
|
-
*/
|
|
641
|
-
name: string;
|
|
642
|
-
schema: SchemaObject$1;
|
|
643
|
-
operation?: Operation$1;
|
|
644
|
-
/**
|
|
645
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
646
|
-
*/
|
|
647
|
-
operationName: string;
|
|
648
|
-
description?: string;
|
|
649
|
-
statusCode?: number;
|
|
650
|
-
keys?: string[];
|
|
651
|
-
keysToOmit?: string[];
|
|
652
|
-
withData?: boolean;
|
|
653
|
-
};
|
|
654
|
-
type OperationSchemas = {
|
|
655
|
-
pathParams?: OperationSchema & {
|
|
656
|
-
keysToOmit?: never;
|
|
571
|
+
url: {
|
|
572
|
+
keyword: 'url';
|
|
657
573
|
};
|
|
658
|
-
|
|
659
|
-
|
|
574
|
+
readOnly: {
|
|
575
|
+
keyword: 'readOnly';
|
|
660
576
|
};
|
|
661
|
-
|
|
662
|
-
|
|
577
|
+
writeOnly: {
|
|
578
|
+
keyword: 'writeOnly';
|
|
663
579
|
};
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
580
|
+
uuid: {
|
|
581
|
+
keyword: 'uuid';
|
|
582
|
+
};
|
|
583
|
+
email: {
|
|
584
|
+
keyword: 'email';
|
|
585
|
+
};
|
|
586
|
+
firstName: {
|
|
587
|
+
keyword: 'firstName';
|
|
588
|
+
};
|
|
589
|
+
lastName: {
|
|
590
|
+
keyword: 'lastName';
|
|
591
|
+
};
|
|
592
|
+
phone: {
|
|
593
|
+
keyword: 'phone';
|
|
594
|
+
};
|
|
595
|
+
password: {
|
|
596
|
+
keyword: 'password';
|
|
597
|
+
};
|
|
598
|
+
date: {
|
|
599
|
+
keyword: 'date';
|
|
600
|
+
args: {
|
|
601
|
+
type?: 'date' | 'string';
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
time: {
|
|
605
|
+
keyword: 'time';
|
|
606
|
+
args: {
|
|
607
|
+
type?: 'date' | 'string';
|
|
608
|
+
};
|
|
609
|
+
};
|
|
610
|
+
datetime: {
|
|
611
|
+
keyword: 'datetime';
|
|
612
|
+
args: {
|
|
613
|
+
offset?: boolean;
|
|
614
|
+
local?: boolean;
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
tuple: {
|
|
618
|
+
keyword: 'tuple';
|
|
619
|
+
args: {
|
|
620
|
+
items: Schema[];
|
|
621
|
+
min?: number;
|
|
622
|
+
max?: number;
|
|
623
|
+
rest?: Schema;
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
array: {
|
|
627
|
+
keyword: 'array';
|
|
628
|
+
args: {
|
|
629
|
+
items: Schema[];
|
|
630
|
+
min?: number;
|
|
631
|
+
max?: number;
|
|
632
|
+
unique?: boolean;
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
enum: {
|
|
636
|
+
keyword: 'enum';
|
|
637
|
+
args: {
|
|
638
|
+
name: string;
|
|
639
|
+
typeName: string;
|
|
640
|
+
asConst: boolean;
|
|
641
|
+
items: Array<{
|
|
642
|
+
name: string | number;
|
|
643
|
+
format: 'string' | 'number' | 'boolean';
|
|
644
|
+
value?: string | number | boolean;
|
|
645
|
+
}>;
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
and: {
|
|
649
|
+
keyword: 'and';
|
|
650
|
+
args: Schema[];
|
|
651
|
+
};
|
|
652
|
+
const: {
|
|
653
|
+
keyword: 'const';
|
|
654
|
+
args: {
|
|
655
|
+
name: string | number;
|
|
656
|
+
format: 'string' | 'number' | 'boolean';
|
|
657
|
+
value?: string | number | boolean;
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
union: {
|
|
661
|
+
keyword: 'union';
|
|
662
|
+
args: Schema[];
|
|
663
|
+
};
|
|
664
|
+
ref: {
|
|
665
|
+
keyword: 'ref';
|
|
666
|
+
args: {
|
|
667
|
+
name: string;
|
|
668
|
+
$ref: string;
|
|
669
|
+
/**
|
|
670
|
+
* Full qualified path.
|
|
671
|
+
*/
|
|
672
|
+
path: KubbFile.Path;
|
|
673
|
+
/**
|
|
674
|
+
* When true `File.Import` will be used.
|
|
675
|
+
* When false a reference will be used inside the current file.
|
|
676
|
+
*/
|
|
677
|
+
isImportable: boolean;
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
matches: {
|
|
681
|
+
keyword: 'matches';
|
|
682
|
+
args?: string;
|
|
683
|
+
};
|
|
684
|
+
boolean: {
|
|
685
|
+
keyword: 'boolean';
|
|
686
|
+
};
|
|
687
|
+
default: {
|
|
688
|
+
keyword: 'default';
|
|
689
|
+
args: string | number | boolean;
|
|
690
|
+
};
|
|
691
|
+
string: {
|
|
692
|
+
keyword: 'string';
|
|
693
|
+
};
|
|
694
|
+
integer: {
|
|
695
|
+
keyword: 'integer';
|
|
696
|
+
};
|
|
697
|
+
number: {
|
|
698
|
+
keyword: 'number';
|
|
699
|
+
};
|
|
700
|
+
max: {
|
|
701
|
+
keyword: 'max';
|
|
702
|
+
args: number;
|
|
703
|
+
};
|
|
704
|
+
min: {
|
|
705
|
+
keyword: 'min';
|
|
706
|
+
args: number;
|
|
707
|
+
};
|
|
708
|
+
exclusiveMaximum: {
|
|
709
|
+
keyword: 'exclusiveMaximum';
|
|
710
|
+
args: number;
|
|
711
|
+
};
|
|
712
|
+
exclusiveMinimum: {
|
|
713
|
+
keyword: 'exclusiveMinimum';
|
|
714
|
+
args: number;
|
|
715
|
+
};
|
|
716
|
+
describe: {
|
|
717
|
+
keyword: 'describe';
|
|
718
|
+
args: string;
|
|
719
|
+
};
|
|
720
|
+
example: {
|
|
721
|
+
keyword: 'example';
|
|
722
|
+
args: string;
|
|
723
|
+
};
|
|
724
|
+
deprecated: {
|
|
725
|
+
keyword: 'deprecated';
|
|
726
|
+
};
|
|
727
|
+
optional: {
|
|
728
|
+
keyword: 'optional';
|
|
729
|
+
};
|
|
730
|
+
undefined: {
|
|
731
|
+
keyword: 'undefined';
|
|
732
|
+
};
|
|
733
|
+
nullish: {
|
|
734
|
+
keyword: 'nullish';
|
|
735
|
+
};
|
|
736
|
+
nullable: {
|
|
737
|
+
keyword: 'nullable';
|
|
738
|
+
};
|
|
739
|
+
null: {
|
|
740
|
+
keyword: 'null';
|
|
741
|
+
};
|
|
742
|
+
any: {
|
|
743
|
+
keyword: 'any';
|
|
744
|
+
};
|
|
745
|
+
unknown: {
|
|
746
|
+
keyword: 'unknown';
|
|
747
|
+
};
|
|
748
|
+
void: {
|
|
749
|
+
keyword: 'void';
|
|
750
|
+
};
|
|
751
|
+
blob: {
|
|
752
|
+
keyword: 'blob';
|
|
772
753
|
};
|
|
773
|
-
};
|
|
774
|
-
type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
|
|
775
|
-
type SchemaProps$1 = {
|
|
776
|
-
schemaObject?: SchemaObject$1;
|
|
777
|
-
name?: string;
|
|
778
|
-
parentName?: string;
|
|
779
|
-
};
|
|
780
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
781
|
-
#private;
|
|
782
|
-
refs: Refs;
|
|
783
|
-
/**
|
|
784
|
-
* Creates a type node from a given schema.
|
|
785
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
786
|
-
* optionally adds a union with null.
|
|
787
|
-
*/
|
|
788
|
-
parse(props: SchemaProps$1): Schema[];
|
|
789
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
790
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
791
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
792
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
793
|
-
}
|
|
794
|
-
//#endregion
|
|
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;
|
|
801
|
-
};
|
|
802
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
803
|
-
name: string;
|
|
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>;
|
|
817
|
-
//#endregion
|
|
818
|
-
//#region src/generators/types.d.ts
|
|
819
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
820
|
-
config: Config;
|
|
821
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
822
|
-
plugin: Plugin<TOptions>;
|
|
823
|
-
operations: Array<Operation$1>;
|
|
824
|
-
};
|
|
825
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
826
|
-
config: Config;
|
|
827
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
828
|
-
plugin: Plugin<TOptions>;
|
|
829
|
-
operation: Operation$1;
|
|
830
|
-
};
|
|
831
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
832
|
-
config: Config;
|
|
833
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
834
|
-
plugin: Plugin<TOptions>;
|
|
835
754
|
schema: {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
755
|
+
keyword: 'schema';
|
|
756
|
+
args: {
|
|
757
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
758
|
+
format?: string;
|
|
759
|
+
};
|
|
760
|
+
};
|
|
761
|
+
name: {
|
|
762
|
+
keyword: 'name';
|
|
763
|
+
args: string;
|
|
764
|
+
};
|
|
765
|
+
catchall: {
|
|
766
|
+
keyword: 'catchall';
|
|
767
|
+
};
|
|
768
|
+
interface: {
|
|
769
|
+
keyword: 'interface';
|
|
839
770
|
};
|
|
840
771
|
};
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
772
|
+
declare const schemaKeywords: {
|
|
773
|
+
any: "any";
|
|
774
|
+
unknown: "unknown";
|
|
775
|
+
number: "number";
|
|
776
|
+
integer: "integer";
|
|
777
|
+
string: "string";
|
|
778
|
+
boolean: "boolean";
|
|
779
|
+
undefined: "undefined";
|
|
780
|
+
nullable: "nullable";
|
|
781
|
+
null: "null";
|
|
782
|
+
nullish: "nullish";
|
|
783
|
+
array: "array";
|
|
784
|
+
tuple: "tuple";
|
|
785
|
+
enum: "enum";
|
|
786
|
+
union: "union";
|
|
787
|
+
datetime: "datetime";
|
|
788
|
+
date: "date";
|
|
789
|
+
email: "email";
|
|
790
|
+
uuid: "uuid";
|
|
791
|
+
url: "url";
|
|
792
|
+
void: "void";
|
|
793
|
+
default: "default";
|
|
794
|
+
const: "const";
|
|
795
|
+
and: "and";
|
|
796
|
+
describe: "describe";
|
|
797
|
+
min: "min";
|
|
798
|
+
max: "max";
|
|
799
|
+
exclusiveMinimum: "exclusiveMinimum";
|
|
800
|
+
exclusiveMaximum: "exclusiveMaximum";
|
|
801
|
+
optional: "optional";
|
|
802
|
+
readOnly: "readOnly";
|
|
803
|
+
writeOnly: "writeOnly";
|
|
804
|
+
object: "object";
|
|
805
|
+
ref: "ref";
|
|
806
|
+
matches: "matches";
|
|
807
|
+
firstName: "firstName";
|
|
808
|
+
lastName: "lastName";
|
|
809
|
+
password: "password";
|
|
810
|
+
phone: "phone";
|
|
811
|
+
blob: "blob";
|
|
812
|
+
deprecated: "deprecated";
|
|
813
|
+
example: "example";
|
|
814
|
+
schema: "schema";
|
|
815
|
+
catchall: "catchall";
|
|
816
|
+
time: "time";
|
|
817
|
+
name: "name";
|
|
818
|
+
interface: "interface";
|
|
819
|
+
};
|
|
820
|
+
type SchemaKeyword = keyof SchemaKeywordMapper;
|
|
821
|
+
type SchemaMapper<T = string | null | undefined> = { [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined };
|
|
822
|
+
type SchemaKeywordBase<T> = {
|
|
823
|
+
keyword: SchemaKeyword;
|
|
824
|
+
args: T;
|
|
825
|
+
};
|
|
826
|
+
type Schema = {
|
|
827
|
+
keyword: string;
|
|
828
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
829
|
+
type SchemaTree = {
|
|
830
|
+
schema: SchemaObject$1;
|
|
831
|
+
parent: Schema | undefined;
|
|
832
|
+
current: Schema;
|
|
833
|
+
siblings: Schema[];
|
|
834
|
+
/**
|
|
835
|
+
* this will be equal to the key of a property(object)
|
|
836
|
+
*/
|
|
837
|
+
name?: string;
|
|
856
838
|
};
|
|
857
|
-
declare function
|
|
839
|
+
declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
|
|
858
840
|
//#endregion
|
|
859
|
-
export {
|
|
860
|
-
//# sourceMappingURL=
|
|
841
|
+
export { Plugin as C, BaseGenerator as D, UserPluginWithLifeCycle as E, Output as S, ResolveNameParams as T, contentType as _, SchemaMapper as a, Config as b, schemaKeywords as c, HttpMethod as d, OasTypes as f, SchemaObject$1 as g, Operation$1 as h, SchemaKeywordMapper as i, isOptional as l, OpenAPIV3_1 as m, SchemaKeyword as n, SchemaTree as o, OpenAPIV3$1 as p, SchemaKeywordBase as r, isKeyword as s, Schema as t, Oas as u, FileMetaBase as v, PluginFactoryOptions as w, Group as x, PluginManager as y };
|
|
842
|
+
//# sourceMappingURL=SchemaMapper-BtvCVaPJ.d.ts.map
|