@moccona/apicodegen 0.0.3 → 0.0.7
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/README.md +320 -25
- package/bin/cli.cjs +23 -0
- package/npm/index.cjs +2156 -2382
- package/npm/index.cjs.map +1 -1
- package/npm/index.d.cts +608 -408
- package/npm/index.d.cts.map +1 -0
- package/npm/index.d.mts +736 -0
- package/npm/index.d.mts.map +1 -0
- package/npm/index.mjs +2137 -0
- package/npm/index.mjs.map +1 -0
- package/npm/vite/index.d.mts +39 -0
- package/npm/vite/index.d.mts.map +1 -0
- package/npm/vite/index.mjs +2049 -0
- package/npm/vite/index.mjs.map +1 -0
- package/package.json +42 -25
- package/bin/cli.js +0 -2248
- package/npm/index.d.ts +0 -536
- package/npm/index.js +0 -2367
- package/npm/index.js.map +0 -1
- package/npm/vite/index.d.ts +0 -29
- package/npm/vite/index.js +0 -2276
- package/npm/vite/index.js.map +0 -1
package/npm/index.d.cts
CHANGED
|
@@ -1,328 +1,314 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ServerOptions, PluginOption } from 'vite';
|
|
1
|
+
import { Block, Node, ParameterDeclaration, Statement, TypeNode } from "typescript";
|
|
2
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
3
|
+
import { PluginOption } from "vite";
|
|
5
4
|
|
|
5
|
+
//#region src/core/interface.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Simple represenration for JSON object
|
|
8
8
|
*/
|
|
9
9
|
type JSONValue = {
|
|
10
|
-
|
|
10
|
+
[K: string]: string | number | boolean | JSONValue | (string | number | boolean | JSONValue)[];
|
|
11
11
|
};
|
|
12
12
|
declare enum SchemaType {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
schemas = "schemas",
|
|
14
|
+
parameters = "parameters",
|
|
15
|
+
responses = "responses",
|
|
16
|
+
requestBodies = "requestBodies"
|
|
17
17
|
}
|
|
18
18
|
declare enum NonArraySchemaType {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
object = "object",
|
|
20
|
+
string = "string",
|
|
21
|
+
number = "number",
|
|
22
|
+
boolean = "boolean",
|
|
23
|
+
integer = "integer",
|
|
24
|
+
enum = "enum",
|
|
25
|
+
file = "file"
|
|
26
26
|
}
|
|
27
27
|
declare enum ArraySchemaType {
|
|
28
|
-
|
|
28
|
+
array = "array"
|
|
29
29
|
}
|
|
30
30
|
declare enum SchemaFormatType {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
string = "string",
|
|
32
|
+
number = "number",
|
|
33
|
+
boolean = "boolean",
|
|
34
|
+
file = "file",
|
|
35
|
+
binary = "binary",
|
|
36
|
+
blob = "blob"
|
|
37
37
|
}
|
|
38
38
|
declare enum ParameterIn {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
header = "header",
|
|
40
|
+
body = "body",
|
|
41
|
+
query = "query",
|
|
42
|
+
cookie = "cookie",
|
|
43
|
+
path = "path",
|
|
44
|
+
formData = "formData"
|
|
45
45
|
}
|
|
46
46
|
interface ReferenceObject {
|
|
47
|
-
|
|
47
|
+
$ref: string;
|
|
48
48
|
}
|
|
49
49
|
interface EnumSchemaObject {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
name: string;
|
|
51
|
+
enum: (string | number)[];
|
|
52
52
|
}
|
|
53
53
|
interface SingleTypeSchemaObject {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
type: keyof typeof NonArraySchemaType | string;
|
|
55
|
+
description?: string;
|
|
56
|
+
allOf?: SchemaObject[];
|
|
57
|
+
anyOf?: SchemaObject[];
|
|
58
|
+
deprecated?: boolean;
|
|
59
|
+
enum?: (string | number)[];
|
|
60
|
+
format?: keyof typeof SchemaFormatType;
|
|
61
|
+
oneOf?: SchemaObject[];
|
|
62
|
+
properties?: Record<string, SchemaObject>;
|
|
63
|
+
readonly?: boolean;
|
|
64
|
+
required?: string[] | boolean;
|
|
65
|
+
ref?: string;
|
|
66
|
+
isRef?: boolean;
|
|
66
67
|
}
|
|
67
68
|
interface ArrayTypeSchemaObject {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
type: keyof typeof ArraySchemaType;
|
|
70
|
+
items?: SchemaObject;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
description?: string;
|
|
73
|
+
ref?: string;
|
|
73
74
|
}
|
|
74
75
|
type SchemaObject = SingleTypeSchemaObject | ArrayTypeSchemaObject;
|
|
75
76
|
type ParameterObject = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
name: string;
|
|
78
|
+
in: keyof typeof ParameterIn;
|
|
79
|
+
schema?: SchemaObject;
|
|
80
|
+
required?: boolean;
|
|
81
|
+
description?: string;
|
|
82
|
+
deprecated?: boolean;
|
|
83
|
+
ref?: string;
|
|
83
84
|
};
|
|
84
85
|
declare enum MediaTypes {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
JSON = "application/json",
|
|
87
|
+
TEXT = "text",
|
|
88
|
+
IMAGE = "image",
|
|
89
|
+
AUDIO = "audio",
|
|
90
|
+
VIDEO = "video"
|
|
90
91
|
}
|
|
91
92
|
type MediaTypeObject = {
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
type: MediaTypes | keyof typeof MediaTypes;
|
|
94
|
+
schema?: SchemaObject;
|
|
94
95
|
};
|
|
95
96
|
type ResponsesObject = Record<string, MediaTypeObject[]>;
|
|
96
97
|
type RequestBodyObject = ResponsesObject;
|
|
97
98
|
declare enum HttpMethods {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
GET = "get",
|
|
100
|
+
PUT = "put",
|
|
101
|
+
POST = "post",
|
|
102
|
+
DELETE = "delete",
|
|
103
|
+
OPTIONS = "options",
|
|
104
|
+
HEAD = "head",
|
|
105
|
+
PATCH = "patch",
|
|
106
|
+
TRACE = "trace"
|
|
106
107
|
}
|
|
107
108
|
type OperationObject = {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
method: string;
|
|
110
|
+
summary?: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
operationId?: string;
|
|
113
|
+
externalDocs?: {
|
|
114
|
+
url: string;
|
|
110
115
|
description?: string;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
parameters?: ParameterObject[];
|
|
117
|
-
requestBody?: MediaTypeObject[];
|
|
118
|
-
responses: MediaTypeObject[];
|
|
119
|
-
deprecated?: boolean;
|
|
116
|
+
}[];
|
|
117
|
+
parameters?: ParameterObject[];
|
|
118
|
+
requestBody?: MediaTypeObject[];
|
|
119
|
+
responses: MediaTypeObject[];
|
|
120
|
+
deprecated?: boolean;
|
|
120
121
|
};
|
|
121
122
|
type PathObject = {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
ref?: string;
|
|
124
|
+
summary?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
parameters?: ParameterObject[];
|
|
126
127
|
} & Partial<Record<HttpMethods, OperationObject>>;
|
|
127
128
|
type PathsObject = Record<string, OperationObject[]>;
|
|
128
129
|
type FetchDocRequestInit = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
method?: string;
|
|
131
|
+
body?: string | FormData;
|
|
132
|
+
headers?: Record<string, string>;
|
|
132
133
|
};
|
|
133
134
|
declare enum Adaptors {
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
fetch = "fetch",
|
|
136
|
+
axios = "axios"
|
|
136
137
|
}
|
|
137
138
|
type ProviderInitOptions = {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
docURL: string;
|
|
140
|
+
output: string;
|
|
141
|
+
baseURL?: string;
|
|
142
|
+
importClientSource?: string;
|
|
143
|
+
requestOptions?: FetchDocRequestInit;
|
|
144
|
+
verbose?: boolean;
|
|
145
|
+
adaptor?: keyof typeof Adaptors;
|
|
145
146
|
};
|
|
146
147
|
interface ProviderInitResult {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
readonly enums: EnumSchemaObject[];
|
|
149
|
+
readonly schemas: Record<string, SchemaObject>;
|
|
150
|
+
readonly parameters: Record<string, ParameterObject>;
|
|
151
|
+
readonly responses: Record<string, ResponsesObject>;
|
|
152
|
+
readonly requestBodies: Record<string, RequestBodyObject>;
|
|
153
|
+
readonly apis: PathsObject;
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
* @file Adapter abstract class definition
|
|
157
|
-
* @author wp.l
|
|
158
|
-
* @description Base adapter implementation for various code generation tools
|
|
159
|
-
*/
|
|
160
|
-
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/core/base/Adaptor.d.ts
|
|
161
157
|
/**
|
|
162
158
|
* Base adapter for tool
|
|
163
159
|
* This abstract class serves as the foundation for implementing adapters for different code generation tools
|
|
164
160
|
*/
|
|
165
161
|
declare abstract class Adapter {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
162
|
+
/**
|
|
163
|
+
* @abstract The unique name/identifier for this adapter implementation
|
|
164
|
+
*/
|
|
165
|
+
abstract readonly name: string;
|
|
166
|
+
/**
|
|
167
|
+
* @abstract The name of the field used to specify the HTTP method in API calls
|
|
168
|
+
*/
|
|
169
|
+
abstract readonly methodFieldName: string;
|
|
170
|
+
/**
|
|
171
|
+
* @abstract The name of the field used to specify the request body in API calls
|
|
172
|
+
*/
|
|
173
|
+
abstract readonly bodyFieldName: string;
|
|
174
|
+
/**
|
|
175
|
+
* @abstract The name of the field used to specify request headers in API calls
|
|
176
|
+
*/
|
|
177
|
+
abstract readonly headersFieldName: string;
|
|
178
|
+
/**
|
|
179
|
+
* @abstract The name of the field used to specify query parameters in API calls
|
|
180
|
+
*/
|
|
181
|
+
abstract readonly queryFieldName: string;
|
|
182
|
+
/**
|
|
183
|
+
* @abstract
|
|
184
|
+
* @param {string} uri - The API endpoint URI
|
|
185
|
+
* @param {string} method - The HTTP method (e.g., GET, POST, etc.)
|
|
186
|
+
* @param {ParameterObject[]} parameters - An array of parameters for the API call
|
|
187
|
+
* @param {MediaTypeObject | undefined} requestBody - The request body payload (if applicable)
|
|
188
|
+
* @param {MediaTypeObject | undefined} response - The expected response format (if applicable)
|
|
189
|
+
* @param {Adapter} adapter - An instance of the adapter being used
|
|
190
|
+
* @param {boolean} useFormData - Flag indicating whether to use FormData for the request body
|
|
191
|
+
* @param {boolean} useJSONResponse - Flag indicating whether the response should be parsed as JSON
|
|
192
|
+
* @returns {Statement[]} An array of TypeScript AST statements representing the generated code
|
|
193
|
+
*/
|
|
194
|
+
abstract client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, useFormData: boolean, useJSONResponse: boolean): Statement[];
|
|
199
195
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
* @file Base class implementation
|
|
203
|
-
* @author wp.l
|
|
204
|
-
* @description Base utility class providing common methods for code generation and API handling
|
|
205
|
-
*/
|
|
206
|
-
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/core/base/Base.d.ts
|
|
207
198
|
/**
|
|
208
199
|
* Represents success HTTP status codes.
|
|
209
200
|
* Each key is a string representation of a success HTTP status code.
|
|
210
201
|
*/
|
|
211
202
|
declare const SuccessHttpStatusCode: {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
203
|
+
'200': string;
|
|
204
|
+
'201': string;
|
|
205
|
+
'202': string;
|
|
206
|
+
'203': string;
|
|
207
|
+
'204': string;
|
|
208
|
+
'205': string;
|
|
209
|
+
'206': string;
|
|
210
|
+
'207': string;
|
|
211
|
+
'208': string;
|
|
212
|
+
'226': string;
|
|
222
213
|
};
|
|
223
214
|
/**
|
|
224
215
|
* Base abstract class providing common utility methods.
|
|
225
216
|
*/
|
|
226
217
|
declare abstract class Base {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
218
|
+
protected constructor();
|
|
219
|
+
/**
|
|
220
|
+
* Converts a reference string to a meaningful name.
|
|
221
|
+
* @param ref - The reference string to process.
|
|
222
|
+
* @param [doc] - Optional document reference for context.
|
|
223
|
+
* @returns - The processed name.
|
|
224
|
+
*/
|
|
225
|
+
static ref2name(ref: string, doc?: any): string;
|
|
226
|
+
/**
|
|
227
|
+
* Converts an API path to a function name.
|
|
228
|
+
* @param path - The API endpoint path.
|
|
229
|
+
* @param [method] - The HTTP method (e.g., GET, POST).
|
|
230
|
+
* @param [operationId] - Unique identifier for the operation.
|
|
231
|
+
* @returns - The generated function name.
|
|
232
|
+
*/
|
|
233
|
+
static pathToFnName(path: string, method?: string, _operationId?: string): string;
|
|
234
|
+
/**
|
|
235
|
+
* Normalizes a string by replacing special characters and avoiding TypeScript keywords.
|
|
236
|
+
* @param text - Input text to normalize.
|
|
237
|
+
* @returns - The normalized string.
|
|
238
|
+
*/
|
|
239
|
+
static normalize(text: string): string;
|
|
240
|
+
/**
|
|
241
|
+
* Capitalizes the first character of a string.
|
|
242
|
+
* @param text - Input string.
|
|
243
|
+
* @returns - Capitalized string.
|
|
244
|
+
*/
|
|
245
|
+
static capitalize(text: string): string;
|
|
246
|
+
/**
|
|
247
|
+
* Converts a string to camelCase.
|
|
248
|
+
* @param text - Input string.
|
|
249
|
+
* @returns - CamelCase string.
|
|
250
|
+
*/
|
|
251
|
+
static camelCase(text: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* Converts a string to UpperCamelCase.
|
|
254
|
+
* @param text - Input string.
|
|
255
|
+
* @returns - UpperCamelCase string.
|
|
256
|
+
*/
|
|
257
|
+
static upperCamelCase(text: string): string;
|
|
258
|
+
/**
|
|
259
|
+
* Fetches documentation from a given URL.
|
|
260
|
+
* @param url - The URL to fetch the documentation from.
|
|
261
|
+
* @param requestInit - Additional request parameters.
|
|
262
|
+
* @returns - A promise resolving to the fetched documentation data.
|
|
263
|
+
*/
|
|
264
|
+
static fetchDoc<T = unknown>(url: string, requestInit?: FetchDocRequestInit): Promise<T>;
|
|
265
|
+
/**
|
|
266
|
+
* Determines the media type from a given media type string.
|
|
267
|
+
* @param mediaType - The media type string to evaluate.
|
|
268
|
+
* @returns - The matched MediaTypes or null.
|
|
269
|
+
*/
|
|
270
|
+
static getMediaType(mediaType: string): MediaTypes | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* Checks if a schema is a valid enum type that isn't boolean.
|
|
273
|
+
* @param a - The schema object to evaluate.
|
|
274
|
+
* @returns - True if the schema is a valid non-boolean enum.
|
|
275
|
+
*/
|
|
276
|
+
static isValidEnumType(a: SchemaObject): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Checks if a schema represents a boolean enum.
|
|
279
|
+
* @param a - The schema object to evaluate.
|
|
280
|
+
* @returns - True if the schema is a boolean enum.
|
|
281
|
+
*/
|
|
282
|
+
static isBooleanEnum(a: SchemaObject): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Checks if two enum schemas are identical.
|
|
285
|
+
* @param a - First enum schema to compare.
|
|
286
|
+
* @param b - Second enum schema to compare.
|
|
287
|
+
* @returns - True if the enums are identical.
|
|
288
|
+
*/
|
|
289
|
+
private static isSameEnum;
|
|
290
|
+
/**
|
|
291
|
+
* Filters out duplicate enum schemas from an array.
|
|
292
|
+
* @param enums - Array of enum schemas to process.
|
|
293
|
+
* @returns - Array of unique enum schemas.
|
|
294
|
+
*/
|
|
295
|
+
static uniqueEnums(enums: EnumSchemaObject[]): EnumSchemaObject[];
|
|
296
|
+
/**
|
|
297
|
+
* Finds the first occurrence of a matching enum schema in an array.
|
|
298
|
+
* @param a - The enum schema to find.
|
|
299
|
+
* @param enums - Array of enum schemas to search.
|
|
300
|
+
* @returns - The found schema or undefined.
|
|
301
|
+
*/
|
|
302
|
+
static findSameSchema(a: EnumSchemaObject, enums: EnumSchemaObject[]): EnumSchemaObject | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Checks if an object is a reference object.
|
|
305
|
+
* @param schema - The object to check.
|
|
306
|
+
* @returns - True if the object is a reference.
|
|
307
|
+
*/
|
|
308
|
+
static isRef(schema: unknown): schema is ReferenceObject;
|
|
318
309
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
* @file Base class implementation
|
|
322
|
-
* @author wp.l
|
|
323
|
-
* @description This file defines the `Provider` abstract class, which serves as a base for providers responsible for parsing and processing API documentation.
|
|
324
|
-
*/
|
|
325
|
-
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/core/base/Provider.d.ts
|
|
326
312
|
/**
|
|
327
313
|
* Abstract Provider Class.
|
|
328
314
|
*
|
|
@@ -356,181 +342,395 @@ declare abstract class Base {
|
|
|
356
342
|
* ```
|
|
357
343
|
*/
|
|
358
344
|
declare abstract class Provider implements ProviderInitResult, ProviderInitOptions {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
345
|
+
/** collection of enum schemas */
|
|
346
|
+
readonly enums: EnumSchemaObject[];
|
|
347
|
+
/** collection of schemas indexed by name */
|
|
348
|
+
readonly schemas: Record<string, SchemaObject>;
|
|
349
|
+
/** collection of parameters indexed by name */
|
|
350
|
+
readonly parameters: Record<string, ParameterObject>;
|
|
351
|
+
/** collection of API responses indexed by name */
|
|
352
|
+
readonly responses: Record<string, ResponsesObject>;
|
|
353
|
+
/** collection of request bodies indexed by name */
|
|
354
|
+
readonly requestBodies: Record<string, RequestBodyObject>;
|
|
355
|
+
/** collection of API endpoints (operations) indexed by path */
|
|
356
|
+
readonly apis: Record<string, OperationObject[]>;
|
|
357
|
+
/** URL for fetching API documentation */
|
|
358
|
+
readonly docURL: string;
|
|
359
|
+
/** base URL for API endpoints */
|
|
360
|
+
readonly baseURL: string;
|
|
361
|
+
/** output directory for generated code */
|
|
362
|
+
readonly output: string;
|
|
363
|
+
/** request options for API documentation fetch */
|
|
364
|
+
readonly requestOptions: FetchDocRequestInit;
|
|
365
|
+
/** source path for imported client */
|
|
366
|
+
readonly importClientSource: string;
|
|
367
|
+
/**
|
|
368
|
+
* Provider Constructor.
|
|
369
|
+
* @param {ProviderInitOptions} initOptions - Initial configuration for the provider.
|
|
370
|
+
* @param {unknown} doc - Raw API documentation data to be parsed.
|
|
371
|
+
*/
|
|
372
|
+
constructor(initOptions: ProviderInitOptions, doc: unknown);
|
|
373
|
+
/**
|
|
374
|
+
* Abstract Parse Method.
|
|
375
|
+
* @abstract
|
|
376
|
+
* @param {unknown} doc - Raw API documentation data.
|
|
377
|
+
* @returns {ProviderInitResult} - Parsed documentation data.
|
|
378
|
+
*
|
|
379
|
+
* This method must be implemented by subclasses to parse the raw documentation into structured data.
|
|
380
|
+
*/
|
|
381
|
+
abstract parse(doc: unknown): ProviderInitResult;
|
|
396
382
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
* File containing the implementation of the AxiosAdapter class.
|
|
400
|
-
* This adapter is responsible for generating code that uses the Axios HTTP client library.
|
|
401
|
-
*/
|
|
402
|
-
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/core/client/axios.d.ts
|
|
403
385
|
/**
|
|
404
386
|
* Adapter class implementing support for generating code that makes use of the Axios HTTP client library.
|
|
405
387
|
* This class defines custom behavior and field mappings specific to the Axios client.
|
|
406
388
|
*/
|
|
407
389
|
declare class AxiosAdapter extends Adapter {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
390
|
+
/**
|
|
391
|
+
* Name of the field used to specify the HTTP method in the request configuration.
|
|
392
|
+
*/
|
|
393
|
+
readonly methodFieldName = "method";
|
|
394
|
+
/**
|
|
395
|
+
* Name of the field used to specify the request body (data) in the request configuration.
|
|
396
|
+
*/
|
|
397
|
+
readonly bodyFieldName = "data";
|
|
398
|
+
/**
|
|
399
|
+
* Name of the field used to specify the request headers in the request configuration.
|
|
400
|
+
*/
|
|
401
|
+
readonly headersFieldName = "headers";
|
|
402
|
+
/**
|
|
403
|
+
* Name of the field used to specify the query parameters in the request configuration.
|
|
404
|
+
*/
|
|
405
|
+
readonly queryFieldName = "params";
|
|
406
|
+
/**
|
|
407
|
+
* The name of the client this adapter is configured for, which is 'axios' in this case.
|
|
408
|
+
*/
|
|
409
|
+
readonly name = "axios";
|
|
410
|
+
/**
|
|
411
|
+
* Method that should generate and return the client-specific configuration statements.
|
|
412
|
+
*
|
|
413
|
+
* @returns {Statement[]} An array of TypeScript statements that define the client configuration.
|
|
414
|
+
*
|
|
415
|
+
* @throws {Error} Indicates that the method is not yet implemented and needs to be filled in.
|
|
416
|
+
*/
|
|
417
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, shouldUseFormData: boolean): Statement[];
|
|
436
418
|
}
|
|
437
|
-
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/core/client/fetch.d.ts
|
|
438
421
|
/**
|
|
439
422
|
* FetchAdapter is an adapter class that generates client-side fetch requests.
|
|
440
423
|
* It handles parameters, headers, and request bodies to construct proper fetch calls.
|
|
441
424
|
*/
|
|
442
425
|
declare class FetchAdapter extends Adapter {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
426
|
+
readonly methodFieldName = "method";
|
|
427
|
+
readonly bodyFieldName = "body";
|
|
428
|
+
readonly headersFieldName = "headers";
|
|
429
|
+
readonly queryFieldName = "";
|
|
430
|
+
readonly name = "fetch";
|
|
431
|
+
/**
|
|
432
|
+
* Generates client code for making API requests using the Fetch API.
|
|
433
|
+
* @param uri - The API endpoint URI
|
|
434
|
+
* @param method - The HTTP method (GET, POST, etc.)
|
|
435
|
+
* @param parameters - Array of parameters to include in the request
|
|
436
|
+
* @param requestBody - The request body media type definition
|
|
437
|
+
* @param response - The response media type definition
|
|
438
|
+
* @param adapter - The adapter instance
|
|
439
|
+
* @param shouldUseFormData - Flag to use FormData for the request body
|
|
440
|
+
* @param shouldUseJSONResponse - Flag to use JSON parsing for the response
|
|
441
|
+
* @return - An array of generated TypeScript statements
|
|
442
|
+
*/
|
|
443
|
+
client(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter, shouldUseFormData: boolean, shouldUseJSONResponse: boolean): Statement[];
|
|
461
444
|
}
|
|
462
|
-
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/core/config.d.ts
|
|
447
|
+
/**
|
|
448
|
+
* Adaptor type for HTTP client
|
|
449
|
+
*/
|
|
450
|
+
type ConfigAdaptor = keyof typeof Adaptors;
|
|
451
|
+
/**
|
|
452
|
+
* Shared config interface for CLI and Vite plugin
|
|
453
|
+
*/
|
|
454
|
+
interface ApicodegenConfig {
|
|
455
|
+
/** OpenAPI spec file path or URL (required) */
|
|
456
|
+
spec: string;
|
|
457
|
+
/** Output file path */
|
|
458
|
+
output: string;
|
|
459
|
+
/** HTTP client adaptor (fetch|axios) */
|
|
460
|
+
adaptor?: ConfigAdaptor;
|
|
461
|
+
/** Base URL for API endpoints */
|
|
462
|
+
baseURL?: string;
|
|
463
|
+
/** Custom client import source path */
|
|
464
|
+
importClientSource?: string;
|
|
465
|
+
/** Enable verbose logging */
|
|
466
|
+
verbose?: boolean;
|
|
467
|
+
/** Run type check after generation (default: true) */
|
|
468
|
+
typeCheck?: boolean;
|
|
469
|
+
/** Watch for file changes */
|
|
470
|
+
watch?: boolean;
|
|
471
|
+
/** Request options for fetching spec */
|
|
472
|
+
requestOptions?: FetchDocRequestInit;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Options for loading config
|
|
476
|
+
*/
|
|
477
|
+
interface LoadConfigOptions {
|
|
478
|
+
/** Explicit config file path */
|
|
479
|
+
configFile?: string;
|
|
480
|
+
/** Config file directory (defaults to cwd) */
|
|
481
|
+
cwd?: string;
|
|
482
|
+
/** CLI overrides */
|
|
483
|
+
cliOptions?: Partial<ApicodegenConfig>;
|
|
484
|
+
/** Vite plugin options (for name metadata) */
|
|
485
|
+
name?: string;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Result of config loading
|
|
489
|
+
*/
|
|
490
|
+
interface ResolvedConfig extends ApicodegenConfig {
|
|
491
|
+
/** Config file path if loaded from file */
|
|
492
|
+
configFilePath?: string;
|
|
493
|
+
/** Config name for logging */
|
|
494
|
+
name: string;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Load and resolve config from multiple sources
|
|
498
|
+
*/
|
|
499
|
+
declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
500
|
+
/**
|
|
501
|
+
* Create CLI options from config for commander
|
|
502
|
+
*/
|
|
503
|
+
declare function configToCLIOptions(config: ApicodegenConfig): Record<string, unknown>;
|
|
504
|
+
/**
|
|
505
|
+
* Convert resolved config to provider options format
|
|
506
|
+
*/
|
|
507
|
+
declare function toProviderOptions(config: ResolvedConfig): {
|
|
508
|
+
docURL: string;
|
|
509
|
+
output: string;
|
|
510
|
+
adaptor: "fetch" | "axios" | undefined;
|
|
511
|
+
baseURL: string | undefined;
|
|
512
|
+
importClientSource: string | undefined;
|
|
513
|
+
verbose: boolean | undefined;
|
|
514
|
+
requestOptions: FetchDocRequestInit | undefined;
|
|
515
|
+
};
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/core/errors.d.ts
|
|
518
|
+
/**
|
|
519
|
+
* Error handling utilities for api-codegen
|
|
520
|
+
*/
|
|
521
|
+
declare const ErrorCodes: {
|
|
522
|
+
readonly SPEC_NOT_FOUND: "E_SPEC_NOT_FOUND";
|
|
523
|
+
readonly SPEC_FETCH_FAILED: "E_SPEC_FETCH_FAILED";
|
|
524
|
+
readonly SPEC_PARSE_FAILED: "E_SPEC_PARSE_FAILED";
|
|
525
|
+
readonly OUTPUT_DIR_MISSING: "E_OUTPUT_DIR_MISSING";
|
|
526
|
+
readonly CONFIG_INVALID: "E_CONFIG_INVALID";
|
|
527
|
+
readonly VALIDATION_FAILED: "E_VALIDATION_FAILED";
|
|
528
|
+
readonly GENERATION_FAILED: "E_GENERATION_FAILED";
|
|
529
|
+
readonly TYPE_CHECK_FAILED: "E_TYPE_CHECK_FAILED";
|
|
530
|
+
};
|
|
531
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
532
|
+
/**
|
|
533
|
+
* Error context for ApicodegenError
|
|
534
|
+
*/
|
|
535
|
+
interface ApicodegenErrorContext {
|
|
536
|
+
/** Error code */
|
|
537
|
+
code: ErrorCode;
|
|
538
|
+
/** Human readable message */
|
|
539
|
+
message: string;
|
|
540
|
+
/** File/URL related to error */
|
|
541
|
+
location?: string;
|
|
542
|
+
/** Line number if applicable */
|
|
543
|
+
line?: number;
|
|
544
|
+
/** Column number if applicable */
|
|
545
|
+
column?: number;
|
|
546
|
+
/** Related schema/path if applicable */
|
|
547
|
+
path?: string;
|
|
548
|
+
/** Suggested fixes */
|
|
549
|
+
suggestions?: string[];
|
|
550
|
+
/** Original error */
|
|
551
|
+
cause?: Error;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Custom error class for api-codegen with rich context
|
|
555
|
+
*/
|
|
556
|
+
declare class ApicodegenError extends Error {
|
|
557
|
+
readonly code: ErrorCode;
|
|
558
|
+
readonly location?: string;
|
|
559
|
+
readonly line?: number;
|
|
560
|
+
readonly column?: number;
|
|
561
|
+
readonly path?: string;
|
|
562
|
+
readonly suggestions: string[];
|
|
563
|
+
readonly cause?: Error;
|
|
564
|
+
constructor(context: ApicodegenErrorContext);
|
|
565
|
+
/**
|
|
566
|
+
* Convert error to formatted string for CLI output
|
|
567
|
+
*/
|
|
568
|
+
toString(verbose?: boolean): string;
|
|
569
|
+
/**
|
|
570
|
+
* Convert to JSON-serializable object
|
|
571
|
+
*/
|
|
572
|
+
toJSON(): object;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* ANSI color codes for terminal output
|
|
576
|
+
*/
|
|
577
|
+
declare const Colors: {
|
|
578
|
+
readonly reset: "\u001B[0m";
|
|
579
|
+
readonly bold: "\u001B[1m";
|
|
580
|
+
readonly red: "\u001B[31m";
|
|
581
|
+
readonly green: "\u001B[32m";
|
|
582
|
+
readonly yellow: "\u001B[33m";
|
|
583
|
+
readonly blue: "\u001B[34m";
|
|
584
|
+
readonly cyan: "\u001B[36m";
|
|
585
|
+
readonly gray: "\u001B[90m";
|
|
586
|
+
readonly brightRed: "\u001B[91m";
|
|
587
|
+
readonly brightGreen: "\u001B[92m";
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* Format error for CLI output
|
|
591
|
+
*/
|
|
592
|
+
declare function formatError(error: unknown, verbose?: boolean): string;
|
|
593
|
+
/**
|
|
594
|
+
* Print error to console with formatting
|
|
595
|
+
*/
|
|
596
|
+
declare function printError(error: unknown, verbose?: boolean, stream?: NodeJS.WriteStream): void;
|
|
597
|
+
/**
|
|
598
|
+
* Create error with common patterns
|
|
599
|
+
*/
|
|
600
|
+
declare const createErrors: {
|
|
601
|
+
specNotFound(path: string, cause?: Error): ApicodegenError;
|
|
602
|
+
specFetchFailed(url: string, statusCode?: number, cause?: Error): ApicodegenError;
|
|
603
|
+
specParseFailed(path: string, line?: number, column?: number, cause?: Error): ApicodegenError;
|
|
604
|
+
outputDirMissing(path: string, cause?: Error): ApicodegenError;
|
|
605
|
+
configInvalid(path: string, cause?: Error): ApicodegenError;
|
|
606
|
+
validationFailed(path: string, details: string, cause?: Error): ApicodegenError;
|
|
607
|
+
generationFailed(cause?: Error): ApicodegenError;
|
|
608
|
+
typeCheckFailed(path: string, _errors: string[], cause?: Error): ApicodegenError;
|
|
609
|
+
missingRequiredField(field: string, context?: string): ApicodegenError;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Wrap unknown error in ApicodegenError if needed
|
|
613
|
+
*/
|
|
614
|
+
declare function wrapError(error: unknown, context?: Partial<ApicodegenErrorContext>): ApicodegenError;
|
|
615
|
+
/**
|
|
616
|
+
* Check if error is an ApicodegenError
|
|
617
|
+
*/
|
|
618
|
+
declare function isApicodegenError(error: unknown): error is ApicodegenError;
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/core/generator/index.d.ts
|
|
463
621
|
/**
|
|
464
622
|
* Represents a comment object with optional tag and message.
|
|
465
623
|
*/
|
|
466
624
|
type CommentObject = {
|
|
467
|
-
|
|
468
|
-
|
|
625
|
+
tag?: 'deprecated' | 'param' | 'returns';
|
|
626
|
+
comment: string;
|
|
627
|
+
paramName?: string;
|
|
628
|
+
type?: string;
|
|
469
629
|
};
|
|
470
630
|
/**
|
|
471
631
|
* Array of comment objects to be added to the code.
|
|
472
632
|
*/
|
|
473
633
|
type Comments = CommentObject[];
|
|
474
634
|
declare class Generator {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
635
|
+
/**
|
|
636
|
+
* Converts an array of TypeScript statements into a formatted string of code.
|
|
637
|
+
*
|
|
638
|
+
* @param statements - The array of TypeScript statement nodes.
|
|
639
|
+
* @returns Formatted code as a string.
|
|
640
|
+
* @throws {Error} If no valid statements are provided.
|
|
641
|
+
*/
|
|
642
|
+
static toCode(statements: Statement[]): string;
|
|
643
|
+
static write(code: string, filepath: string): Promise<void>;
|
|
644
|
+
/**
|
|
645
|
+
* Converts a path string with parameters into a TypeScript template expression.
|
|
646
|
+
* Handles query parameters and path placeholders.
|
|
647
|
+
*
|
|
648
|
+
* @param path - The base path string containing placeholders.
|
|
649
|
+
* @param parameters - Array of parameter objects defining the parameters.
|
|
650
|
+
* @param basePath - Optional base path to prepend (default: "").
|
|
651
|
+
* @returns A TypeScript template expressi
|
|
652
|
+
*/
|
|
653
|
+
static toUrlTemplate(path: string, parameters: ParameterObject[], basePath?: string): import("typescript").NoSubstitutionTemplateLiteral | import("typescript").TemplateExpression;
|
|
654
|
+
/**
|
|
655
|
+
* Adds synthetic comments to a TypeScript AST node.
|
|
656
|
+
*
|
|
657
|
+
* @param node - The target AST node.
|
|
658
|
+
* @param comments - Array of comment objects to add.
|
|
659
|
+
*/
|
|
660
|
+
static addComments(node: Node, comments: Comments): void;
|
|
661
|
+
/**
|
|
662
|
+
* Checks if a schema represents a binary type.
|
|
663
|
+
*
|
|
664
|
+
* @param schema - The schema object to check.
|
|
665
|
+
* @returns true if the schema is a binary type, false otherwise.
|
|
666
|
+
*/
|
|
667
|
+
static isBinarySchema(schema: SchemaObject): boolean;
|
|
668
|
+
static schemaToTypeString(schema: SchemaObject): string;
|
|
669
|
+
static generateParamTags(parameters: ParameterObject[], requestBody?: MediaTypeObject): CommentObject[];
|
|
670
|
+
static toRequestBodyTypeNode(schema: SchemaObject): ParameterDeclaration;
|
|
671
|
+
static toTypeNode(schema: SchemaObject): TypeNode;
|
|
672
|
+
static toDeclarationNodes(parameters: ParameterObject[]): ParameterDeclaration[];
|
|
673
|
+
static toFormDataStatement(parameters: ParameterObject[], requestBody?: SchemaObject): Statement[];
|
|
674
|
+
static bodyBlock(uri: string, method: string, parameters: ParameterObject[], requestBody: MediaTypeObject | undefined, response: MediaTypeObject | undefined, adapter: Adapter): Block;
|
|
675
|
+
static schemaToStatemets(parsedDoc: ProviderInitResult, adaptor: Adapter, options: Omit<ProviderInitOptions, 'docURL' | 'output' | 'requestOptions'>): Statement[];
|
|
676
|
+
static prettier(code: string): Promise<string>;
|
|
677
|
+
static genCode(schema: ProviderInitResult, initOptions: ProviderInitOptions, adaptor: Adapter): Promise<string>;
|
|
516
678
|
}
|
|
517
|
-
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/openapi/index.d.ts
|
|
518
681
|
declare enum OpenAPIVersion {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
682
|
+
v2 = "v2",
|
|
683
|
+
v3 = "v3",
|
|
684
|
+
v3_1 = "v3_1",
|
|
685
|
+
unknown = "unknown"
|
|
523
686
|
}
|
|
524
687
|
declare class OpenAPIProvider extends Provider {
|
|
525
|
-
|
|
688
|
+
parse(doc: OpenAPIV3.Document): ProviderInitResult;
|
|
526
689
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
690
|
+
interface CodeGenResult {
|
|
691
|
+
code: string;
|
|
692
|
+
stats: {
|
|
693
|
+
endpoints: number;
|
|
694
|
+
schemas: number;
|
|
695
|
+
duration: number;
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
declare function codeGen(initOptions: ProviderInitOptions): Promise<CodeGenResult>;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/vite-plugin/index.d.ts
|
|
701
|
+
type ApiCodeGenPluginOptions = {
|
|
702
|
+
/** Human-readable name for this API config (required) */name: string; /** OpenAPI spec file path or URL */
|
|
703
|
+
spec?: string; /** Output file path */
|
|
704
|
+
output?: string; /** HTTP client adaptor */
|
|
705
|
+
adaptor?: 'fetch' | 'axios'; /** Base URL for API endpoints */
|
|
706
|
+
baseURL?: string; /** Custom client import source path */
|
|
707
|
+
importClientSource?: string; /** Enable verbose logging */
|
|
708
|
+
verbose?: boolean; /** Run type check after generation (default: true) */
|
|
709
|
+
typeCheck?: boolean;
|
|
532
710
|
};
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Main Vite plugin function
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```ts
|
|
716
|
+
* // vite.config.ts
|
|
717
|
+
* import { apiCodeGenPlugin } from '@moccona/apicodegen/vite';
|
|
718
|
+
*
|
|
719
|
+
* export default defineConfig({
|
|
720
|
+
* plugins: [
|
|
721
|
+
* apiCodeGenPlugin([
|
|
722
|
+
* {
|
|
723
|
+
* name: 'my-api',
|
|
724
|
+
* spec: './openapi.json',
|
|
725
|
+
* output: './src/api/generated.ts',
|
|
726
|
+
* baseURL: 'https://api.example.com',
|
|
727
|
+
* },
|
|
728
|
+
* ]),
|
|
729
|
+
* ],
|
|
730
|
+
* });
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
733
|
+
declare function apiCodeGenPlugin(options: ApiCodeGenPluginOptions[]): PluginOption;
|
|
734
|
+
//#endregion
|
|
735
|
+
export { Adapter, Adaptors, ApiCodeGenPluginOptions, ApicodegenConfig, ApicodegenError, ApicodegenErrorContext, ArraySchemaType, ArrayTypeSchemaObject, AxiosAdapter, Base, CodeGenResult, Colors, CommentObject, Comments, ConfigAdaptor, EnumSchemaObject, ErrorCode, ErrorCodes, FetchAdapter, FetchDocRequestInit, Generator, HttpMethods, JSONValue, LoadConfigOptions, MediaTypeObject, MediaTypes, NonArraySchemaType, OpenAPIProvider, OpenAPIVersion, OperationObject, ParameterIn, ParameterObject, PathObject, PathsObject, Provider, ProviderInitOptions, ProviderInitResult, ReferenceObject, RequestBodyObject, ResolvedConfig, ResponsesObject, SchemaFormatType, SchemaObject, SchemaType, SingleTypeSchemaObject, SuccessHttpStatusCode, apiCodeGenPlugin, codeGen, configToCLIOptions, createErrors, formatError, isApicodegenError, loadConfig, printError, toProviderOptions, wrapError };
|
|
736
|
+
//# sourceMappingURL=index.d.cts.map
|