@kubb/plugin-oas 0.0.0-canary-20240509211223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/OperationGenerator-DvnXUUp4.d.ts +56 -0
- package/dist/OperationGenerator-X6CTMfhG.d.cts +56 -0
- package/dist/Schema-BWPWyiQO.d.cts +39 -0
- package/dist/Schema-DFZBfjF2.d.ts +39 -0
- package/dist/SchemaGenerator-hK5SHxTI.d.ts +316 -0
- package/dist/SchemaGenerator-z_7YrAAB.d.cts +316 -0
- package/dist/chunk-2MJ2CQMI.js +61 -0
- package/dist/chunk-2MJ2CQMI.js.map +1 -0
- package/dist/chunk-3RCQ2LNT.js +81 -0
- package/dist/chunk-3RCQ2LNT.js.map +1 -0
- package/dist/chunk-55NUFNT6.cjs +68 -0
- package/dist/chunk-55NUFNT6.cjs.map +1 -0
- package/dist/chunk-ECXSQTMV.cjs +81 -0
- package/dist/chunk-ECXSQTMV.cjs.map +1 -0
- package/dist/chunk-EPTOYYAP.js +3312 -0
- package/dist/chunk-EPTOYYAP.js.map +1 -0
- package/dist/chunk-H52M2RUX.cjs +3312 -0
- package/dist/chunk-H52M2RUX.cjs.map +1 -0
- package/dist/chunk-LQ6IAWRX.js +68 -0
- package/dist/chunk-LQ6IAWRX.js.map +1 -0
- package/dist/chunk-VNFSHGSN.cjs +61 -0
- package/dist/chunk-VNFSHGSN.cjs.map +1 -0
- package/dist/components.cjs +18 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +41 -0
- package/dist/components.d.ts +41 -0
- package/dist/components.js +18 -0
- package/dist/components.js.map +1 -0
- package/dist/hooks.cjs +152 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +76 -0
- package/dist/hooks.d.ts +76 -0
- package/dist/hooks.js +152 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +985 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +985 -0
- package/dist/index.js.map +1 -0
- package/dist/types-n5zV4Q3s.d.cts +146 -0
- package/dist/types-n5zV4Q3s.d.ts +146 -0
- package/dist/utils.cjs +126 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +80 -0
- package/dist/utils.d.ts +80 -0
- package/dist/utils.js +126 -0
- package/dist/utils.js.map +1 -0
- package/package.json +107 -0
- package/src/OperationGenerator.ts +328 -0
- package/src/SchemaGenerator.ts +827 -0
- package/src/SchemaMapper.ts +145 -0
- package/src/components/Oas.tsx +31 -0
- package/src/components/Operation.tsx +21 -0
- package/src/components/Schema.tsx +156 -0
- package/src/components/index.ts +3 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useOas.ts +15 -0
- package/src/hooks/useOperation.ts +18 -0
- package/src/hooks/useOperationManager.ts +142 -0
- package/src/hooks/useOperations.ts +40 -0
- package/src/hooks/useSchema.ts +23 -0
- package/src/index.ts +30 -0
- package/src/plugin.ts +133 -0
- package/src/types.ts +147 -0
- package/src/utils/getComments.ts +15 -0
- package/src/utils/getGroupedByTagFiles.ts +81 -0
- package/src/utils/getParams.ts +57 -0
- package/src/utils/getSchemaFactory.ts +33 -0
- package/src/utils/getSchemas.ts +45 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/parseFromConfig.ts +36 -0
- package/src/utils/refSorter.ts +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Stijn Van Hulle
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
|
|
4
|
+
<h1>@kubb/plugin-oas</h1>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
Swagger package.
|
|
8
|
+
</p>
|
|
9
|
+
<img src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/banner.png" alt="logo" height="auto" />
|
|
10
|
+
|
|
11
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
12
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
13
|
+
[![Coverage][coverage-src]][coverage-href]
|
|
14
|
+
[![License][license-src]][license-href]
|
|
15
|
+
|
|
16
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
17
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<h4>
|
|
21
|
+
<a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
|
|
22
|
+
<span> · </span>
|
|
23
|
+
<a href="https://kubb.dev/" target="_blank">Documentation</a>
|
|
24
|
+
<span> · </span>
|
|
25
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
26
|
+
<span> · </span>
|
|
27
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
28
|
+
</h4>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<!-- Badges -->
|
|
32
|
+
|
|
33
|
+
[npm-version-src]: https://img.shields.io/npm/v/@kubb/plugin-oas?flat&colorA=18181B&colorB=f58517
|
|
34
|
+
[npm-version-href]: https://npmjs.com/package/@kubb/plugin-oas
|
|
35
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/plugin-oas?flat&colorA=18181B&colorB=f58517
|
|
36
|
+
[npm-downloads-href]: https://npmjs.com/package/@kubb/plugin-oas
|
|
37
|
+
[license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
|
|
38
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
39
|
+
[build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
|
|
40
|
+
[build-href]: https://www.npmjs.com/package/@kubb/plugin-oas
|
|
41
|
+
[minified-src]: https://img.shields.io/bundlephobia/min/@kubb/plugin-oas?style=flat&colorA=18181B&colorB=f58517
|
|
42
|
+
[minified-href]: https://www.npmjs.com/package/@kubb/plugin-oas
|
|
43
|
+
[coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
|
|
44
|
+
[coverage-href]: https://www.npmjs.com/package/@kubb/plugin-oas
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { KubbFile, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
+
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
3
|
+
import { f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include, g as Override } from './types-n5zV4Q3s.js';
|
|
4
|
+
|
|
5
|
+
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
6
|
+
type OperationMethodResult<TFileMeta extends KubbFile.FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
7
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
8
|
+
oas: Oas;
|
|
9
|
+
exclude: Array<Exclude> | undefined;
|
|
10
|
+
include: Array<Include> | undefined;
|
|
11
|
+
override: Array<Override<TOptions>> | undefined;
|
|
12
|
+
contentType: contentType | undefined;
|
|
13
|
+
pluginManager: PluginManager;
|
|
14
|
+
/**
|
|
15
|
+
* Current plugin
|
|
16
|
+
*/
|
|
17
|
+
plugin: Plugin<TPluginOptions>;
|
|
18
|
+
mode: KubbFile.Mode;
|
|
19
|
+
};
|
|
20
|
+
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
21
|
+
#private;
|
|
22
|
+
get operationsByMethod(): OperationsByMethod;
|
|
23
|
+
set operationsByMethod(paths: OperationsByMethod);
|
|
24
|
+
getSchemas(operation: Operation, forStatusCode?: string | number): OperationSchemas;
|
|
25
|
+
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
26
|
+
/**
|
|
27
|
+
* Operation
|
|
28
|
+
*/
|
|
29
|
+
abstract operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
30
|
+
/**
|
|
31
|
+
* GET
|
|
32
|
+
*/
|
|
33
|
+
abstract get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
+
/**
|
|
35
|
+
* POST
|
|
36
|
+
*/
|
|
37
|
+
abstract post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
+
/**
|
|
39
|
+
* PATCH
|
|
40
|
+
*/
|
|
41
|
+
abstract patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
+
/**
|
|
43
|
+
* PUT
|
|
44
|
+
*/
|
|
45
|
+
abstract put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
+
/**
|
|
47
|
+
* DELETE
|
|
48
|
+
*/
|
|
49
|
+
abstract delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
+
/**
|
|
51
|
+
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
52
|
+
*/
|
|
53
|
+
abstract all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { KubbFile, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
+
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
3
|
+
import { f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include, g as Override } from './types-n5zV4Q3s.cjs';
|
|
4
|
+
|
|
5
|
+
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
6
|
+
type OperationMethodResult<TFileMeta extends KubbFile.FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
7
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
8
|
+
oas: Oas;
|
|
9
|
+
exclude: Array<Exclude> | undefined;
|
|
10
|
+
include: Array<Include> | undefined;
|
|
11
|
+
override: Array<Override<TOptions>> | undefined;
|
|
12
|
+
contentType: contentType | undefined;
|
|
13
|
+
pluginManager: PluginManager;
|
|
14
|
+
/**
|
|
15
|
+
* Current plugin
|
|
16
|
+
*/
|
|
17
|
+
plugin: Plugin<TPluginOptions>;
|
|
18
|
+
mode: KubbFile.Mode;
|
|
19
|
+
};
|
|
20
|
+
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
21
|
+
#private;
|
|
22
|
+
get operationsByMethod(): OperationsByMethod;
|
|
23
|
+
set operationsByMethod(paths: OperationsByMethod);
|
|
24
|
+
getSchemas(operation: Operation, forStatusCode?: string | number): OperationSchemas;
|
|
25
|
+
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
26
|
+
/**
|
|
27
|
+
* Operation
|
|
28
|
+
*/
|
|
29
|
+
abstract operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
30
|
+
/**
|
|
31
|
+
* GET
|
|
32
|
+
*/
|
|
33
|
+
abstract get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
+
/**
|
|
35
|
+
* POST
|
|
36
|
+
*/
|
|
37
|
+
abstract post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
+
/**
|
|
39
|
+
* PATCH
|
|
40
|
+
*/
|
|
41
|
+
abstract patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
+
/**
|
|
43
|
+
* PUT
|
|
44
|
+
*/
|
|
45
|
+
abstract put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
+
/**
|
|
47
|
+
* DELETE
|
|
48
|
+
*/
|
|
49
|
+
abstract delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
+
/**
|
|
51
|
+
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
52
|
+
*/
|
|
53
|
+
abstract all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SchemaObject } from '@kubb/oas';
|
|
4
|
+
import { KubbNode } from '@kubb/react';
|
|
5
|
+
import { S as SchemaGeneratorBuildOptions, d as Schema$1, c as SchemaGenerator } from './SchemaGenerator-z_7YrAAB.cjs';
|
|
6
|
+
|
|
7
|
+
type SchemaContextProps = {
|
|
8
|
+
name: string;
|
|
9
|
+
object?: SchemaObject;
|
|
10
|
+
generator?: SchemaGenerator;
|
|
11
|
+
schemas: Schema$1[];
|
|
12
|
+
};
|
|
13
|
+
type Props = {
|
|
14
|
+
name: string;
|
|
15
|
+
object?: SchemaObject;
|
|
16
|
+
generator: SchemaGenerator<any, any, any>;
|
|
17
|
+
children?: KubbNode;
|
|
18
|
+
};
|
|
19
|
+
declare function Schema({ name, object, generator, children }: Props): KubbNode;
|
|
20
|
+
declare namespace Schema {
|
|
21
|
+
var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
|
|
22
|
+
var Imports: ({ isTypeOnly }: SchemaImportsProps) => ReactNode;
|
|
23
|
+
var Source: <TOptions extends SchemaGeneratorBuildOptions = SchemaGeneratorBuildOptions>({ options, extraSchemas, }: SchemaSourceProps<TOptions>) => ReactNode;
|
|
24
|
+
var Context: react.Context<SchemaContextProps>;
|
|
25
|
+
}
|
|
26
|
+
type FileProps = {
|
|
27
|
+
isTypeOnly?: boolean;
|
|
28
|
+
output: string | undefined;
|
|
29
|
+
children?: KubbNode;
|
|
30
|
+
};
|
|
31
|
+
type SchemaImportsProps = {
|
|
32
|
+
isTypeOnly?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type SchemaSourceProps<TOptions extends SchemaGeneratorBuildOptions = SchemaGeneratorBuildOptions> = {
|
|
35
|
+
extraSchemas?: Schema$1[];
|
|
36
|
+
options?: TOptions;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { Schema as S, type SchemaContextProps as a };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SchemaObject } from '@kubb/oas';
|
|
4
|
+
import { KubbNode } from '@kubb/react';
|
|
5
|
+
import { S as SchemaGeneratorBuildOptions, d as Schema$1, c as SchemaGenerator } from './SchemaGenerator-hK5SHxTI.js';
|
|
6
|
+
|
|
7
|
+
type SchemaContextProps = {
|
|
8
|
+
name: string;
|
|
9
|
+
object?: SchemaObject;
|
|
10
|
+
generator?: SchemaGenerator;
|
|
11
|
+
schemas: Schema$1[];
|
|
12
|
+
};
|
|
13
|
+
type Props = {
|
|
14
|
+
name: string;
|
|
15
|
+
object?: SchemaObject;
|
|
16
|
+
generator: SchemaGenerator<any, any, any>;
|
|
17
|
+
children?: KubbNode;
|
|
18
|
+
};
|
|
19
|
+
declare function Schema({ name, object, generator, children }: Props): KubbNode;
|
|
20
|
+
declare namespace Schema {
|
|
21
|
+
var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
|
|
22
|
+
var Imports: ({ isTypeOnly }: SchemaImportsProps) => ReactNode;
|
|
23
|
+
var Source: <TOptions extends SchemaGeneratorBuildOptions = SchemaGeneratorBuildOptions>({ options, extraSchemas, }: SchemaSourceProps<TOptions>) => ReactNode;
|
|
24
|
+
var Context: react.Context<SchemaContextProps>;
|
|
25
|
+
}
|
|
26
|
+
type FileProps = {
|
|
27
|
+
isTypeOnly?: boolean;
|
|
28
|
+
output: string | undefined;
|
|
29
|
+
children?: KubbNode;
|
|
30
|
+
};
|
|
31
|
+
type SchemaImportsProps = {
|
|
32
|
+
isTypeOnly?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type SchemaSourceProps<TOptions extends SchemaGeneratorBuildOptions = SchemaGeneratorBuildOptions> = {
|
|
35
|
+
extraSchemas?: Schema$1[];
|
|
36
|
+
options?: TOptions;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { Schema as S, type SchemaContextProps as a };
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { KubbFile, ResolveNameParams, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
+
import { SchemaObject, Oas, contentType } from '@kubb/oas';
|
|
3
|
+
import { d as OperationSchema, b as Refs, g as Override } from './types-n5zV4Q3s.js';
|
|
4
|
+
|
|
5
|
+
type SchemaKeywordMapper = {
|
|
6
|
+
object: {
|
|
7
|
+
keyword: 'object';
|
|
8
|
+
args: {
|
|
9
|
+
properties: {
|
|
10
|
+
[x: string]: Schema[];
|
|
11
|
+
};
|
|
12
|
+
additionalProperties: Schema[];
|
|
13
|
+
strict?: boolean;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
strict: {
|
|
17
|
+
keyword: 'strict';
|
|
18
|
+
};
|
|
19
|
+
url: {
|
|
20
|
+
keyword: 'url';
|
|
21
|
+
};
|
|
22
|
+
readOnly: {
|
|
23
|
+
keyword: 'readOnly';
|
|
24
|
+
};
|
|
25
|
+
uuid: {
|
|
26
|
+
keyword: 'uuid';
|
|
27
|
+
};
|
|
28
|
+
email: {
|
|
29
|
+
keyword: 'email';
|
|
30
|
+
};
|
|
31
|
+
firstName: {
|
|
32
|
+
keyword: 'firstName';
|
|
33
|
+
};
|
|
34
|
+
lastName: {
|
|
35
|
+
keyword: 'lastName';
|
|
36
|
+
};
|
|
37
|
+
phone: {
|
|
38
|
+
keyword: 'phone';
|
|
39
|
+
};
|
|
40
|
+
password: {
|
|
41
|
+
keyword: 'password';
|
|
42
|
+
};
|
|
43
|
+
date: {
|
|
44
|
+
keyword: 'date';
|
|
45
|
+
args: {
|
|
46
|
+
type?: 'date' | 'string';
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
time: {
|
|
50
|
+
keyword: 'time';
|
|
51
|
+
args: {
|
|
52
|
+
type?: 'date' | 'string';
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
datetime: {
|
|
56
|
+
keyword: 'datetime';
|
|
57
|
+
args: {
|
|
58
|
+
offset?: boolean;
|
|
59
|
+
local?: boolean;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
tuple: {
|
|
63
|
+
keyword: 'tuple';
|
|
64
|
+
args: Schema[];
|
|
65
|
+
};
|
|
66
|
+
array: {
|
|
67
|
+
keyword: 'array';
|
|
68
|
+
args: {
|
|
69
|
+
items: Schema[];
|
|
70
|
+
min?: number;
|
|
71
|
+
max?: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
enum: {
|
|
75
|
+
keyword: 'enum';
|
|
76
|
+
args: {
|
|
77
|
+
name: string;
|
|
78
|
+
typeName: string;
|
|
79
|
+
asConst: boolean;
|
|
80
|
+
items: Array<{
|
|
81
|
+
name: string | number;
|
|
82
|
+
format: 'string' | 'number';
|
|
83
|
+
value?: string | number;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
and: {
|
|
88
|
+
keyword: 'and';
|
|
89
|
+
args: Schema[];
|
|
90
|
+
};
|
|
91
|
+
const: {
|
|
92
|
+
keyword: 'const';
|
|
93
|
+
args: {
|
|
94
|
+
name: string | number;
|
|
95
|
+
format: 'string' | 'number';
|
|
96
|
+
value?: string | number;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
union: {
|
|
100
|
+
keyword: 'union';
|
|
101
|
+
args: Schema[];
|
|
102
|
+
};
|
|
103
|
+
ref: {
|
|
104
|
+
keyword: 'ref';
|
|
105
|
+
args: {
|
|
106
|
+
name: string;
|
|
107
|
+
path: KubbFile.OptionalPath;
|
|
108
|
+
isTypeOnly?: boolean;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
matches: {
|
|
112
|
+
keyword: 'matches';
|
|
113
|
+
args?: string;
|
|
114
|
+
};
|
|
115
|
+
boolean: {
|
|
116
|
+
keyword: 'boolean';
|
|
117
|
+
};
|
|
118
|
+
default: {
|
|
119
|
+
keyword: 'default';
|
|
120
|
+
args: string | number | boolean;
|
|
121
|
+
};
|
|
122
|
+
string: {
|
|
123
|
+
keyword: 'string';
|
|
124
|
+
};
|
|
125
|
+
integer: {
|
|
126
|
+
keyword: 'integer';
|
|
127
|
+
};
|
|
128
|
+
number: {
|
|
129
|
+
keyword: 'number';
|
|
130
|
+
};
|
|
131
|
+
max: {
|
|
132
|
+
keyword: 'max';
|
|
133
|
+
args: number;
|
|
134
|
+
};
|
|
135
|
+
min: {
|
|
136
|
+
keyword: 'min';
|
|
137
|
+
args: number;
|
|
138
|
+
};
|
|
139
|
+
describe: {
|
|
140
|
+
keyword: 'describe';
|
|
141
|
+
args: string;
|
|
142
|
+
};
|
|
143
|
+
example: {
|
|
144
|
+
keyword: 'example';
|
|
145
|
+
args: string;
|
|
146
|
+
};
|
|
147
|
+
deprecated: {
|
|
148
|
+
keyword: 'deprecated';
|
|
149
|
+
};
|
|
150
|
+
optional: {
|
|
151
|
+
keyword: 'optional';
|
|
152
|
+
};
|
|
153
|
+
undefined: {
|
|
154
|
+
keyword: 'undefined';
|
|
155
|
+
};
|
|
156
|
+
nullish: {
|
|
157
|
+
keyword: 'nullish';
|
|
158
|
+
};
|
|
159
|
+
nullable: {
|
|
160
|
+
keyword: 'nullable';
|
|
161
|
+
};
|
|
162
|
+
null: {
|
|
163
|
+
keyword: 'null';
|
|
164
|
+
};
|
|
165
|
+
any: {
|
|
166
|
+
keyword: 'any';
|
|
167
|
+
};
|
|
168
|
+
unknown: {
|
|
169
|
+
keyword: 'unknown';
|
|
170
|
+
};
|
|
171
|
+
blob: {
|
|
172
|
+
keyword: 'blob';
|
|
173
|
+
};
|
|
174
|
+
schema: {
|
|
175
|
+
keyword: 'schema';
|
|
176
|
+
args: {
|
|
177
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
178
|
+
format?: string;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
name: {
|
|
182
|
+
keyword: 'name';
|
|
183
|
+
args: string;
|
|
184
|
+
};
|
|
185
|
+
catchall: {
|
|
186
|
+
keyword: 'catchall';
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
declare const schemaKeywords: {
|
|
190
|
+
any: "any";
|
|
191
|
+
strict: "strict";
|
|
192
|
+
unknown: "unknown";
|
|
193
|
+
number: "number";
|
|
194
|
+
integer: "integer";
|
|
195
|
+
string: "string";
|
|
196
|
+
boolean: "boolean";
|
|
197
|
+
undefined: "undefined";
|
|
198
|
+
nullable: "nullable";
|
|
199
|
+
null: "null";
|
|
200
|
+
nullish: "nullish";
|
|
201
|
+
array: "array";
|
|
202
|
+
tuple: "tuple";
|
|
203
|
+
enum: "enum";
|
|
204
|
+
union: "union";
|
|
205
|
+
datetime: "datetime";
|
|
206
|
+
date: "date";
|
|
207
|
+
email: "email";
|
|
208
|
+
uuid: "uuid";
|
|
209
|
+
url: "url";
|
|
210
|
+
default: "default";
|
|
211
|
+
const: "const";
|
|
212
|
+
and: "and";
|
|
213
|
+
describe: "describe";
|
|
214
|
+
min: "min";
|
|
215
|
+
max: "max";
|
|
216
|
+
optional: "optional";
|
|
217
|
+
readOnly: "readOnly";
|
|
218
|
+
object: "object";
|
|
219
|
+
ref: "ref";
|
|
220
|
+
matches: "matches";
|
|
221
|
+
firstName: "firstName";
|
|
222
|
+
lastName: "lastName";
|
|
223
|
+
password: "password";
|
|
224
|
+
phone: "phone";
|
|
225
|
+
blob: "blob";
|
|
226
|
+
deprecated: "deprecated";
|
|
227
|
+
example: "example";
|
|
228
|
+
schema: "schema";
|
|
229
|
+
catchall: "catchall";
|
|
230
|
+
time: "time";
|
|
231
|
+
name: "name";
|
|
232
|
+
};
|
|
233
|
+
type SchemaKeyword = keyof SchemaKeywordMapper;
|
|
234
|
+
type SchemaMapper<T = string | null | undefined> = {
|
|
235
|
+
[K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined;
|
|
236
|
+
};
|
|
237
|
+
type SchemaKeywordBase<T> = {
|
|
238
|
+
keyword: SchemaKeyword;
|
|
239
|
+
args: T;
|
|
240
|
+
};
|
|
241
|
+
type Schema = {
|
|
242
|
+
keyword: string;
|
|
243
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
244
|
+
declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
|
|
245
|
+
|
|
246
|
+
type SchemaMethodResult<TFileMeta extends KubbFile.FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
247
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
248
|
+
oas: Oas;
|
|
249
|
+
pluginManager: PluginManager;
|
|
250
|
+
/**
|
|
251
|
+
* Current plugin
|
|
252
|
+
*/
|
|
253
|
+
plugin: Plugin<TPluginOptions>;
|
|
254
|
+
mode: KubbFile.Mode;
|
|
255
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
256
|
+
override: Array<Override<TOptions>> | undefined;
|
|
257
|
+
contentType?: contentType;
|
|
258
|
+
output?: string;
|
|
259
|
+
};
|
|
260
|
+
type SchemaGeneratorOptions = {
|
|
261
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
262
|
+
unknownType: 'any' | 'unknown';
|
|
263
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
264
|
+
enumSuffix?: string;
|
|
265
|
+
usedEnumNames?: Record<string, number>;
|
|
266
|
+
mapper?: Record<string, string>;
|
|
267
|
+
typed?: boolean;
|
|
268
|
+
transformers: {
|
|
269
|
+
/**
|
|
270
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
271
|
+
*/
|
|
272
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
273
|
+
/**
|
|
274
|
+
* Receive schema and name(propertName) and return FakerMeta array
|
|
275
|
+
* TODO TODO add docs
|
|
276
|
+
* @beta
|
|
277
|
+
*/
|
|
278
|
+
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
|
|
282
|
+
type SchemaProps = {
|
|
283
|
+
schema?: SchemaObject;
|
|
284
|
+
name?: string;
|
|
285
|
+
parentName?: string;
|
|
286
|
+
};
|
|
287
|
+
declare abstract class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
288
|
+
#private;
|
|
289
|
+
refs: Refs;
|
|
290
|
+
/**
|
|
291
|
+
* Creates a type node from a given schema.
|
|
292
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
293
|
+
* optionally adds a union with null.
|
|
294
|
+
*/
|
|
295
|
+
buildSchemas(props: SchemaProps): Schema[];
|
|
296
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(schemas: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
297
|
+
find<T extends keyof SchemaKeywordMapper>(schemas: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
298
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(schemas: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
299
|
+
static findInObject<T extends keyof SchemaKeywordMapper>(schemas: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
300
|
+
static find<T extends keyof SchemaKeywordMapper>(schemas: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
301
|
+
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
302
|
+
/**
|
|
303
|
+
* Schema
|
|
304
|
+
*/
|
|
305
|
+
abstract schema(name: string, object: SchemaObject): SchemaMethodResult<TFileMeta>;
|
|
306
|
+
/**
|
|
307
|
+
* Returns the source, in the future it will return a React component
|
|
308
|
+
*/
|
|
309
|
+
abstract getSource<TOptions extends SchemaGeneratorBuildOptions = SchemaGeneratorBuildOptions>(name: string, schemas: Schema[], options?: TOptions): string[];
|
|
310
|
+
/**
|
|
311
|
+
* @deprecated only used for testing
|
|
312
|
+
*/
|
|
313
|
+
abstract buildSource(name: string, object: SchemaObject | undefined, options?: SchemaGeneratorBuildOptions): string[];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { type SchemaGeneratorBuildOptions as S, type SchemaGeneratorOptions as a, type SchemaMethodResult as b, SchemaGenerator as c, type Schema as d, type SchemaKeyword as e, type SchemaKeywordBase as f, type SchemaKeywordMapper as g, type SchemaMapper as h, isKeyword as i, schemaKeywords as s };
|