swagger-typescript-api 13.2.16 → 13.2.18
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/chunk-DQk6qfdC.mjs +18 -0
- package/dist/cli.cjs +14 -15
- package/dist/cli.cjs.map +1 -1
- package/dist/{cli.js → cli.mjs} +3 -2
- package/dist/cli.mjs.map +1 -0
- package/dist/{src-DWf638kx.cjs → generate-templates-C4JBmSNw.cjs} +377 -359
- package/dist/generate-templates-C4JBmSNw.cjs.map +1 -0
- package/dist/{src-D-LZ3PGk.js → generate-templates-DGQlyLhe.mjs} +349 -337
- package/dist/generate-templates-DGQlyLhe.mjs.map +1 -0
- package/dist/index.cjs +17 -6
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +179 -289
- package/dist/index.d.cts.map +1 -1
- package/dist/{index.d.ts → index.d.mts} +179 -290
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +24 -28
- package/templates/base/data-contract-jsdoc.ejs +16 -16
- package/templates/base/object-field-jsdoc.ejs +8 -8
- package/templates/base/route-docs.ejs +7 -7
- package/templates/default/api.ejs +11 -11
- package/templates/default/procedure-call.ejs +1 -1
- package/templates/modular/procedure-call.ejs +1 -1
- package/CHANGELOG.md +0 -1770
- package/dist/chunk-Bp6m_JJh.js +0 -13
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/src-D-LZ3PGk.js.map +0 -1
- package/dist/src-DWf638kx.cjs.map +0 -1
- /package/dist/{cli.d.ts → cli.d.mts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
1
|
+
import * as es_toolkit0 from "es-toolkit";
|
|
2
|
+
import * as es_toolkit_compat0 from "es-toolkit/compat";
|
|
3
|
+
import { camelCase } from "es-toolkit/compat";
|
|
4
4
|
import * as typescript from "typescript";
|
|
5
|
-
import * as
|
|
5
|
+
import * as eta from "eta";
|
|
6
6
|
import { OpenAPI } from "openapi-types";
|
|
7
7
|
import * as swagger_schema_official0 from "swagger-schema-official";
|
|
8
|
+
import { PartialDeep } from "type-fest";
|
|
8
9
|
|
|
9
10
|
//#region src/schema-components-map.d.ts
|
|
10
11
|
declare class SchemaComponentsMap {
|
|
@@ -165,26 +166,6 @@ declare class SchemaUtils {
|
|
|
165
166
|
formatJsValue: (value: any) => string;
|
|
166
167
|
}
|
|
167
168
|
//#endregion
|
|
168
|
-
//#region src/schema-parser/schema-formatters.d.ts
|
|
169
|
-
declare class SchemaFormatters {
|
|
170
|
-
config: CodeGenConfig;
|
|
171
|
-
templatesWorker: TemplatesWorker;
|
|
172
|
-
schemaUtils: SchemaUtils;
|
|
173
|
-
constructor(schemaParser: SchemaParser | SchemaParserFabric);
|
|
174
|
-
base: {
|
|
175
|
-
enum: (parsedSchema: any) => any;
|
|
176
|
-
object: (parsedSchema: any) => any;
|
|
177
|
-
primitive: (parsedSchema: any) => any;
|
|
178
|
-
};
|
|
179
|
-
inline: {
|
|
180
|
-
enum: (parsedSchema: any) => any;
|
|
181
|
-
object: (parsedSchema: any) => any;
|
|
182
|
-
};
|
|
183
|
-
formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
|
|
184
|
-
formatDescription: (description: any, inline: any) => any;
|
|
185
|
-
formatObjectContent: (content: any) => string;
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
169
|
//#region src/schema-parser/schema-parser-fabric.d.ts
|
|
189
170
|
declare class SchemaParserFabric {
|
|
190
171
|
config: CodeGenConfig;
|
|
@@ -199,11 +180,7 @@ declare class SchemaParserFabric {
|
|
|
199
180
|
schema,
|
|
200
181
|
typeName,
|
|
201
182
|
schemaPath
|
|
202
|
-
}:
|
|
203
|
-
schema: any;
|
|
204
|
-
typeName: any;
|
|
205
|
-
schemaPath: any;
|
|
206
|
-
}) => SchemaParser;
|
|
183
|
+
}: SchemaParserConfig) => SchemaParser;
|
|
207
184
|
createSchema: ({
|
|
208
185
|
content,
|
|
209
186
|
linkedSchema,
|
|
@@ -211,24 +188,65 @@ declare class SchemaParserFabric {
|
|
|
211
188
|
schemaPath,
|
|
212
189
|
...otherSchemaProps
|
|
213
190
|
}: {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
191
|
+
content: unknown;
|
|
192
|
+
linkedSchema?: Record<string, unknown>;
|
|
193
|
+
linkedComponent?: SchemaComponent;
|
|
194
|
+
schemaPath?: string[];
|
|
195
|
+
[key: string]: unknown;
|
|
219
196
|
}) => any;
|
|
220
197
|
createParsedComponent: ({
|
|
221
198
|
typeName,
|
|
222
199
|
schema,
|
|
223
200
|
schemaPath
|
|
224
|
-
}: {
|
|
225
|
-
typeName:
|
|
226
|
-
schema: any;
|
|
227
|
-
schemaPath: any;
|
|
201
|
+
}: Required<SchemaParserConfig> & {
|
|
202
|
+
typeName: string;
|
|
228
203
|
}) => SchemaComponent;
|
|
229
|
-
parseSchema: (schema:
|
|
230
|
-
getInlineParseContent: (schema:
|
|
231
|
-
getParseContent: (schema:
|
|
204
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
205
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
206
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/schema-parser/schema-formatters.d.ts
|
|
210
|
+
declare class SchemaFormatters {
|
|
211
|
+
config: CodeGenConfig;
|
|
212
|
+
templatesWorker: TemplatesWorker;
|
|
213
|
+
schemaUtils: SchemaUtils;
|
|
214
|
+
constructor(schemaParser: SchemaParser | SchemaParserFabric);
|
|
215
|
+
base: {
|
|
216
|
+
enum: (parsedSchema: any) => any;
|
|
217
|
+
object: (parsedSchema: any) => any;
|
|
218
|
+
primitive: (parsedSchema: any) => any;
|
|
219
|
+
};
|
|
220
|
+
inline: {
|
|
221
|
+
enum: (parsedSchema: any) => any;
|
|
222
|
+
object: (parsedSchema: any) => any;
|
|
223
|
+
};
|
|
224
|
+
formatSchema: (parsedSchema: Record<string, any>, formatType?: "base" | "inline") => any;
|
|
225
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
226
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
227
|
+
formatObjectContent: (content: any) => string;
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/schema-parser/mono-schema-parser.d.ts
|
|
231
|
+
interface SchemaParserConfig {
|
|
232
|
+
typeName?: string | null;
|
|
233
|
+
schema?: any;
|
|
234
|
+
schemaPath?: string[];
|
|
235
|
+
}
|
|
236
|
+
declare class MonoSchemaParser {
|
|
237
|
+
schema: any;
|
|
238
|
+
typeName: string | null;
|
|
239
|
+
schemaPath: string[];
|
|
240
|
+
schemaParser: SchemaParser;
|
|
241
|
+
schemaParserFabric: SchemaParserFabric;
|
|
242
|
+
typeNameFormatter: TypeNameFormatter;
|
|
243
|
+
schemaComponentsMap: SchemaComponentsMap;
|
|
244
|
+
schemaUtils: SchemaUtils;
|
|
245
|
+
config: CodeGenConfig;
|
|
246
|
+
schemaFormatters: SchemaFormatters;
|
|
247
|
+
constructor(schemaParser: SchemaParser, schema: unknown, typeName?: string | null, schemaPath?: string[]);
|
|
248
|
+
parse(): void;
|
|
249
|
+
buildTypeNameFromPath: () => Capitalize<string> | null;
|
|
232
250
|
}
|
|
233
251
|
//#endregion
|
|
234
252
|
//#region src/schema-routes/schema-routes.d.ts
|
|
@@ -245,47 +263,12 @@ declare class SchemaRoutes {
|
|
|
245
263
|
hasQueryRoutes: boolean;
|
|
246
264
|
hasFormDataRoutes: boolean;
|
|
247
265
|
constructor(config: CodeGenConfig, schemaParserFabric: SchemaParserFabric, schemaComponentsMap: SchemaComponentsMap, templatesWorker: TemplatesWorker, typeNameFormatter: TypeNameFormatter);
|
|
248
|
-
createRequestsMap: (
|
|
249
|
-
parseRouteName: (
|
|
250
|
-
originalRoute: string;
|
|
251
|
-
route: string;
|
|
252
|
-
pathParams: {
|
|
253
|
-
$match: string;
|
|
254
|
-
name: string;
|
|
255
|
-
required: boolean;
|
|
256
|
-
type: "string";
|
|
257
|
-
description: string;
|
|
258
|
-
schema: {
|
|
259
|
-
type: string;
|
|
260
|
-
};
|
|
261
|
-
in: "path" | "query";
|
|
262
|
-
}[];
|
|
263
|
-
queryParams: {
|
|
264
|
-
$match: string;
|
|
265
|
-
name: string;
|
|
266
|
-
required: boolean;
|
|
267
|
-
type: "string";
|
|
268
|
-
description: string;
|
|
269
|
-
schema: {
|
|
270
|
-
type: string;
|
|
271
|
-
};
|
|
272
|
-
in: "path" | "query";
|
|
273
|
-
}[];
|
|
274
|
-
} | {
|
|
266
|
+
createRequestsMap: (routesByMethod: any) => {};
|
|
267
|
+
parseRouteName: (rawRoute: any) => {
|
|
275
268
|
originalRoute: any;
|
|
276
269
|
route: any;
|
|
277
|
-
pathParams:
|
|
278
|
-
queryParams:
|
|
279
|
-
$match: unknown;
|
|
280
|
-
name: string;
|
|
281
|
-
required: boolean;
|
|
282
|
-
type: string;
|
|
283
|
-
description: string;
|
|
284
|
-
schema: {
|
|
285
|
-
type: string;
|
|
286
|
-
};
|
|
287
|
-
in: string;
|
|
288
|
-
}[];
|
|
270
|
+
pathParams: any[];
|
|
271
|
+
queryParams: any[];
|
|
289
272
|
};
|
|
290
273
|
getRouteParams: (routeInfo: any, pathParamsFromRouteName: any, queryParamsFromRouteName: any) => {
|
|
291
274
|
path: never[];
|
|
@@ -322,16 +305,16 @@ declare class SchemaRoutes {
|
|
|
322
305
|
parsedSchemas: any;
|
|
323
306
|
operationId: any;
|
|
324
307
|
defaultType: any;
|
|
325
|
-
}) =>
|
|
308
|
+
}) => any[];
|
|
326
309
|
getResponseBodyInfo: (routeInfo: any, parsedSchemas: any) => {
|
|
327
310
|
contentTypes: any[];
|
|
328
|
-
responses:
|
|
311
|
+
responses: any[];
|
|
329
312
|
success: {
|
|
330
|
-
schema:
|
|
313
|
+
schema: any;
|
|
331
314
|
type: any;
|
|
332
315
|
};
|
|
333
316
|
error: {
|
|
334
|
-
schemas:
|
|
317
|
+
schemas: any[];
|
|
335
318
|
type: string;
|
|
336
319
|
};
|
|
337
320
|
full: {
|
|
@@ -384,9 +367,6 @@ declare class JavascriptTranslator extends Translator {
|
|
|
384
367
|
}[]>;
|
|
385
368
|
}
|
|
386
369
|
//#endregion
|
|
387
|
-
//#region src/util/internal-case.d.ts
|
|
388
|
-
declare function internalCase(value: string): string;
|
|
389
|
-
//#endregion
|
|
390
370
|
//#region src/util/name-resolver.d.ts
|
|
391
371
|
type Resolver = (reserved: string[], extras?: string[]) => string;
|
|
392
372
|
declare class NameResolver {
|
|
@@ -498,14 +478,15 @@ declare class CodeGenProcess {
|
|
|
498
478
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
499
479
|
Tuple: (values: unknown[]) => string;
|
|
500
480
|
};
|
|
501
|
-
formatDescription: (description:
|
|
502
|
-
|
|
481
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
482
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
483
|
+
internalCase: typeof camelCase;
|
|
503
484
|
classNameCase: typeof pascalCase;
|
|
504
485
|
pascalCase: typeof pascalCase;
|
|
505
|
-
getInlineParseContent: (schema:
|
|
506
|
-
getParseContent: (schema:
|
|
486
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
487
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
507
488
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
508
|
-
parseSchema: (schema:
|
|
489
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
509
490
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
510
491
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
511
492
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -527,7 +508,7 @@ declare class CodeGenProcess {
|
|
|
527
508
|
eol?: boolean | undefined;
|
|
528
509
|
}) => string;
|
|
529
510
|
NameResolver: typeof NameResolver;
|
|
530
|
-
_:
|
|
511
|
+
_: Record<string, unknown>;
|
|
531
512
|
require: (packageOrPath: string) => any;
|
|
532
513
|
};
|
|
533
514
|
};
|
|
@@ -603,14 +584,15 @@ declare class CodeGenProcess {
|
|
|
603
584
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
604
585
|
Tuple: (values: unknown[]) => string;
|
|
605
586
|
};
|
|
606
|
-
formatDescription: (description:
|
|
607
|
-
|
|
587
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
588
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
589
|
+
internalCase: typeof camelCase;
|
|
608
590
|
classNameCase: typeof pascalCase;
|
|
609
591
|
pascalCase: typeof pascalCase;
|
|
610
|
-
getInlineParseContent: (schema:
|
|
611
|
-
getParseContent: (schema:
|
|
592
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
593
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
612
594
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
613
|
-
parseSchema: (schema:
|
|
595
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
614
596
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
615
597
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
616
598
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -632,7 +614,7 @@ declare class CodeGenProcess {
|
|
|
632
614
|
eol?: boolean | undefined;
|
|
633
615
|
}) => string;
|
|
634
616
|
NameResolver: typeof NameResolver;
|
|
635
|
-
_:
|
|
617
|
+
_: Record<string, unknown>;
|
|
636
618
|
require: (packageOrPath: string) => any;
|
|
637
619
|
};
|
|
638
620
|
config: CodeGenConfig;
|
|
@@ -690,14 +672,18 @@ declare class SchemaParser {
|
|
|
690
672
|
schemaUtils: SchemaUtils;
|
|
691
673
|
templatesWorker: TemplatesWorker;
|
|
692
674
|
schemaWalker: SchemaWalker;
|
|
693
|
-
typeName:
|
|
675
|
+
typeName: string | null;
|
|
694
676
|
schema: any;
|
|
695
|
-
schemaPath:
|
|
696
|
-
constructor(schemaParserFabric:
|
|
677
|
+
schemaPath: string[];
|
|
678
|
+
constructor(schemaParserFabric: SchemaParserFabric, {
|
|
697
679
|
typeName,
|
|
698
680
|
schema,
|
|
699
681
|
schemaPath
|
|
700
|
-
}?: {
|
|
682
|
+
}?: {
|
|
683
|
+
typeName?: string | null;
|
|
684
|
+
schema?: any;
|
|
685
|
+
schemaPath?: string[];
|
|
686
|
+
});
|
|
701
687
|
_complexSchemaParsers: {
|
|
702
688
|
oneOf: (schema: any) => any;
|
|
703
689
|
allOf: (schema: any) => any;
|
|
@@ -755,23 +741,6 @@ declare const SCHEMA_TYPES$1: {
|
|
|
755
741
|
readonly COMPLEX_UNKNOWN: "__unknown";
|
|
756
742
|
};
|
|
757
743
|
//#endregion
|
|
758
|
-
//#region src/schema-parser/mono-schema-parser.d.ts
|
|
759
|
-
declare class MonoSchemaParser {
|
|
760
|
-
schema: any;
|
|
761
|
-
typeName: any;
|
|
762
|
-
schemaPath: never[];
|
|
763
|
-
schemaParser: SchemaParser;
|
|
764
|
-
schemaParserFabric: SchemaParserFabric;
|
|
765
|
-
typeNameFormatter: TypeNameFormatter;
|
|
766
|
-
schemaComponentsMap: SchemaComponentsMap;
|
|
767
|
-
schemaUtils: SchemaUtils;
|
|
768
|
-
config: CodeGenConfig;
|
|
769
|
-
schemaFormatters: SchemaFormatters;
|
|
770
|
-
constructor(schemaParser: SchemaParser, schema: any, typeName?: null, schemaPath?: never[]);
|
|
771
|
-
parse(): void;
|
|
772
|
-
buildTypeNameFromPath: () => Capitalize<string> | null;
|
|
773
|
-
}
|
|
774
|
-
//#endregion
|
|
775
744
|
//#region types/index.d.ts
|
|
776
745
|
type HttpClientType = (typeof HTTP_CLIENT)[keyof typeof HTTP_CLIENT];
|
|
777
746
|
type CodeGenConstruct = {
|
|
@@ -842,8 +811,7 @@ interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfigurat
|
|
|
842
811
|
}
|
|
843
812
|
type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
|
|
844
813
|
type BuildRouteParam = {
|
|
845
|
-
/** {bar}
|
|
846
|
-
$match: string;
|
|
814
|
+
/** {bar} */$match: string;
|
|
847
815
|
name: string;
|
|
848
816
|
required: boolean;
|
|
849
817
|
type: "string";
|
|
@@ -854,9 +822,7 @@ type BuildRouteParam = {
|
|
|
854
822
|
in: "path" | "query";
|
|
855
823
|
};
|
|
856
824
|
type BuildRoutePath = {
|
|
857
|
-
/** /foo/{bar}/baz */
|
|
858
|
-
originalRoute: string;
|
|
859
|
-
/** /foo/${bar}/baz */
|
|
825
|
+
/** /foo/{bar}/baz */originalRoute: string; /** /foo/${bar}/baz */
|
|
860
826
|
route: string;
|
|
861
827
|
pathParams: BuildRouteParam[];
|
|
862
828
|
queryParams: BuildRouteParam[];
|
|
@@ -918,7 +884,7 @@ type SchemaTypeEnumContent = {
|
|
|
918
884
|
type: string;
|
|
919
885
|
value: string;
|
|
920
886
|
};
|
|
921
|
-
interface ParsedSchema<C
|
|
887
|
+
interface ParsedSchema<C> {
|
|
922
888
|
$parsedSchema: boolean;
|
|
923
889
|
schemaType: string;
|
|
924
890
|
type: string;
|
|
@@ -926,7 +892,7 @@ interface ParsedSchema<C$1> {
|
|
|
926
892
|
name: string;
|
|
927
893
|
description?: string;
|
|
928
894
|
allFieldsAreOptional?: boolean;
|
|
929
|
-
content: C
|
|
895
|
+
content: C;
|
|
930
896
|
isExtractedRequestParams?: boolean;
|
|
931
897
|
isExtractedRequestBody?: boolean;
|
|
932
898
|
isExtractedResponseBody?: boolean;
|
|
@@ -964,7 +930,7 @@ declare enum RequestContentKind {
|
|
|
964
930
|
FORM_DATA = "FORM_DATA",
|
|
965
931
|
IMAGE = "IMAGE",
|
|
966
932
|
OTHER = "OTHER",
|
|
967
|
-
TEXT = "TEXT"
|
|
933
|
+
TEXT = "TEXT"
|
|
968
934
|
}
|
|
969
935
|
interface RequestResponseInfo {
|
|
970
936
|
contentTypes: string[];
|
|
@@ -1065,7 +1031,7 @@ declare enum SCHEMA_TYPES {
|
|
|
1065
1031
|
COMPLEX_ANY_OF = "anyOf",
|
|
1066
1032
|
COMPLEX_ALL_OF = "allOf",
|
|
1067
1033
|
COMPLEX_NOT = "not",
|
|
1068
|
-
COMPLEX_UNKNOWN = "__unknown"
|
|
1034
|
+
COMPLEX_UNKNOWN = "__unknown"
|
|
1069
1035
|
}
|
|
1070
1036
|
type MAIN_SCHEMA_TYPES = SCHEMA_TYPES.PRIMITIVE | SCHEMA_TYPES.OBJECT | SCHEMA_TYPES.ENUM;
|
|
1071
1037
|
type ExtractingOptions = {
|
|
@@ -1086,20 +1052,14 @@ type ExtractingOptions = {
|
|
|
1086
1052
|
};
|
|
1087
1053
|
interface GenerateApiConfiguration {
|
|
1088
1054
|
apiConfig: {
|
|
1089
|
-
/** base url from schema */
|
|
1090
|
-
|
|
1091
|
-
/**
|
|
1092
|
-
|
|
1093
|
-
/** document version */
|
|
1094
|
-
version: string;
|
|
1095
|
-
/** description split into lines */
|
|
1096
|
-
description: string[];
|
|
1097
|
-
/** flag that description is present */
|
|
1055
|
+
/** base url from schema */baseUrl: string; /** document title */
|
|
1056
|
+
title: string; /** document version */
|
|
1057
|
+
version: string; /** description split into lines */
|
|
1058
|
+
description: string[]; /** flag that description is present */
|
|
1098
1059
|
hasDescription: boolean;
|
|
1099
1060
|
};
|
|
1100
1061
|
config: {
|
|
1101
|
-
/** path to swagger schema */
|
|
1102
|
-
input: string;
|
|
1062
|
+
/** path to swagger schema */input: string;
|
|
1103
1063
|
/**
|
|
1104
1064
|
* generate separated files for http client, data contracts, and routes
|
|
1105
1065
|
* @default false
|
|
@@ -1110,10 +1070,8 @@ interface GenerateApiConfiguration {
|
|
|
1110
1070
|
* may be set to `false` to skip writing content to disk; in this case
|
|
1111
1071
|
* the `files` array on the return value will contain the generated contents.
|
|
1112
1072
|
*/
|
|
1113
|
-
output: string | false;
|
|
1114
|
-
|
|
1115
|
-
url: string;
|
|
1116
|
-
/** swagger schema JSON */
|
|
1073
|
+
output: string | false; /** url to swagger schema */
|
|
1074
|
+
url: string; /** swagger schema JSON */
|
|
1117
1075
|
spec: unknown;
|
|
1118
1076
|
/**
|
|
1119
1077
|
* file name for the generated API module
|
|
@@ -1126,95 +1084,57 @@ interface GenerateApiConfiguration {
|
|
|
1126
1084
|
*/
|
|
1127
1085
|
templates: string;
|
|
1128
1086
|
templatePaths: {
|
|
1129
|
-
/** `templates/base` */
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
|
|
1133
|
-
/** `templates/modular` */
|
|
1134
|
-
modular: string;
|
|
1135
|
-
/** usage path if `--templates` option is not set */
|
|
1136
|
-
original: string;
|
|
1137
|
-
/** custom path to templates (`--templates`) */
|
|
1087
|
+
/** `templates/base` */base: string; /** `templates/default` */
|
|
1088
|
+
default: string; /** `templates/modular` */
|
|
1089
|
+
modular: string; /** usage path if `--templates` option is not set */
|
|
1090
|
+
original: string; /** custom path to templates (`--templates`) */
|
|
1138
1091
|
custom: string | null;
|
|
1139
|
-
};
|
|
1140
|
-
/**
|
|
1141
|
-
authorizationToken?: string;
|
|
1142
|
-
/** generate additional information about request responses and error typings */
|
|
1092
|
+
}; /** authorisation token for private swagger schema access */
|
|
1093
|
+
authorizationToken?: string; /** generate additional information about request responses and error typings */
|
|
1143
1094
|
generateResponses: boolean;
|
|
1144
1095
|
/**
|
|
1145
1096
|
* use "default" response status code as success response.
|
|
1146
1097
|
* some swagger schemas treat "default" as a successful response.
|
|
1147
1098
|
*/
|
|
1148
|
-
defaultResponseAsSuccess: boolean;
|
|
1149
|
-
/** generate
|
|
1150
|
-
|
|
1151
|
-
/**
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
|
|
1157
|
-
/**
|
|
1158
|
-
originalSchema: object;
|
|
1159
|
-
/** map of schema component references */
|
|
1160
|
-
componentsMap: Record<string, SchemaComponent>;
|
|
1161
|
-
/** flag indicating the schema was converted from Swagger 2.0 */
|
|
1162
|
-
convertedFromSwagger2: boolean;
|
|
1163
|
-
/** determines which path index should be used for routes separation */
|
|
1164
|
-
moduleNameIndex: number;
|
|
1165
|
-
/** use the first tag for the module name */
|
|
1166
|
-
moduleNameFirstTag: boolean;
|
|
1167
|
-
/** extra templates */
|
|
1099
|
+
defaultResponseAsSuccess: boolean; /** generate type definitions for API routes */
|
|
1100
|
+
generateRouteTypes: boolean; /** generate an API client */
|
|
1101
|
+
generateClient: boolean; /** generate all "enum" types as union types (T1 | T2 | TN) */
|
|
1102
|
+
generateUnionEnums: boolean; /** parsed swagger schema */
|
|
1103
|
+
swaggerSchema: object; /** original swagger schema */
|
|
1104
|
+
originalSchema: object; /** map of schema component references */
|
|
1105
|
+
componentsMap: Record<string, SchemaComponent>; /** flag indicating the schema was converted from Swagger 2.0 */
|
|
1106
|
+
convertedFromSwagger2: boolean; /** determines which path index should be used for routes separation */
|
|
1107
|
+
moduleNameIndex: number; /** use the first tag for the module name */
|
|
1108
|
+
moduleNameFirstTag: boolean; /** extra templates */
|
|
1168
1109
|
extraTemplates: {
|
|
1169
1110
|
name: string;
|
|
1170
1111
|
path: string;
|
|
1171
|
-
}[];
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
/**
|
|
1177
|
-
|
|
1178
|
-
/**
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
typePrefix: string;
|
|
1184
|
-
/** suffix string value for type names */
|
|
1185
|
-
typeSuffix: string;
|
|
1186
|
-
/** prefix string value for enum keys */
|
|
1187
|
-
enumKeyPrefix: string;
|
|
1188
|
-
/** suffix string value for enum keys */
|
|
1189
|
-
enumKeySuffix: string;
|
|
1190
|
-
/** fix up small errors in the swagger source definition */
|
|
1191
|
-
patch: boolean;
|
|
1192
|
-
/** remove output directory before generating */
|
|
1193
|
-
cleanOutput: boolean;
|
|
1194
|
-
/** output debug messages */
|
|
1112
|
+
}[]; /** extract request params to data contract */
|
|
1113
|
+
extractRequestParams: boolean; /** unwrap the data item from the response */
|
|
1114
|
+
unwrapResponseData: boolean; /** sort data contracts in alphabetical order */
|
|
1115
|
+
sortTypes: boolean; /** sort routes in alphabetical order */
|
|
1116
|
+
sortRoutes: boolean; /** ability to send HttpClient instance to Api constructor */
|
|
1117
|
+
singleHttpClient: boolean; /** prefix string value for type names */
|
|
1118
|
+
typePrefix: string; /** suffix string value for type names */
|
|
1119
|
+
typeSuffix: string; /** prefix string value for enum keys */
|
|
1120
|
+
enumKeyPrefix: string; /** suffix string value for enum keys */
|
|
1121
|
+
enumKeySuffix: string; /** fix up small errors in the swagger source definition */
|
|
1122
|
+
patch: boolean; /** remove output directory before generating */
|
|
1123
|
+
cleanOutput: boolean; /** output debug messages */
|
|
1195
1124
|
debug: boolean;
|
|
1196
1125
|
/**
|
|
1197
1126
|
* generate array types as Array<Type>
|
|
1198
1127
|
* @default false
|
|
1199
1128
|
*/
|
|
1200
|
-
anotherArrayType: boolean;
|
|
1201
|
-
/**
|
|
1202
|
-
|
|
1203
|
-
/**
|
|
1204
|
-
|
|
1205
|
-
/**
|
|
1206
|
-
|
|
1207
|
-
/**
|
|
1208
|
-
|
|
1209
|
-
/** customise code generation constructs */
|
|
1210
|
-
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
|
|
1211
|
-
/** extract response body type to data contract */
|
|
1212
|
-
extractResponseBody: boolean;
|
|
1213
|
-
/** extract response error type to data contract */
|
|
1214
|
-
extractResponseError: boolean;
|
|
1215
|
-
/** extract all enums from nested types/interfaces to `enum` construction */
|
|
1216
|
-
extractEnums: boolean;
|
|
1217
|
-
/** extract all enums from inline interface/type content to typescript enum construction */
|
|
1129
|
+
anotherArrayType: boolean; /** extract request body type to data contract */
|
|
1130
|
+
extractRequestBody: boolean; /** generated http client type */
|
|
1131
|
+
httpClientType: "axios" | "fetch"; /** generate readonly properties */
|
|
1132
|
+
addReadonly: boolean; /** customise primitive type mappings */
|
|
1133
|
+
primitiveTypeConstructs?: ((struct: PrimitiveTypeStruct) => PartialDeep<PrimitiveTypeStruct>) | PartialDeep<PrimitiveTypeStruct>; /** customise code generation constructs */
|
|
1134
|
+
codeGenConstructs?: ((struct: CodeGenConstruct) => PartialDeep<CodeGenConstruct>) | PartialDeep<CodeGenConstruct>; /** extract response body type to data contract */
|
|
1135
|
+
extractResponseBody: boolean; /** extract response error type to data contract */
|
|
1136
|
+
extractResponseError: boolean; /** extract all enums from nested types/interfaces to `enum` construction */
|
|
1137
|
+
extractEnums: boolean; /** extract all enums from inline interface/type content to typescript enum construction */
|
|
1218
1138
|
extractResponses: boolean;
|
|
1219
1139
|
/**
|
|
1220
1140
|
* prefix string value needed to fix invalid type names
|
|
@@ -1235,52 +1155,38 @@ interface GenerateApiConfiguration {
|
|
|
1235
1155
|
* generate js api module with declaration file
|
|
1236
1156
|
* @default false
|
|
1237
1157
|
*/
|
|
1238
|
-
toJS: boolean;
|
|
1239
|
-
/** disable throwing on a non-successful response */
|
|
1158
|
+
toJS: boolean; /** disable throwing on a non-successful response */
|
|
1240
1159
|
disableThrowOnError: boolean;
|
|
1241
1160
|
/**
|
|
1242
1161
|
* output only errors to console
|
|
1243
1162
|
* @default false
|
|
1244
1163
|
*/
|
|
1245
|
-
silent: boolean;
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1248
|
-
/**
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
|
|
1252
|
-
/** ts compiler configuration object (for --to-js option) */
|
|
1253
|
-
compilerTsConfig: Record<string, unknown>;
|
|
1254
|
-
/** enum key resolver name */
|
|
1255
|
-
enumKeyResolverName: string;
|
|
1256
|
-
/** type name resolver name */
|
|
1257
|
-
typeNameResolverName: string;
|
|
1258
|
-
/** specific argument name resolver name */
|
|
1164
|
+
silent: boolean; /** hooks for customising the generation process */
|
|
1165
|
+
hooks: Partial<Hooks>; /** use enum names as values */
|
|
1166
|
+
enumNamesAsValues: boolean; /** package version */
|
|
1167
|
+
version: string; /** ts compiler configuration object (for --to-js option) */
|
|
1168
|
+
compilerTsConfig: Record<string, unknown>; /** enum key resolver name */
|
|
1169
|
+
enumKeyResolverName: string; /** type name resolver name */
|
|
1170
|
+
typeNameResolverName: string; /** specific argument name resolver name */
|
|
1259
1171
|
specificArgNameResolverName: string;
|
|
1260
1172
|
/**
|
|
1261
1173
|
* custom ts->* translator
|
|
1262
1174
|
* do not use constructor args, just send class reference
|
|
1263
1175
|
*/
|
|
1264
|
-
customTranslator?: new () => Translator;
|
|
1265
|
-
/**
|
|
1266
|
-
constants: typeof constants_d_exports;
|
|
1267
|
-
/** code generation constructs for TypeScript */
|
|
1176
|
+
customTranslator?: new () => Translator; /** internal constants */
|
|
1177
|
+
constants: typeof constants_d_exports; /** code generation constructs for TypeScript */
|
|
1268
1178
|
Ts: CodeGenConstruct;
|
|
1269
1179
|
/**
|
|
1270
1180
|
* swagger schema type -> typescript type
|
|
1271
1181
|
* https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
|
|
1272
1182
|
*/
|
|
1273
|
-
primitiveTypes: PrimitiveTypeStruct;
|
|
1274
|
-
/** built-in template info */
|
|
1183
|
+
primitiveTypes: PrimitiveTypeStruct; /** built-in template info */
|
|
1275
1184
|
templateInfos: {
|
|
1276
1185
|
name: string;
|
|
1277
1186
|
fileName: string;
|
|
1278
|
-
}[];
|
|
1279
|
-
/**
|
|
1280
|
-
|
|
1281
|
-
/** range of HTTP status codes treated as success */
|
|
1282
|
-
successResponseStatusRange: [number, number];
|
|
1283
|
-
/** custom schema parsers */
|
|
1187
|
+
}[]; /** supported template file extensions */
|
|
1188
|
+
templateExtensions: string[]; /** range of HTTP status codes treated as success */
|
|
1189
|
+
successResponseStatusRange: [number, number]; /** custom schema parsers */
|
|
1284
1190
|
schemaParsers?: {
|
|
1285
1191
|
complexOneOf?: MonoSchemaParser;
|
|
1286
1192
|
complexAllOf?: MonoSchemaParser;
|
|
@@ -1292,21 +1198,17 @@ interface GenerateApiConfiguration {
|
|
|
1292
1198
|
primitive?: MonoSchemaParser;
|
|
1293
1199
|
discriminator?: MonoSchemaParser;
|
|
1294
1200
|
array?: MonoSchemaParser;
|
|
1295
|
-
};
|
|
1296
|
-
/** internal options for templates */
|
|
1201
|
+
}; /** internal options for templates */
|
|
1297
1202
|
internalTemplateOptions: {
|
|
1298
1203
|
addUtilRequiredKeysType: boolean;
|
|
1299
|
-
};
|
|
1300
|
-
|
|
1301
|
-
componentTypeNameResolver: ComponentTypeNameResolver;
|
|
1302
|
-
/** generated file names */
|
|
1204
|
+
}; /** resolver for component type names */
|
|
1205
|
+
componentTypeNameResolver: ComponentTypeNameResolver; /** generated file names */
|
|
1303
1206
|
fileNames: {
|
|
1304
1207
|
dataContracts: string;
|
|
1305
1208
|
routeTypes: string;
|
|
1306
1209
|
httpClient: string;
|
|
1307
1210
|
outOfModuleApi: string;
|
|
1308
|
-
};
|
|
1309
|
-
/** Record<templateName, templateContent> */
|
|
1211
|
+
}; /** Record<templateName, templateContent> */
|
|
1310
1212
|
templatesToRender: {
|
|
1311
1213
|
api: string;
|
|
1312
1214
|
dataContracts: string;
|
|
@@ -1318,16 +1220,11 @@ interface GenerateApiConfiguration {
|
|
|
1318
1220
|
typeDataContract: string;
|
|
1319
1221
|
enumDataContract: string;
|
|
1320
1222
|
objectFieldJsDoc: string;
|
|
1321
|
-
};
|
|
1322
|
-
/**
|
|
1323
|
-
|
|
1324
|
-
/**
|
|
1325
|
-
|
|
1326
|
-
/** configuration for fetching swagger schema requests */
|
|
1327
|
-
requestOptions?: Partial<RequestInit>;
|
|
1328
|
-
/** extra configuration for extracting type names operations */
|
|
1329
|
-
extractingOptions: Partial<ExtractingOptions>;
|
|
1330
|
-
/** update configuration object during generation */
|
|
1223
|
+
}; /** map of duplicate route names */
|
|
1224
|
+
routeNameDuplicatesMap: Map<string, string>; /** name of the main exported class */
|
|
1225
|
+
apiClassName: string; /** configuration for fetching swagger schema requests */
|
|
1226
|
+
requestOptions?: Partial<RequestInit>; /** extra configuration for extracting type names operations */
|
|
1227
|
+
extractingOptions: Partial<ExtractingOptions>; /** update configuration object during generation */
|
|
1331
1228
|
update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
|
|
1332
1229
|
};
|
|
1333
1230
|
modelTypes: ModelType[];
|
|
@@ -1345,8 +1242,7 @@ interface GenerateApiConfiguration {
|
|
|
1345
1242
|
requestOptions?: Partial<RequestInit>;
|
|
1346
1243
|
utils: {
|
|
1347
1244
|
formatDescription: (description: string, inline?: boolean) => string;
|
|
1348
|
-
internalCase: (value: string) => string;
|
|
1349
|
-
/** @deprecated */
|
|
1245
|
+
internalCase: (value: string) => string; /** @deprecated */
|
|
1350
1246
|
classNameCase: (value: string) => string;
|
|
1351
1247
|
pascalCase: (value: string) => string;
|
|
1352
1248
|
getInlineParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => string;
|
|
@@ -1359,16 +1255,13 @@ interface GenerateApiConfiguration {
|
|
|
1359
1255
|
fmtToJSDocLine: (line: string, params?: {
|
|
1360
1256
|
eol?: boolean;
|
|
1361
1257
|
}) => string;
|
|
1362
|
-
_:
|
|
1258
|
+
_: typeof es_toolkit0 & typeof es_toolkit_compat0;
|
|
1363
1259
|
require: (path: string) => unknown;
|
|
1364
1260
|
};
|
|
1365
1261
|
}
|
|
1366
1262
|
type FileInfo = {
|
|
1367
|
-
/** @example myFilename */
|
|
1368
|
-
|
|
1369
|
-
/** @example .d.ts */
|
|
1370
|
-
fileExtension: string;
|
|
1371
|
-
/** content of the file */
|
|
1263
|
+
/** @example myFilename */fileName: string; /** @example .d.ts */
|
|
1264
|
+
fileExtension: string; /** content of the file */
|
|
1372
1265
|
fileContent: string;
|
|
1373
1266
|
};
|
|
1374
1267
|
interface GenerateApiOutput {
|
|
@@ -1380,7 +1273,7 @@ interface GenerateApiOutput {
|
|
|
1380
1273
|
content: string;
|
|
1381
1274
|
withPrefix: boolean;
|
|
1382
1275
|
}) => void;
|
|
1383
|
-
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<
|
|
1276
|
+
renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta.EtaConfig>) => Promise<string> | string;
|
|
1384
1277
|
getTemplate: (params: {
|
|
1385
1278
|
fileName?: string;
|
|
1386
1279
|
name?: string;
|
|
@@ -1452,15 +1345,10 @@ declare class CodeGenConfig {
|
|
|
1452
1345
|
sortTypes: boolean;
|
|
1453
1346
|
sortRoutes: boolean;
|
|
1454
1347
|
templatePaths: {
|
|
1455
|
-
/** `templates/base` */
|
|
1456
|
-
|
|
1457
|
-
/**
|
|
1458
|
-
|
|
1459
|
-
/** `templates/modular` */
|
|
1460
|
-
modular: string;
|
|
1461
|
-
/** usage path if `--templates` option is not set */
|
|
1462
|
-
original: string;
|
|
1463
|
-
/** custom path to templates (`--templates`) */
|
|
1348
|
+
/** `templates/base` */base: string; /** `templates/default` */
|
|
1349
|
+
default: string; /** `templates/modular` */
|
|
1350
|
+
modular: string; /** usage path if `--templates` option is not set */
|
|
1351
|
+
original: string; /** custom path to templates (`--templates`) */
|
|
1464
1352
|
custom: string;
|
|
1465
1353
|
};
|
|
1466
1354
|
/** Record<templateName, templateContent> */
|
|
@@ -1773,14 +1661,15 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1773
1661
|
TypeWithGeneric: (typeName: unknown, genericArgs: unknown[]) => string;
|
|
1774
1662
|
Tuple: (values: unknown[]) => string;
|
|
1775
1663
|
};
|
|
1776
|
-
formatDescription: (description:
|
|
1777
|
-
|
|
1664
|
+
formatDescription: (description: string | undefined, inline?: boolean) => string;
|
|
1665
|
+
escapeJSDocContent: (content: unknown) => string;
|
|
1666
|
+
internalCase: typeof es_toolkit_compat0.camelCase;
|
|
1778
1667
|
classNameCase: typeof pascalCase;
|
|
1779
1668
|
pascalCase: typeof pascalCase;
|
|
1780
|
-
getInlineParseContent: (schema:
|
|
1781
|
-
getParseContent: (schema:
|
|
1669
|
+
getInlineParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
1670
|
+
getParseContent: (schema: SchemaParserConfig["schema"], typeName: string | null, schemaPath: string[]) => Record<string, any>;
|
|
1782
1671
|
getComponentByRef: ($ref: string) => SchemaComponent | null;
|
|
1783
|
-
parseSchema: (schema:
|
|
1672
|
+
parseSchema: (schema: SchemaParserConfig["schema"], typeName?: string | null, schemaPath?: string[]) => ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
|
|
1784
1673
|
checkAndAddNull: (schema: any, type: any) => any;
|
|
1785
1674
|
safeAddNullToType: (schema: any, type: any) => any;
|
|
1786
1675
|
isNeedToAddNull: (schema: any, type: any) => any;
|
|
@@ -1802,7 +1691,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1802
1691
|
eol?: boolean | undefined;
|
|
1803
1692
|
}) => string;
|
|
1804
1693
|
NameResolver: typeof NameResolver;
|
|
1805
|
-
_:
|
|
1694
|
+
_: Record<string, unknown>;
|
|
1806
1695
|
require: (packageOrPath: string) => any;
|
|
1807
1696
|
};
|
|
1808
1697
|
};
|
|
@@ -1829,4 +1718,4 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1829
1718
|
}>;
|
|
1830
1719
|
//#endregion
|
|
1831
1720
|
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 };
|
|
1832
|
-
//# sourceMappingURL=index.d.
|
|
1721
|
+
//# sourceMappingURL=index.d.mts.map
|