@kubb/plugin-oas 3.16.2 → 3.16.4
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/Oas-CuqAnIw-.js +60 -0
- package/dist/Oas-CuqAnIw-.js.map +1 -0
- package/dist/Oas-Cv_pyXRM.cjs +78 -0
- package/dist/Oas-Cv_pyXRM.cjs.map +1 -0
- package/dist/OperationGenerator-CgbXErhW.d.cts +900 -0
- package/dist/OperationGenerator-OtLcGk2y.d.ts +900 -0
- package/dist/Schema-DJshqHto.d.cts +38 -0
- package/dist/Schema-DOXGUW1m.d.ts +38 -0
- package/dist/SchemaGenerator-8205BXCp.cjs +942 -0
- package/dist/SchemaGenerator-8205BXCp.cjs.map +1 -0
- package/dist/SchemaGenerator-B8Io6kky.js +930 -0
- package/dist/SchemaGenerator-B8Io6kky.js.map +1 -0
- package/dist/SchemaMapper-BaZQKrQB.js +54 -0
- package/dist/SchemaMapper-BaZQKrQB.js.map +1 -0
- package/dist/SchemaMapper-BiagBQN4.d.cts +388 -0
- package/dist/SchemaMapper-C2J2d3o4.d.ts +388 -0
- package/dist/SchemaMapper-D8J0V9Pj.cjs +66 -0
- package/dist/SchemaMapper-D8J0V9Pj.cjs.map +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +42 -35
- package/dist/components.d.ts +42 -35
- package/dist/components.js +3 -3
- package/dist/generators-BhLMlRNk.js +137 -0
- package/dist/generators-BhLMlRNk.js.map +1 -0
- package/dist/generators-DLH2kvlh.cjs +155 -0
- package/dist/generators-DLH2kvlh.cjs.map +1 -0
- package/dist/generators.cjs +4 -13
- package/dist/generators.d.cts +5 -7
- package/dist/generators.d.ts +5 -7
- package/dist/generators.js +5 -5
- package/dist/getFooter-BChY2kC1.cjs +43 -0
- package/dist/getFooter-BChY2kC1.cjs.map +1 -0
- package/dist/getFooter-T7_pZ6f8.js +31 -0
- package/dist/getFooter-T7_pZ6f8.js.map +1 -0
- package/dist/getSchemas-D8mP129c.cjs +67 -0
- package/dist/getSchemas-D8mP129c.cjs.map +1 -0
- package/dist/getSchemas-WoSBIxG8.js +55 -0
- package/dist/getSchemas-WoSBIxG8.js.map +1 -0
- package/dist/hooks.cjs +213 -195
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +91 -86
- package/dist/hooks.d.ts +91 -86
- package/dist/hooks.js +212 -193
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +280 -342
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +274 -318
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +802 -737
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +12 -11
- package/dist/mocks.d.ts +12 -11
- package/dist/mocks.js +802 -735
- package/dist/mocks.js.map +1 -1
- package/dist/parseFromConfig-CMNGsef2.cjs +33 -0
- package/dist/parseFromConfig-CMNGsef2.cjs.map +1 -0
- package/dist/parseFromConfig-yAiFK03V.js +27 -0
- package/dist/parseFromConfig-yAiFK03V.js.map +1 -0
- package/dist/utils.cjs +58 -74
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +96 -42
- package/dist/utils.d.ts +96 -42
- package/dist/utils.js +47 -46
- package/dist/utils.js.map +1 -1
- package/package.json +26 -34
- package/src/components/Operation.tsx +1 -2
- package/src/mocks/schemas.ts +39 -0
- package/src/utils/getBanner.ts +5 -5
- package/src/utils/getFooter.ts +4 -4
- package/dist/OperationGenerator-C7NPZtOM.d.ts +0 -288
- package/dist/OperationGenerator-DJE2XQ83.d.cts +0 -288
- package/dist/Schema-AjebpeVY.d.ts +0 -32
- package/dist/Schema-M6983FL1.d.cts +0 -32
- package/dist/SchemaMapper-B21ZmWag.d.cts +0 -275
- package/dist/SchemaMapper-B21ZmWag.d.ts +0 -275
- package/dist/chunk-6S7YFY6F.js +0 -33
- package/dist/chunk-6S7YFY6F.js.map +0 -1
- package/dist/chunk-76E35IZ2.js +0 -56
- package/dist/chunk-76E35IZ2.js.map +0 -1
- package/dist/chunk-7RFNM43R.cjs +0 -41
- package/dist/chunk-7RFNM43R.cjs.map +0 -1
- package/dist/chunk-DTD4ZUDA.cjs +0 -36
- package/dist/chunk-DTD4ZUDA.cjs.map +0 -1
- package/dist/chunk-G3FDK7YW.js +0 -35
- package/dist/chunk-G3FDK7YW.js.map +0 -1
- package/dist/chunk-JNN4JPWK.js +0 -28
- package/dist/chunk-JNN4JPWK.js.map +0 -1
- package/dist/chunk-MBX66JAT.js +0 -93
- package/dist/chunk-MBX66JAT.js.map +0 -1
- package/dist/chunk-NC5PWNEF.js +0 -866
- package/dist/chunk-NC5PWNEF.js.map +0 -1
- package/dist/chunk-PORSNYI5.js +0 -47
- package/dist/chunk-PORSNYI5.js.map +0 -1
- package/dist/chunk-QJMOOF2A.cjs +0 -97
- package/dist/chunk-QJMOOF2A.cjs.map +0 -1
- package/dist/chunk-RKHCI3WI.cjs +0 -1002
- package/dist/chunk-RKHCI3WI.cjs.map +0 -1
- package/dist/chunk-YWMMI3MO.cjs +0 -59
- package/dist/chunk-YWMMI3MO.cjs.map +0 -1
- package/dist/chunk-Z2NREI4X.cjs +0 -32
- package/dist/chunk-Z2NREI4X.cjs.map +0 -1
- package/dist/chunk-ZVFL3NXX.cjs +0 -50
- package/dist/chunk-ZVFL3NXX.cjs.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { Plugin, Output, Group, PluginFactoryOptions, ResolveNameParams, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
2
|
-
import { KubbFile } from '@kubb/core/fs';
|
|
3
|
-
import { HttpMethod, SchemaObject, Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import { S as Schema, d as SchemaKeywordMapper } from './SchemaMapper-B21ZmWag.js';
|
|
6
|
-
|
|
7
|
-
type ResolvePathOptions = {
|
|
8
|
-
pluginKey?: Plugin['key'];
|
|
9
|
-
group?: {
|
|
10
|
-
tag?: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
};
|
|
13
|
-
type?: ResolveNameParams['type'];
|
|
14
|
-
};
|
|
15
|
-
type API = {
|
|
16
|
-
getOas: () => Promise<Oas>;
|
|
17
|
-
getBaseURL: () => Promise<string | undefined>;
|
|
18
|
-
};
|
|
19
|
-
type Options = {
|
|
20
|
-
/**
|
|
21
|
-
* Validate your input(see kubb.config) based on '@readme/openapi-parser'.
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
validate?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Specify the export location for the files and define the behavior of the output
|
|
27
|
-
* @default { path: 'schemas', barrelType: 'named' }
|
|
28
|
-
*/
|
|
29
|
-
output?: Output<Oas>;
|
|
30
|
-
/**
|
|
31
|
-
* Group the JSON files based on the provided name.
|
|
32
|
-
*/
|
|
33
|
-
group?: Group;
|
|
34
|
-
/**
|
|
35
|
-
* Which server to use from the array of `servers.url[serverIndex]`
|
|
36
|
-
* @example
|
|
37
|
-
* - `0` will return `http://petstore.swagger.io/api`
|
|
38
|
-
* - `1` will return `http://localhost:3000`
|
|
39
|
-
*/
|
|
40
|
-
serverIndex?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Define which contentType should be used.
|
|
43
|
-
* By default, the first JSON valid mediaType will be used
|
|
44
|
-
*/
|
|
45
|
-
contentType?: contentType;
|
|
46
|
-
/**
|
|
47
|
-
* Defines how the discriminator value should be interpreted during processing.
|
|
48
|
-
*
|
|
49
|
-
* @default 'strict'
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* - `inherit`: Replaces the `oneOf` schema with the schema referenced by `discriminator.mapping[key]`.
|
|
53
|
-
* - `strict`: Uses the `oneOf` schemas as defined, without modification.
|
|
54
|
-
*
|
|
55
|
-
* @see https://github.com/kubb-labs/kubb/issues/1736
|
|
56
|
-
*/
|
|
57
|
-
discriminator?: 'strict' | 'inherit';
|
|
58
|
-
/**
|
|
59
|
-
* Override some behaviour of the Oas class instance, see '@kubb/oas'
|
|
60
|
-
*/
|
|
61
|
-
oasClass?: typeof Oas;
|
|
62
|
-
/**
|
|
63
|
-
* Define some generators next to the JSON generation
|
|
64
|
-
*/
|
|
65
|
-
generators?: Array<Generator<PluginOas>>;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
69
|
-
* @example import { Pet } from './Pet'
|
|
70
|
-
*
|
|
71
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
72
|
-
*
|
|
73
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
74
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
75
|
-
*/
|
|
76
|
-
type Ref = {
|
|
77
|
-
propertyName: string;
|
|
78
|
-
originalName: string;
|
|
79
|
-
path: KubbFile.OptionalPath;
|
|
80
|
-
pluginKey?: Plugin['key'];
|
|
81
|
-
};
|
|
82
|
-
type Refs = Record<string, Ref>;
|
|
83
|
-
type Resolver = {
|
|
84
|
-
/**
|
|
85
|
-
* Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
|
|
86
|
-
*/
|
|
87
|
-
name: string;
|
|
88
|
-
baseName: KubbFile.BaseName;
|
|
89
|
-
path: KubbFile.Path;
|
|
90
|
-
};
|
|
91
|
-
type OperationSchema = {
|
|
92
|
-
/**
|
|
93
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
94
|
-
*/
|
|
95
|
-
name: string;
|
|
96
|
-
schema: SchemaObject;
|
|
97
|
-
operation?: Operation;
|
|
98
|
-
/**
|
|
99
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
100
|
-
*/
|
|
101
|
-
operationName: string;
|
|
102
|
-
description?: string;
|
|
103
|
-
statusCode?: number;
|
|
104
|
-
keys?: string[];
|
|
105
|
-
keysToOmit?: string[];
|
|
106
|
-
withData?: boolean;
|
|
107
|
-
};
|
|
108
|
-
type OperationSchemas = {
|
|
109
|
-
pathParams?: OperationSchema & {
|
|
110
|
-
keysToOmit?: never;
|
|
111
|
-
};
|
|
112
|
-
queryParams?: OperationSchema & {
|
|
113
|
-
keysToOmit?: never;
|
|
114
|
-
};
|
|
115
|
-
headerParams?: OperationSchema & {
|
|
116
|
-
keysToOmit?: never;
|
|
117
|
-
};
|
|
118
|
-
request?: OperationSchema;
|
|
119
|
-
response: OperationSchema;
|
|
120
|
-
responses: Array<OperationSchema>;
|
|
121
|
-
statusCodes?: Array<OperationSchema>;
|
|
122
|
-
errors?: Array<OperationSchema>;
|
|
123
|
-
};
|
|
124
|
-
type ByTag = {
|
|
125
|
-
type: 'tag';
|
|
126
|
-
pattern: string | RegExp;
|
|
127
|
-
};
|
|
128
|
-
type ByOperationId = {
|
|
129
|
-
type: 'operationId';
|
|
130
|
-
pattern: string | RegExp;
|
|
131
|
-
};
|
|
132
|
-
type ByPath = {
|
|
133
|
-
type: 'path';
|
|
134
|
-
pattern: string | RegExp;
|
|
135
|
-
};
|
|
136
|
-
type ByMethod = {
|
|
137
|
-
type: 'method';
|
|
138
|
-
pattern: HttpMethod | RegExp;
|
|
139
|
-
};
|
|
140
|
-
type BySchemaName = {
|
|
141
|
-
type: 'schemaName';
|
|
142
|
-
pattern: string | RegExp;
|
|
143
|
-
};
|
|
144
|
-
type ByContentType = {
|
|
145
|
-
type: 'contentType';
|
|
146
|
-
pattern: string | RegExp;
|
|
147
|
-
};
|
|
148
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
149
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
150
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
151
|
-
options: Partial<TOptions>;
|
|
152
|
-
};
|
|
153
|
-
type ResolvedOptions = Options & {
|
|
154
|
-
output: Output<Oas>;
|
|
155
|
-
};
|
|
156
|
-
type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>;
|
|
157
|
-
|
|
158
|
-
type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
|
|
159
|
-
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
160
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
161
|
-
oas: Oas;
|
|
162
|
-
pluginManager: PluginManager;
|
|
163
|
-
/**
|
|
164
|
-
* Current plugin
|
|
165
|
-
*/
|
|
166
|
-
plugin: Plugin<TPluginOptions>;
|
|
167
|
-
mode: KubbFile.Mode;
|
|
168
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
169
|
-
override: Array<Override<TOptions>> | undefined;
|
|
170
|
-
contentType?: contentType;
|
|
171
|
-
output?: string;
|
|
172
|
-
};
|
|
173
|
-
type SchemaGeneratorOptions = {
|
|
174
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
175
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
176
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
177
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
178
|
-
enumSuffix?: string;
|
|
179
|
-
usedEnumNames?: Record<string, number>;
|
|
180
|
-
mapper?: Record<string, string>;
|
|
181
|
-
typed?: boolean;
|
|
182
|
-
transformers: {
|
|
183
|
-
/**
|
|
184
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
185
|
-
*/
|
|
186
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
187
|
-
/**
|
|
188
|
-
* Receive schema and name(propertName) and return FakerMeta array
|
|
189
|
-
* TODO TODO add docs
|
|
190
|
-
* @beta
|
|
191
|
-
*/
|
|
192
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
|
|
196
|
-
type SchemaProps$1 = {
|
|
197
|
-
schemaObject?: SchemaObject;
|
|
198
|
-
name?: string;
|
|
199
|
-
parentName?: string;
|
|
200
|
-
};
|
|
201
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
202
|
-
#private;
|
|
203
|
-
refs: Refs;
|
|
204
|
-
/**
|
|
205
|
-
* Creates a type node from a given schema.
|
|
206
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
207
|
-
* optionally adds a union with null.
|
|
208
|
-
*/
|
|
209
|
-
parse(props: SchemaProps$1): Schema[];
|
|
210
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
211
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
212
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
213
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
214
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
215
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
216
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
220
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
221
|
-
options: TOptions['resolvedOptions'];
|
|
222
|
-
operations: Array<Operation>;
|
|
223
|
-
};
|
|
224
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
225
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
226
|
-
options: TOptions['resolvedOptions'];
|
|
227
|
-
operation: Operation;
|
|
228
|
-
};
|
|
229
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
230
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
231
|
-
options: TOptions['resolvedOptions'];
|
|
232
|
-
schema: {
|
|
233
|
-
name: string;
|
|
234
|
-
tree: Array<Schema>;
|
|
235
|
-
value: SchemaObject;
|
|
236
|
-
};
|
|
237
|
-
};
|
|
238
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
239
|
-
name: string;
|
|
240
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
241
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
242
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
243
|
-
};
|
|
244
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
245
|
-
declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
|
|
246
|
-
type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
247
|
-
name: string;
|
|
248
|
-
Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
|
|
249
|
-
Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
|
|
250
|
-
Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
|
|
251
|
-
};
|
|
252
|
-
/****
|
|
253
|
-
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
254
|
-
*
|
|
255
|
-
* 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.
|
|
256
|
-
*
|
|
257
|
-
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
258
|
-
*/
|
|
259
|
-
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
|
|
260
|
-
|
|
261
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
262
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
263
|
-
oas: Oas;
|
|
264
|
-
exclude: Array<Exclude> | undefined;
|
|
265
|
-
include: Array<Include> | undefined;
|
|
266
|
-
override: Array<Override<TOptions>> | undefined;
|
|
267
|
-
contentType: contentType | undefined;
|
|
268
|
-
pluginManager: PluginManager;
|
|
269
|
-
/**
|
|
270
|
-
* Current plugin
|
|
271
|
-
*/
|
|
272
|
-
plugin: Plugin<TPluginOptions>;
|
|
273
|
-
mode: KubbFile.Mode;
|
|
274
|
-
};
|
|
275
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
276
|
-
#private;
|
|
277
|
-
getSchemas(operation: Operation, { resolveName, }?: {
|
|
278
|
-
resolveName?: (name: string) => string;
|
|
279
|
-
}): OperationSchemas;
|
|
280
|
-
getOperations(): Promise<Array<{
|
|
281
|
-
path: string;
|
|
282
|
-
method: HttpMethod;
|
|
283
|
-
operation: Operation;
|
|
284
|
-
}>>;
|
|
285
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export { type API as A, type Exclude as E, type GetSchemaGeneratorOptions as G, type Include as I, type Options as O, type PluginOas as P, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, type OperationMethodResult as a, OperationGenerator as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createGenerator as f, createReactGenerator as g, type Generator as h, type GeneratorOptions as i, type ResolvePathOptions as j, type Ref as k, type Refs as l, type Resolver as m, type OperationSchema as n, type OperationSchemas as o, type Override as p };
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { Plugin, Output, Group, PluginFactoryOptions, ResolveNameParams, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
2
|
-
import { KubbFile } from '@kubb/core/fs';
|
|
3
|
-
import { HttpMethod, SchemaObject, Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import { S as Schema, d as SchemaKeywordMapper } from './SchemaMapper-B21ZmWag.cjs';
|
|
6
|
-
|
|
7
|
-
type ResolvePathOptions = {
|
|
8
|
-
pluginKey?: Plugin['key'];
|
|
9
|
-
group?: {
|
|
10
|
-
tag?: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
};
|
|
13
|
-
type?: ResolveNameParams['type'];
|
|
14
|
-
};
|
|
15
|
-
type API = {
|
|
16
|
-
getOas: () => Promise<Oas>;
|
|
17
|
-
getBaseURL: () => Promise<string | undefined>;
|
|
18
|
-
};
|
|
19
|
-
type Options = {
|
|
20
|
-
/**
|
|
21
|
-
* Validate your input(see kubb.config) based on '@readme/openapi-parser'.
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
validate?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Specify the export location for the files and define the behavior of the output
|
|
27
|
-
* @default { path: 'schemas', barrelType: 'named' }
|
|
28
|
-
*/
|
|
29
|
-
output?: Output<Oas>;
|
|
30
|
-
/**
|
|
31
|
-
* Group the JSON files based on the provided name.
|
|
32
|
-
*/
|
|
33
|
-
group?: Group;
|
|
34
|
-
/**
|
|
35
|
-
* Which server to use from the array of `servers.url[serverIndex]`
|
|
36
|
-
* @example
|
|
37
|
-
* - `0` will return `http://petstore.swagger.io/api`
|
|
38
|
-
* - `1` will return `http://localhost:3000`
|
|
39
|
-
*/
|
|
40
|
-
serverIndex?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Define which contentType should be used.
|
|
43
|
-
* By default, the first JSON valid mediaType will be used
|
|
44
|
-
*/
|
|
45
|
-
contentType?: contentType;
|
|
46
|
-
/**
|
|
47
|
-
* Defines how the discriminator value should be interpreted during processing.
|
|
48
|
-
*
|
|
49
|
-
* @default 'strict'
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* - `inherit`: Replaces the `oneOf` schema with the schema referenced by `discriminator.mapping[key]`.
|
|
53
|
-
* - `strict`: Uses the `oneOf` schemas as defined, without modification.
|
|
54
|
-
*
|
|
55
|
-
* @see https://github.com/kubb-labs/kubb/issues/1736
|
|
56
|
-
*/
|
|
57
|
-
discriminator?: 'strict' | 'inherit';
|
|
58
|
-
/**
|
|
59
|
-
* Override some behaviour of the Oas class instance, see '@kubb/oas'
|
|
60
|
-
*/
|
|
61
|
-
oasClass?: typeof Oas;
|
|
62
|
-
/**
|
|
63
|
-
* Define some generators next to the JSON generation
|
|
64
|
-
*/
|
|
65
|
-
generators?: Array<Generator<PluginOas>>;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
69
|
-
* @example import { Pet } from './Pet'
|
|
70
|
-
*
|
|
71
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
72
|
-
*
|
|
73
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
74
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
75
|
-
*/
|
|
76
|
-
type Ref = {
|
|
77
|
-
propertyName: string;
|
|
78
|
-
originalName: string;
|
|
79
|
-
path: KubbFile.OptionalPath;
|
|
80
|
-
pluginKey?: Plugin['key'];
|
|
81
|
-
};
|
|
82
|
-
type Refs = Record<string, Ref>;
|
|
83
|
-
type Resolver = {
|
|
84
|
-
/**
|
|
85
|
-
* Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
|
|
86
|
-
*/
|
|
87
|
-
name: string;
|
|
88
|
-
baseName: KubbFile.BaseName;
|
|
89
|
-
path: KubbFile.Path;
|
|
90
|
-
};
|
|
91
|
-
type OperationSchema = {
|
|
92
|
-
/**
|
|
93
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
94
|
-
*/
|
|
95
|
-
name: string;
|
|
96
|
-
schema: SchemaObject;
|
|
97
|
-
operation?: Operation;
|
|
98
|
-
/**
|
|
99
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
100
|
-
*/
|
|
101
|
-
operationName: string;
|
|
102
|
-
description?: string;
|
|
103
|
-
statusCode?: number;
|
|
104
|
-
keys?: string[];
|
|
105
|
-
keysToOmit?: string[];
|
|
106
|
-
withData?: boolean;
|
|
107
|
-
};
|
|
108
|
-
type OperationSchemas = {
|
|
109
|
-
pathParams?: OperationSchema & {
|
|
110
|
-
keysToOmit?: never;
|
|
111
|
-
};
|
|
112
|
-
queryParams?: OperationSchema & {
|
|
113
|
-
keysToOmit?: never;
|
|
114
|
-
};
|
|
115
|
-
headerParams?: OperationSchema & {
|
|
116
|
-
keysToOmit?: never;
|
|
117
|
-
};
|
|
118
|
-
request?: OperationSchema;
|
|
119
|
-
response: OperationSchema;
|
|
120
|
-
responses: Array<OperationSchema>;
|
|
121
|
-
statusCodes?: Array<OperationSchema>;
|
|
122
|
-
errors?: Array<OperationSchema>;
|
|
123
|
-
};
|
|
124
|
-
type ByTag = {
|
|
125
|
-
type: 'tag';
|
|
126
|
-
pattern: string | RegExp;
|
|
127
|
-
};
|
|
128
|
-
type ByOperationId = {
|
|
129
|
-
type: 'operationId';
|
|
130
|
-
pattern: string | RegExp;
|
|
131
|
-
};
|
|
132
|
-
type ByPath = {
|
|
133
|
-
type: 'path';
|
|
134
|
-
pattern: string | RegExp;
|
|
135
|
-
};
|
|
136
|
-
type ByMethod = {
|
|
137
|
-
type: 'method';
|
|
138
|
-
pattern: HttpMethod | RegExp;
|
|
139
|
-
};
|
|
140
|
-
type BySchemaName = {
|
|
141
|
-
type: 'schemaName';
|
|
142
|
-
pattern: string | RegExp;
|
|
143
|
-
};
|
|
144
|
-
type ByContentType = {
|
|
145
|
-
type: 'contentType';
|
|
146
|
-
pattern: string | RegExp;
|
|
147
|
-
};
|
|
148
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
149
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
150
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
151
|
-
options: Partial<TOptions>;
|
|
152
|
-
};
|
|
153
|
-
type ResolvedOptions = Options & {
|
|
154
|
-
output: Output<Oas>;
|
|
155
|
-
};
|
|
156
|
-
type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, ResolvePathOptions>;
|
|
157
|
-
|
|
158
|
-
type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
|
|
159
|
-
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
160
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
161
|
-
oas: Oas;
|
|
162
|
-
pluginManager: PluginManager;
|
|
163
|
-
/**
|
|
164
|
-
* Current plugin
|
|
165
|
-
*/
|
|
166
|
-
plugin: Plugin<TPluginOptions>;
|
|
167
|
-
mode: KubbFile.Mode;
|
|
168
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
169
|
-
override: Array<Override<TOptions>> | undefined;
|
|
170
|
-
contentType?: contentType;
|
|
171
|
-
output?: string;
|
|
172
|
-
};
|
|
173
|
-
type SchemaGeneratorOptions = {
|
|
174
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
175
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
176
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
177
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
178
|
-
enumSuffix?: string;
|
|
179
|
-
usedEnumNames?: Record<string, number>;
|
|
180
|
-
mapper?: Record<string, string>;
|
|
181
|
-
typed?: boolean;
|
|
182
|
-
transformers: {
|
|
183
|
-
/**
|
|
184
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
185
|
-
*/
|
|
186
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
187
|
-
/**
|
|
188
|
-
* Receive schema and name(propertName) and return FakerMeta array
|
|
189
|
-
* TODO TODO add docs
|
|
190
|
-
* @beta
|
|
191
|
-
*/
|
|
192
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
|
|
196
|
-
type SchemaProps$1 = {
|
|
197
|
-
schemaObject?: SchemaObject;
|
|
198
|
-
name?: string;
|
|
199
|
-
parentName?: string;
|
|
200
|
-
};
|
|
201
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
202
|
-
#private;
|
|
203
|
-
refs: Refs;
|
|
204
|
-
/**
|
|
205
|
-
* Creates a type node from a given schema.
|
|
206
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
207
|
-
* optionally adds a union with null.
|
|
208
|
-
*/
|
|
209
|
-
parse(props: SchemaProps$1): Schema[];
|
|
210
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
211
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
212
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
213
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
214
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
215
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
216
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
220
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
221
|
-
options: TOptions['resolvedOptions'];
|
|
222
|
-
operations: Array<Operation>;
|
|
223
|
-
};
|
|
224
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
225
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
226
|
-
options: TOptions['resolvedOptions'];
|
|
227
|
-
operation: Operation;
|
|
228
|
-
};
|
|
229
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
230
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
231
|
-
options: TOptions['resolvedOptions'];
|
|
232
|
-
schema: {
|
|
233
|
-
name: string;
|
|
234
|
-
tree: Array<Schema>;
|
|
235
|
-
value: SchemaObject;
|
|
236
|
-
};
|
|
237
|
-
};
|
|
238
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
239
|
-
name: string;
|
|
240
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
241
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
242
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
243
|
-
};
|
|
244
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
245
|
-
declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
|
|
246
|
-
type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
247
|
-
name: string;
|
|
248
|
-
Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
|
|
249
|
-
Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
|
|
250
|
-
Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
|
|
251
|
-
};
|
|
252
|
-
/****
|
|
253
|
-
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
254
|
-
*
|
|
255
|
-
* 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.
|
|
256
|
-
*
|
|
257
|
-
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
258
|
-
*/
|
|
259
|
-
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
|
|
260
|
-
|
|
261
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
262
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
263
|
-
oas: Oas;
|
|
264
|
-
exclude: Array<Exclude> | undefined;
|
|
265
|
-
include: Array<Include> | undefined;
|
|
266
|
-
override: Array<Override<TOptions>> | undefined;
|
|
267
|
-
contentType: contentType | undefined;
|
|
268
|
-
pluginManager: PluginManager;
|
|
269
|
-
/**
|
|
270
|
-
* Current plugin
|
|
271
|
-
*/
|
|
272
|
-
plugin: Plugin<TPluginOptions>;
|
|
273
|
-
mode: KubbFile.Mode;
|
|
274
|
-
};
|
|
275
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
276
|
-
#private;
|
|
277
|
-
getSchemas(operation: Operation, { resolveName, }?: {
|
|
278
|
-
resolveName?: (name: string) => string;
|
|
279
|
-
}): OperationSchemas;
|
|
280
|
-
getOperations(): Promise<Array<{
|
|
281
|
-
path: string;
|
|
282
|
-
method: HttpMethod;
|
|
283
|
-
operation: Operation;
|
|
284
|
-
}>>;
|
|
285
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export { type API as A, type Exclude as E, type GetSchemaGeneratorOptions as G, type Include as I, type Options as O, type PluginOas as P, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, type OperationMethodResult as a, OperationGenerator as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createGenerator as f, createReactGenerator as g, type Generator as h, type GeneratorOptions as i, type ResolvePathOptions as j, type Ref as k, type Refs as l, type Resolver as m, type OperationSchema as n, type OperationSchemas as o, type Override as p };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { SchemaObject } from '@kubb/oas';
|
|
3
|
-
import { Key, KubbNode } from '@kubb/react/types';
|
|
4
|
-
import { S as Schema$1 } from './SchemaMapper-B21ZmWag.js';
|
|
5
|
-
|
|
6
|
-
type SchemaContextProps = {
|
|
7
|
-
name: string;
|
|
8
|
-
schemaObject?: SchemaObject;
|
|
9
|
-
tree: Array<Schema$1>;
|
|
10
|
-
};
|
|
11
|
-
type Props = {
|
|
12
|
-
key?: Key;
|
|
13
|
-
name: string;
|
|
14
|
-
schemaObject?: SchemaObject;
|
|
15
|
-
tree?: Array<Schema$1>;
|
|
16
|
-
children?: KubbNode;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Provides schema-related context to descendant components.
|
|
20
|
-
*
|
|
21
|
-
* Wraps its children with a context containing the schema name, optional schema object, and an optional schema type tree.
|
|
22
|
-
*
|
|
23
|
-
* @param name - The name of the schema.
|
|
24
|
-
* @param schemaObject - The schema object to provide in context, if available.
|
|
25
|
-
* @param tree - An array representing the schema type hierarchy.
|
|
26
|
-
*/
|
|
27
|
-
declare function Schema({ name, schemaObject, tree, children }: Props): any;
|
|
28
|
-
declare namespace Schema {
|
|
29
|
-
var Context: react.Context<SchemaContextProps>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { Schema as S, type SchemaContextProps as a };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { SchemaObject } from '@kubb/oas';
|
|
3
|
-
import { Key, KubbNode } from '@kubb/react/types';
|
|
4
|
-
import { S as Schema$1 } from './SchemaMapper-B21ZmWag.cjs';
|
|
5
|
-
|
|
6
|
-
type SchemaContextProps = {
|
|
7
|
-
name: string;
|
|
8
|
-
schemaObject?: SchemaObject;
|
|
9
|
-
tree: Array<Schema$1>;
|
|
10
|
-
};
|
|
11
|
-
type Props = {
|
|
12
|
-
key?: Key;
|
|
13
|
-
name: string;
|
|
14
|
-
schemaObject?: SchemaObject;
|
|
15
|
-
tree?: Array<Schema$1>;
|
|
16
|
-
children?: KubbNode;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Provides schema-related context to descendant components.
|
|
20
|
-
*
|
|
21
|
-
* Wraps its children with a context containing the schema name, optional schema object, and an optional schema type tree.
|
|
22
|
-
*
|
|
23
|
-
* @param name - The name of the schema.
|
|
24
|
-
* @param schemaObject - The schema object to provide in context, if available.
|
|
25
|
-
* @param tree - An array representing the schema type hierarchy.
|
|
26
|
-
*/
|
|
27
|
-
declare function Schema({ name, schemaObject, tree, children }: Props): any;
|
|
28
|
-
declare namespace Schema {
|
|
29
|
-
var Context: react.Context<SchemaContextProps>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { Schema as S, type SchemaContextProps as a };
|