swagger-typescript-api 13.2.17 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{generate-templates-BO-5CKCm.mjs → generate-templates-BaT2BiRR.mjs} +553 -146
- package/dist/generate-templates-BaT2BiRR.mjs.map +1 -0
- package/dist/{generate-templates-wjE78AWV.cjs → generate-templates-BlSkwa8l.cjs} +518 -109
- package/dist/generate-templates-BlSkwa8l.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +213 -182
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +213 -182
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -10
- package/templates/base/data-contract-jsdoc.ejs +16 -16
- package/templates/base/object-field-jsdoc.ejs +8 -8
- package/templates/base/route-docs.ejs +13 -7
- package/templates/default/api.ejs +11 -11
- package/dist/generate-templates-BO-5CKCm.mjs.map +0 -1
- package/dist/generate-templates-wjE78AWV.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_generate_templates = require('./generate-templates-
|
|
2
|
+
const require_generate_templates = require('./generate-templates-BlSkwa8l.cjs');
|
|
3
3
|
let consola = require("consola");
|
|
4
4
|
|
|
5
5
|
//#region src/index.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { OpenAPI } from "openapi-types";
|
|
2
2
|
import * as typescript from "typescript";
|
|
3
|
+
import { resolve } from "@apidevtools/swagger-parser";
|
|
3
4
|
import * as es_toolkit_compat0 from "es-toolkit/compat";
|
|
4
5
|
import { camelCase } from "es-toolkit/compat";
|
|
6
|
+
import { AnyObject, Maybe, Primitive } from "yummies/types";
|
|
5
7
|
import * as swagger_schema_official0 from "swagger-schema-official";
|
|
6
8
|
import * as es_toolkit0 from "es-toolkit";
|
|
7
9
|
import * as eta from "eta";
|
|
10
|
+
import { PartialDeep } from "type-fest";
|
|
8
11
|
|
|
9
12
|
//#region \0rolldown/runtime.js
|
|
10
13
|
//#endregion
|
|
11
14
|
//#region src/schema-components-map.d.ts
|
|
12
15
|
declare class SchemaComponentsMap {
|
|
13
|
-
_data: SchemaComponent[];
|
|
14
16
|
config: CodeGenConfig;
|
|
17
|
+
_data: SchemaComponent[];
|
|
15
18
|
constructor(config: CodeGenConfig);
|
|
16
19
|
clear(): void;
|
|
17
20
|
createRef: (paths: string[]) => string;
|
|
18
21
|
parseRef: (ref: string) => string[];
|
|
19
|
-
|
|
22
|
+
private createComponentDraft;
|
|
23
|
+
createComponent($ref: string, rawTypeData: SchemaComponent["rawTypeData"] | SchemaComponent, addAtStart?: boolean): SchemaComponent;
|
|
20
24
|
getComponents(): SchemaComponent[];
|
|
21
25
|
filter(...componentNames: (string[] | string)[]): SchemaComponent[];
|
|
22
26
|
get: ($ref: string) => SchemaComponent | null;
|
|
@@ -24,85 +28,6 @@ declare class SchemaComponentsMap {
|
|
|
24
28
|
discriminatorsFirst(): void;
|
|
25
29
|
}
|
|
26
30
|
//#endregion
|
|
27
|
-
//#region src/util/file-system.d.ts
|
|
28
|
-
declare class FileSystem {
|
|
29
|
-
getFileContent: (path: string) => string;
|
|
30
|
-
readDir: (path: string) => string[];
|
|
31
|
-
pathIsDir: (path: string) => boolean;
|
|
32
|
-
cropExtension: (fileName: string) => string;
|
|
33
|
-
removeDir: (path: string) => void;
|
|
34
|
-
createDir: (path: string) => void;
|
|
35
|
-
cleanDir: (path: string) => void;
|
|
36
|
-
pathIsExist: (path: string) => boolean;
|
|
37
|
-
createFile: ({
|
|
38
|
-
path: path_,
|
|
39
|
-
fileName,
|
|
40
|
-
content,
|
|
41
|
-
withPrefix
|
|
42
|
-
}: {
|
|
43
|
-
path: any;
|
|
44
|
-
fileName: any;
|
|
45
|
-
content: any;
|
|
46
|
-
withPrefix: any;
|
|
47
|
-
}) => void;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/util/request.d.ts
|
|
51
|
-
declare class Request {
|
|
52
|
-
config: CodeGenConfig;
|
|
53
|
-
constructor(config: CodeGenConfig);
|
|
54
|
-
download({
|
|
55
|
-
url,
|
|
56
|
-
authToken,
|
|
57
|
-
...options
|
|
58
|
-
}: {
|
|
59
|
-
url: string;
|
|
60
|
-
authToken?: string;
|
|
61
|
-
options?: Partial<RequestInit>;
|
|
62
|
-
}): Promise<string>;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/swagger-schema-resolver.d.ts
|
|
66
|
-
declare class SwaggerSchemaResolver {
|
|
67
|
-
config: CodeGenConfig;
|
|
68
|
-
fileSystem: FileSystem;
|
|
69
|
-
request: Request;
|
|
70
|
-
constructor(config: CodeGenConfig, fileSystem: FileSystem);
|
|
71
|
-
create(): Promise<{
|
|
72
|
-
usageSchema: OpenAPI.Document;
|
|
73
|
-
originalSchema: OpenAPI.Document;
|
|
74
|
-
}>;
|
|
75
|
-
convertSwaggerObject(swaggerSchema: OpenAPI.Document, converterOptions: {
|
|
76
|
-
patch?: boolean;
|
|
77
|
-
}): Promise<{
|
|
78
|
-
usageSchema: OpenAPI.Document;
|
|
79
|
-
originalSchema: OpenAPI.Document;
|
|
80
|
-
}>;
|
|
81
|
-
getSwaggerSchemaByPath: (pathToSwagger: string) => string;
|
|
82
|
-
fetchSwaggerSchemaFile(pathToSwagger: string, urlToSwagger: string, authToken?: string): Promise<string>;
|
|
83
|
-
processSwaggerSchemaFile(file: string): any;
|
|
84
|
-
fixSwaggerSchema({
|
|
85
|
-
usageSchema,
|
|
86
|
-
originalSchema
|
|
87
|
-
}: {
|
|
88
|
-
usageSchema: any;
|
|
89
|
-
originalSchema: any;
|
|
90
|
-
}): void;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/schema-walker.d.ts
|
|
94
|
-
declare class SchemaWalker {
|
|
95
|
-
config: CodeGenConfig;
|
|
96
|
-
swaggerSchemaResolver: SwaggerSchemaResolver;
|
|
97
|
-
schemas: Map<string, OpenAPI.Document<{}>>;
|
|
98
|
-
caches: Map<string, OpenAPI.Document<{}>>;
|
|
99
|
-
constructor(config: CodeGenConfig, swaggerSchemaResolver: SwaggerSchemaResolver);
|
|
100
|
-
addSchema: (name: string, schema: OpenAPI.Document) => void;
|
|
101
|
-
_isLocalRef: (ref: string) => boolean;
|
|
102
|
-
_isRemoteRef: (ref: string) => boolean;
|
|
103
|
-
_getRefDataFromSchema: (schema: Record<string, unknown>, ref: string) => any;
|
|
104
|
-
}
|
|
105
|
-
//#endregion
|
|
106
31
|
//#region src/type-name-formatter.d.ts
|
|
107
32
|
type FormattingSchemaType = "enum-key" | "type-name";
|
|
108
33
|
declare class TypeNameFormatter {
|
|
@@ -123,18 +48,7 @@ declare class SchemaUtils {
|
|
|
123
48
|
config: CodeGenConfig;
|
|
124
49
|
schemaComponentsMap: SchemaComponentsMap;
|
|
125
50
|
typeNameFormatter: TypeNameFormatter;
|
|
126
|
-
|
|
127
|
-
constructor({
|
|
128
|
-
config,
|
|
129
|
-
schemaComponentsMap,
|
|
130
|
-
typeNameFormatter,
|
|
131
|
-
schemaWalker
|
|
132
|
-
}: {
|
|
133
|
-
config: any;
|
|
134
|
-
schemaComponentsMap: any;
|
|
135
|
-
typeNameFormatter: any;
|
|
136
|
-
schemaWalker: any;
|
|
137
|
-
});
|
|
51
|
+
constructor(config: CodeGenConfig, schemaComponentsMap: SchemaComponentsMap, typeNameFormatter: TypeNameFormatter);
|
|
138
52
|
getRequiredProperties: (schema: any) => unknown[];
|
|
139
53
|
isRefSchema: (schema: any) => boolean;
|
|
140
54
|
getEnumNames: (schema: any) => any;
|
|
@@ -167,26 +81,6 @@ declare class SchemaUtils {
|
|
|
167
81
|
formatJsValue: (value: any) => string;
|
|
168
82
|
}
|
|
169
83
|
//#endregion
|
|
170
|
-
//#region src/schema-parser/schema-formatters.d.ts
|
|
171
|
-
declare class SchemaFormatters {
|
|
172
|
-
config: CodeGenConfig;
|
|
173
|
-
templatesWorker: TemplatesWorker;
|
|
174
|
-
schemaUtils: SchemaUtils;
|
|
175
|
-
constructor(schemaParser: SchemaParser | SchemaParserFabric);
|
|
176
|
-
base: {
|
|
177
|
-
enum: (parsedSchema: any) => any;
|
|
178
|
-
object: (parsedSchema: any) => any;
|
|
179
|
-
primitive: (parsedSchema: any) => any;
|
|
180
|
-
};
|
|
181
|
-
inline: {
|
|
182
|
-
enum: (parsedSchema: any) => any;
|
|
183
|
-
object: (parsedSchema: any) => any;
|
|
184
|
-
};
|
|
185
|
-
formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
|
|
186
|
-
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
187
|
-
formatObjectContent: (content: any) => string;
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
84
|
//#region src/schema-parser/schema-parser-fabric.d.ts
|
|
191
85
|
declare class SchemaParserFabric {
|
|
192
86
|
config: CodeGenConfig;
|
|
@@ -195,17 +89,12 @@ declare class SchemaParserFabric {
|
|
|
195
89
|
schemaFormatters: SchemaFormatters;
|
|
196
90
|
templatesWorker: TemplatesWorker;
|
|
197
91
|
schemaUtils: SchemaUtils;
|
|
198
|
-
|
|
199
|
-
constructor(config: CodeGenConfig, templatesWorker: TemplatesWorker, schemaComponentsMap: SchemaComponentsMap, typeNameFormatter: TypeNameFormatter, schemaWalker: SchemaWalker);
|
|
92
|
+
constructor(config: CodeGenConfig, templatesWorker: TemplatesWorker, schemaComponentsMap: SchemaComponentsMap, typeNameFormatter: TypeNameFormatter);
|
|
200
93
|
createSchemaParser: ({
|
|
201
94
|
schema,
|
|
202
95
|
typeName,
|
|
203
96
|
schemaPath
|
|
204
|
-
}:
|
|
205
|
-
schema: any;
|
|
206
|
-
typeName: any;
|
|
207
|
-
schemaPath: any;
|
|
208
|
-
}) => SchemaParser;
|
|
97
|
+
}: SchemaParserConfig) => SchemaParser;
|
|
209
98
|
createSchema: ({
|
|
210
99
|
content,
|
|
211
100
|
linkedSchema,
|
|
@@ -213,41 +102,121 @@ declare class SchemaParserFabric {
|
|
|
213
102
|
schemaPath,
|
|
214
103
|
...otherSchemaProps
|
|
215
104
|
}: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
105
|
+
content: unknown;
|
|
106
|
+
linkedSchema?: Record<string, unknown>;
|
|
107
|
+
linkedComponent?: SchemaComponent;
|
|
108
|
+
schemaPath?: string[];
|
|
109
|
+
[key: string]: unknown;
|
|
221
110
|
}) => any;
|
|
222
111
|
createParsedComponent: ({
|
|
223
112
|
typeName,
|
|
224
113
|
schema,
|
|
225
114
|
schemaPath
|
|
226
|
-
}: {
|
|
227
|
-
typeName:
|
|
228
|
-
schema: any;
|
|
229
|
-
schemaPath: any;
|
|
115
|
+
}: Required<SchemaParserConfig> & {
|
|
116
|
+
typeName: string;
|
|
230
117
|
}) => SchemaComponent;
|
|
231
|
-
parseSchema: (schema:
|
|
232
|
-
getInlineParseContent: (schema:
|
|
233
|
-
getParseContent: (schema:
|
|
118
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
119
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
120
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/schema-parser/schema-formatters.d.ts
|
|
124
|
+
declare class SchemaFormatters {
|
|
125
|
+
config: CodeGenConfig;
|
|
126
|
+
templatesWorker: TemplatesWorker;
|
|
127
|
+
schemaUtils: SchemaUtils;
|
|
128
|
+
constructor(schemaParser: SchemaParser | SchemaParserFabric);
|
|
129
|
+
base: {
|
|
130
|
+
enum: (parsedSchema: any) => any;
|
|
131
|
+
object: (parsedSchema: any) => any;
|
|
132
|
+
primitive: (parsedSchema: any) => any;
|
|
133
|
+
};
|
|
134
|
+
inline: {
|
|
135
|
+
enum: (parsedSchema: any) => any;
|
|
136
|
+
object: (parsedSchema: any) => any;
|
|
137
|
+
};
|
|
138
|
+
formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
|
|
139
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
140
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
141
|
+
formatObjectContent: (content: any) => string;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/schema-parser/mono-schema-parser.d.ts
|
|
145
|
+
interface SchemaParserConfig {
|
|
146
|
+
typeName?: string | null;
|
|
147
|
+
schema?: any;
|
|
148
|
+
schemaPath?: string[];
|
|
149
|
+
}
|
|
150
|
+
declare class MonoSchemaParser {
|
|
151
|
+
schema: any;
|
|
152
|
+
typeName: string | null;
|
|
153
|
+
schemaPath: string[];
|
|
154
|
+
schemaParser: SchemaParser;
|
|
155
|
+
schemaParserFabric: SchemaParserFabric;
|
|
156
|
+
typeNameFormatter: TypeNameFormatter;
|
|
157
|
+
schemaComponentsMap: SchemaComponentsMap;
|
|
158
|
+
schemaUtils: SchemaUtils;
|
|
159
|
+
config: CodeGenConfig;
|
|
160
|
+
schemaFormatters: SchemaFormatters;
|
|
161
|
+
constructor(schemaParser: SchemaParser, schema: unknown, typeName?: string | null, schemaPath?: string[]);
|
|
162
|
+
parse(): void;
|
|
163
|
+
buildTypeNameFromPath: () => Capitalize<string> | null;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/resolved-swagger-schema.d.ts
|
|
167
|
+
interface RefDetails {
|
|
168
|
+
ref: string;
|
|
169
|
+
isLocal: boolean;
|
|
170
|
+
externalUrlOrPath: Maybe<string>;
|
|
171
|
+
externalOpenapiFileName?: string;
|
|
172
|
+
}
|
|
173
|
+
declare class ResolvedSwaggerSchema {
|
|
174
|
+
private config;
|
|
175
|
+
usageSchema: OpenAPI.Document;
|
|
176
|
+
originalSchema: OpenAPI.Document;
|
|
177
|
+
private resolvers;
|
|
178
|
+
private parsedRefsCache;
|
|
179
|
+
private externalSchemaCache;
|
|
180
|
+
private httpMethodSegments;
|
|
181
|
+
private normalizeRef;
|
|
182
|
+
private createEscapedPathsRefVariant;
|
|
183
|
+
private isHttpUrl;
|
|
184
|
+
private getRemoteRequestHeaders;
|
|
185
|
+
private stripHash;
|
|
186
|
+
private extractRefsFromSchema;
|
|
187
|
+
private fetchRemoteSchemaDocument;
|
|
188
|
+
private warmUpRemoteSchemasCache;
|
|
189
|
+
private collectRemoteAbsoluteRefCandidates;
|
|
190
|
+
private resolveFromRemoteSchemaCache;
|
|
191
|
+
private constructor();
|
|
192
|
+
getRefDetails(ref: string): RefDetails;
|
|
193
|
+
isLocalRef(ref: string): boolean;
|
|
194
|
+
getRef(ref: Maybe<string>): Maybe<AnyObject | Primitive>;
|
|
195
|
+
private tryToResolveRef;
|
|
196
|
+
private readExternalSchema;
|
|
197
|
+
private resolveJsonPointer;
|
|
198
|
+
private absolutizeLocalRefs;
|
|
199
|
+
private normalizeResolvedExternalSchemaRef;
|
|
200
|
+
private collectExternalRefCandidates;
|
|
201
|
+
private tryToResolveRefFromFile;
|
|
202
|
+
static create(config: CodeGenConfig, usageSchema: OpenAPI.Document, originalSchema: OpenAPI.Document): Promise<ResolvedSwaggerSchema>;
|
|
234
203
|
}
|
|
235
204
|
//#endregion
|
|
236
205
|
//#region src/schema-routes/schema-routes.d.ts
|
|
237
206
|
declare class SchemaRoutes {
|
|
238
207
|
config: CodeGenConfig;
|
|
239
208
|
schemaParserFabric: SchemaParserFabric;
|
|
240
|
-
schemaUtils: SchemaUtils;
|
|
241
|
-
typeNameFormatter: TypeNameFormatter;
|
|
242
209
|
schemaComponentsMap: SchemaComponentsMap;
|
|
243
210
|
templatesWorker: TemplatesWorker;
|
|
211
|
+
typeNameFormatter: TypeNameFormatter;
|
|
212
|
+
schemaUtils: SchemaUtils;
|
|
244
213
|
FORM_DATA_TYPES: string[];
|
|
245
214
|
routes: ParsedRoute[];
|
|
246
215
|
hasSecurityRoutes: boolean;
|
|
247
216
|
hasQueryRoutes: boolean;
|
|
248
217
|
hasFormDataRoutes: boolean;
|
|
249
218
|
constructor(config: CodeGenConfig, schemaParserFabric: SchemaParserFabric, schemaComponentsMap: SchemaComponentsMap, templatesWorker: TemplatesWorker, typeNameFormatter: TypeNameFormatter);
|
|
250
|
-
createRequestsMap: (routesByMethod: any) => {};
|
|
219
|
+
createRequestsMap: (resolvedSwaggerSchema: ResolvedSwaggerSchema, routesByMethod: any) => {};
|
|
251
220
|
parseRouteName: (rawRoute: any) => {
|
|
252
221
|
originalRoute: any;
|
|
253
222
|
route: any;
|
|
@@ -283,16 +252,20 @@ declare class SchemaRoutes {
|
|
|
283
252
|
requestInfos,
|
|
284
253
|
parsedSchemas,
|
|
285
254
|
operationId,
|
|
286
|
-
defaultType
|
|
255
|
+
defaultType,
|
|
256
|
+
resolvedSwaggerSchema
|
|
287
257
|
}: {
|
|
288
258
|
requestInfos: any;
|
|
289
259
|
parsedSchemas: any;
|
|
290
260
|
operationId: any;
|
|
291
261
|
defaultType: any;
|
|
262
|
+
resolvedSwaggerSchema: any;
|
|
292
263
|
}) => any[];
|
|
293
|
-
|
|
264
|
+
getRouteLinksFromResponse: (resolvedSwaggerSchema: ResolvedSwaggerSchema, responseInfo: AnyObject, status: string) => RouteLinkInfo[];
|
|
265
|
+
getResponseBodyInfo: (routeInfo: any, parsedSchemas: any, resolvedSwaggerSchema: any) => {
|
|
294
266
|
contentTypes: any[];
|
|
295
267
|
responses: any[];
|
|
268
|
+
links: any[];
|
|
296
269
|
success: {
|
|
297
270
|
schema: any;
|
|
298
271
|
type: any;
|
|
@@ -323,14 +296,8 @@ declare class SchemaRoutes {
|
|
|
323
296
|
extractResponseBodyIfItNeeded: (routeInfo: any, responseBodyInfo: any, routeName: any) => void;
|
|
324
297
|
extractResponseErrorIfItNeeded: (routeInfo: any, responseBodyInfo: any, routeName: any) => void;
|
|
325
298
|
getRouteName: (rawRouteInfo: any) => RouteNameInfo;
|
|
326
|
-
parseRouteInfo: (rawRouteName: any, routeInfo: any, method: any,
|
|
327
|
-
attachSchema: (
|
|
328
|
-
usageSchema,
|
|
329
|
-
parsedSchemas
|
|
330
|
-
}: {
|
|
331
|
-
usageSchema: any;
|
|
332
|
-
parsedSchemas: any;
|
|
333
|
-
}) => void;
|
|
299
|
+
parseRouteInfo: (rawRouteName: any, routeInfo: any, method: any, resolvedSwaggerSchema: ResolvedSwaggerSchema, parsedSchemas: any) => ParsedRoute;
|
|
300
|
+
attachSchema: (resolvedSwaggerSchema: ResolvedSwaggerSchema, parsedSchemas: ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>[]) => void;
|
|
334
301
|
getGroupedRoutes: () => {
|
|
335
302
|
outOfModule: ParsedRoute[];
|
|
336
303
|
combined?: {
|
|
@@ -341,6 +308,66 @@ declare class SchemaRoutes {
|
|
|
341
308
|
sortRoutes: (routes: ParsedRoute[]) => ParsedRoute[];
|
|
342
309
|
}
|
|
343
310
|
//#endregion
|
|
311
|
+
//#region src/util/file-system.d.ts
|
|
312
|
+
declare class FileSystem {
|
|
313
|
+
getFileContent: (path: string) => string;
|
|
314
|
+
readDir: (path: string) => string[];
|
|
315
|
+
pathIsDir: (path: string) => boolean;
|
|
316
|
+
cropExtension: (fileName: string) => string;
|
|
317
|
+
removeDir: (path: string) => void;
|
|
318
|
+
createDir: (path: string) => void;
|
|
319
|
+
cleanDir: (path: string) => void;
|
|
320
|
+
pathIsExist: (path: string) => boolean;
|
|
321
|
+
createFile: ({
|
|
322
|
+
path: path_,
|
|
323
|
+
fileName,
|
|
324
|
+
content,
|
|
325
|
+
withPrefix
|
|
326
|
+
}: {
|
|
327
|
+
path: any;
|
|
328
|
+
fileName: any;
|
|
329
|
+
content: any;
|
|
330
|
+
withPrefix: any;
|
|
331
|
+
}) => void;
|
|
332
|
+
}
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/util/request.d.ts
|
|
335
|
+
declare class Request {
|
|
336
|
+
config: CodeGenConfig;
|
|
337
|
+
constructor(config: CodeGenConfig);
|
|
338
|
+
download({
|
|
339
|
+
url,
|
|
340
|
+
authToken,
|
|
341
|
+
...options
|
|
342
|
+
}: {
|
|
343
|
+
url: string;
|
|
344
|
+
authToken?: string;
|
|
345
|
+
options?: Partial<RequestInit>;
|
|
346
|
+
}): Promise<string>;
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/swagger-schema-resolver.d.ts
|
|
350
|
+
interface SwaggerSchemas {
|
|
351
|
+
usageSchema: OpenAPI.Document;
|
|
352
|
+
originalSchema: OpenAPI.Document;
|
|
353
|
+
}
|
|
354
|
+
declare class SwaggerSchemaResolver {
|
|
355
|
+
config: CodeGenConfig;
|
|
356
|
+
fileSystem: FileSystem;
|
|
357
|
+
request: Request;
|
|
358
|
+
constructor(config: CodeGenConfig, fileSystem: FileSystem);
|
|
359
|
+
create(): Promise<ResolvedSwaggerSchema>;
|
|
360
|
+
convertSwaggerObject(swaggerSchema: OpenAPI.Document, converterOptions: {
|
|
361
|
+
patch?: boolean;
|
|
362
|
+
}): Promise<SwaggerSchemas>;
|
|
363
|
+
getSwaggerSchemaByPath: (pathToSwagger: string) => string;
|
|
364
|
+
fetchSwaggerSchemaFile(pathToSwagger: string, urlToSwagger: string, authToken?: string): Promise<string>;
|
|
365
|
+
processSwaggerSchemaFile(file: string): any;
|
|
366
|
+
private normalizeRefValue;
|
|
367
|
+
private normalizeRefsInSchema;
|
|
368
|
+
private fixSwaggerSchemas;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
344
371
|
//#region src/translators/javascript.d.ts
|
|
345
372
|
declare class JavascriptTranslator extends Translator {
|
|
346
373
|
compileTSCode: (input: TranslatorIO) => Record<string, string>;
|
|
@@ -378,8 +405,8 @@ declare class CodeGenProcess {
|
|
|
378
405
|
fileSystem: FileSystem;
|
|
379
406
|
codeFormatter: CodeFormatter;
|
|
380
407
|
templatesWorker: TemplatesWorker;
|
|
381
|
-
schemaWalker: SchemaWalker;
|
|
382
408
|
javascriptTranslator: JavascriptTranslator;
|
|
409
|
+
swaggerRefs: Awaited<ReturnType<typeof resolve>> | undefined | null;
|
|
383
410
|
constructor(config: Partial<GenerateApiConfiguration["config"]>);
|
|
384
411
|
start(): Promise<{
|
|
385
412
|
files: TranslatorIO[];
|
|
@@ -463,13 +490,14 @@ declare class CodeGenProcess {
|
|
|
463
490
|
Tuple: (values: unknown[]) => string;
|
|
464
491
|
};
|
|
465
492
|
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
493
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
466
494
|
internalCase: typeof camelCase;
|
|
467
495
|
classNameCase: typeof pascalCase;
|
|
468
496
|
pascalCase: typeof pascalCase;
|
|
469
|
-
getInlineParseContent: (schema:
|
|
470
|
-
getParseContent: (schema:
|
|
497
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
498
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
471
499
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
472
|
-
parseSchema: (schema:
|
|
500
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
473
501
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
474
502
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
475
503
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -568,13 +596,14 @@ declare class CodeGenProcess {
|
|
|
568
596
|
Tuple: (values: unknown[]) => string;
|
|
569
597
|
};
|
|
570
598
|
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
599
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
571
600
|
internalCase: typeof camelCase;
|
|
572
601
|
classNameCase: typeof pascalCase;
|
|
573
602
|
pascalCase: typeof pascalCase;
|
|
574
|
-
getInlineParseContent: (schema:
|
|
575
|
-
getParseContent: (schema:
|
|
603
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
604
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
576
605
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
577
|
-
parseSchema: (schema:
|
|
606
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
578
607
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
579
608
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
580
609
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -653,15 +682,18 @@ declare class SchemaParser {
|
|
|
653
682
|
schemaFormatters: SchemaFormatters;
|
|
654
683
|
schemaUtils: SchemaUtils;
|
|
655
684
|
templatesWorker: TemplatesWorker;
|
|
656
|
-
|
|
657
|
-
typeName: any;
|
|
685
|
+
typeName: string | null;
|
|
658
686
|
schema: any;
|
|
659
|
-
schemaPath:
|
|
660
|
-
constructor(schemaParserFabric:
|
|
687
|
+
schemaPath: string[];
|
|
688
|
+
constructor(schemaParserFabric: SchemaParserFabric, {
|
|
661
689
|
typeName,
|
|
662
690
|
schema,
|
|
663
691
|
schemaPath
|
|
664
|
-
}?: {
|
|
692
|
+
}?: {
|
|
693
|
+
typeName?: string | null;
|
|
694
|
+
schema?: any;
|
|
695
|
+
schemaPath?: string[];
|
|
696
|
+
});
|
|
665
697
|
_complexSchemaParsers: {
|
|
666
698
|
oneOf: (schema: any) => any;
|
|
667
699
|
allOf: (schema: any) => any;
|
|
@@ -719,23 +751,6 @@ declare const SCHEMA_TYPES$1: {
|
|
|
719
751
|
readonly COMPLEX_UNKNOWN: "__unknown";
|
|
720
752
|
};
|
|
721
753
|
//#endregion
|
|
722
|
-
//#region src/schema-parser/mono-schema-parser.d.ts
|
|
723
|
-
declare class MonoSchemaParser {
|
|
724
|
-
schema: any;
|
|
725
|
-
typeName: any;
|
|
726
|
-
schemaPath: never[];
|
|
727
|
-
schemaParser: SchemaParser;
|
|
728
|
-
schemaParserFabric: SchemaParserFabric;
|
|
729
|
-
typeNameFormatter: TypeNameFormatter;
|
|
730
|
-
schemaComponentsMap: SchemaComponentsMap;
|
|
731
|
-
schemaUtils: SchemaUtils;
|
|
732
|
-
config: CodeGenConfig;
|
|
733
|
-
schemaFormatters: SchemaFormatters;
|
|
734
|
-
constructor(schemaParser: SchemaParser, schema: any, typeName?: null, schemaPath?: never[]);
|
|
735
|
-
parse(): void;
|
|
736
|
-
buildTypeNameFromPath: () => Capitalize<string> | null;
|
|
737
|
-
}
|
|
738
|
-
//#endregion
|
|
739
754
|
//#region types/index.d.ts
|
|
740
755
|
type HttpClientType = (typeof HTTP_CLIENT)[keyof typeof HTTP_CLIENT];
|
|
741
756
|
type CodeGenConstruct = {
|
|
@@ -849,6 +864,8 @@ interface Hooks {
|
|
|
849
864
|
onFormatTypeName?: (typeName: string, rawTypeName?: string, schemaType?: "type-name" | "enum-key") => string | undefined;
|
|
850
865
|
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
|
|
851
866
|
onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
|
|
867
|
+
onFormatExternalTypeName?: (typeName: string, refInfo: RefDetails) => string | undefined;
|
|
868
|
+
onFixDuplicateExternalTypeName?: (typeName: string, refInfo: RefDetails, existedTypeNames: string[]) => string | undefined;
|
|
852
869
|
}
|
|
853
870
|
type RouteNameRouteInfo = Record<string, unknown>;
|
|
854
871
|
type RouteNameInfo = {
|
|
@@ -934,6 +951,14 @@ interface RequestResponseInfo {
|
|
|
934
951
|
description: string;
|
|
935
952
|
status: string | number;
|
|
936
953
|
isSuccess: boolean;
|
|
954
|
+
links?: RouteLinkInfo[];
|
|
955
|
+
}
|
|
956
|
+
interface RouteLinkInfo {
|
|
957
|
+
status: string | number;
|
|
958
|
+
name: string;
|
|
959
|
+
operationId?: string;
|
|
960
|
+
operationRef?: string;
|
|
961
|
+
parameters?: Record<string, string>;
|
|
937
962
|
}
|
|
938
963
|
type RawRouteInfo = {
|
|
939
964
|
operationId: string;
|
|
@@ -941,6 +966,7 @@ type RawRouteInfo = {
|
|
|
941
966
|
route: string;
|
|
942
967
|
moduleName: string;
|
|
943
968
|
responsesTypes: RequestResponseInfo[];
|
|
969
|
+
links?: RouteLinkInfo[];
|
|
944
970
|
description?: string;
|
|
945
971
|
tags?: string[];
|
|
946
972
|
summary?: string;
|
|
@@ -992,6 +1018,7 @@ interface ParsedRoute {
|
|
|
992
1018
|
responseBodyInfo?: {
|
|
993
1019
|
contentTypes: any[];
|
|
994
1020
|
responses: any[];
|
|
1021
|
+
links?: RouteLinkInfo[];
|
|
995
1022
|
success?: Record<string, any>;
|
|
996
1023
|
error?: Record<string, any>;
|
|
997
1024
|
full?: Record<string, any>;
|
|
@@ -1125,8 +1152,8 @@ interface GenerateApiConfiguration {
|
|
|
1125
1152
|
extractRequestBody: boolean; /** generated http client type */
|
|
1126
1153
|
httpClientType: "axios" | "fetch"; /** generate readonly properties */
|
|
1127
1154
|
addReadonly: boolean; /** customise primitive type mappings */
|
|
1128
|
-
primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) =>
|
|
1129
|
-
codeGenConstructs?: (struct: CodeGenConstruct) =>
|
|
1155
|
+
primitiveTypeConstructs?: ((struct: PrimitiveTypeStruct) => PartialDeep<PrimitiveTypeStruct>) | PartialDeep<PrimitiveTypeStruct>; /** customise code generation constructs */
|
|
1156
|
+
codeGenConstructs?: ((struct: CodeGenConstruct) => PartialDeep<CodeGenConstruct>) | PartialDeep<CodeGenConstruct>; /** extract response body type to data contract */
|
|
1130
1157
|
extractResponseBody: boolean; /** extract response error type to data contract */
|
|
1131
1158
|
extractResponseError: boolean; /** extract all enums from nested types/interfaces to `enum` construction */
|
|
1132
1159
|
extractEnums: boolean; /** extract all enums from inline interface/type content to typescript enum construction */
|
|
@@ -1332,6 +1359,7 @@ declare class CodeGenConfig {
|
|
|
1332
1359
|
};
|
|
1333
1360
|
routeNameDuplicatesMap: Map<any, any>;
|
|
1334
1361
|
hooks: Hooks;
|
|
1362
|
+
resolvedSwaggerSchema: ResolvedSwaggerSchema;
|
|
1335
1363
|
defaultResponseType: string;
|
|
1336
1364
|
singleHttpClient: boolean;
|
|
1337
1365
|
httpClientType: "fetch";
|
|
@@ -1384,7 +1412,7 @@ declare class CodeGenConfig {
|
|
|
1384
1412
|
spec: OpenAPI.Document | null;
|
|
1385
1413
|
fileName: string;
|
|
1386
1414
|
authorizationToken: string | undefined;
|
|
1387
|
-
requestOptions: null;
|
|
1415
|
+
requestOptions: Record<string, any> | null;
|
|
1388
1416
|
jsPrimitiveTypes: string[];
|
|
1389
1417
|
jsEmptyTypes: string[];
|
|
1390
1418
|
fixInvalidTypeNamePrefix: string;
|
|
@@ -1540,7 +1568,9 @@ declare class CodeGenConfig {
|
|
|
1540
1568
|
hooks,
|
|
1541
1569
|
...otherConfig
|
|
1542
1570
|
}: Partial<GenerateApiConfiguration["config"]>);
|
|
1543
|
-
update: (update: Partial<GenerateApiConfiguration["config"]
|
|
1571
|
+
update: (update: Partial<GenerateApiConfiguration["config"] & {
|
|
1572
|
+
resolvedSwaggerSchema: ResolvedSwaggerSchema;
|
|
1573
|
+
}>) => void;
|
|
1544
1574
|
}
|
|
1545
1575
|
//#endregion
|
|
1546
1576
|
//#region src/code-formatter.d.ts
|
|
@@ -1657,13 +1687,14 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1657
1687
|
Tuple: (values: unknown[]) => string;
|
|
1658
1688
|
};
|
|
1659
1689
|
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
1690
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
1660
1691
|
internalCase: typeof es_toolkit_compat0.camelCase;
|
|
1661
1692
|
classNameCase: typeof pascalCase;
|
|
1662
1693
|
pascalCase: typeof pascalCase;
|
|
1663
|
-
getInlineParseContent: (schema:
|
|
1664
|
-
getParseContent: (schema:
|
|
1694
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
1695
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
1665
1696
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
1666
|
-
parseSchema: (schema:
|
|
1697
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
1667
1698
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
1668
1699
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
1669
1700
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -1711,5 +1742,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1711
1742
|
}) => Promise<string>;
|
|
1712
1743
|
}>;
|
|
1713
1744
|
//#endregion
|
|
1714
|
-
export { ExtractingOptions, GenerateApiConfiguration, GenerateApiOutput, GenerateApiParams, GenerateTemplatesOutput, GenerateTemplatesParams, Hooks, HttpClientType, ModelType, ParsedRoute, ParsedRouteRequest, ParsedRouteResponse, ParsedSchema, PathArgInfo, RawRouteInfo, RequestContentKind, RequestResponseInfo, RouteNameInfo, RouteNameRouteInfo, SCHEMA_TYPES, SchemaComponent, SchemaTypeEnumContent, SchemaTypeObjectContent, SchemaTypePrimitiveContent, constants_d_exports as constants, generateApi, generateTemplates };
|
|
1745
|
+
export { ExtractingOptions, GenerateApiConfiguration, GenerateApiOutput, GenerateApiParams, GenerateTemplatesOutput, GenerateTemplatesParams, Hooks, HttpClientType, ModelType, ParsedRoute, ParsedRouteRequest, ParsedRouteResponse, ParsedSchema, PathArgInfo, RawRouteInfo, RequestContentKind, RequestResponseInfo, RouteLinkInfo, RouteNameInfo, RouteNameRouteInfo, SCHEMA_TYPES, SchemaComponent, SchemaTypeEnumContent, SchemaTypeObjectContent, SchemaTypePrimitiveContent, constants_d_exports as constants, generateApi, generateTemplates };
|
|
1715
1746
|
//# sourceMappingURL=index.d.cts.map
|