swagger-typescript-api 13.12.6 → 13.13.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 +19 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +19 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +28 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +28 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-BY6Hz6vz.cjs → src-66lzgISA.cjs} +25 -9
- package/dist/src-66lzgISA.cjs.map +1 -0
- package/dist/{src-Dex5t5WU.mjs → src-DXotSN2p.mjs} +25 -9
- package/dist/src-DXotSN2p.mjs.map +1 -0
- package/package.json +1 -1
- package/templates/default/procedure-call.ejs +13 -1
- package/templates/default/route-types.ejs +1 -1
- package/templates/modular/api.ejs +7 -6
- package/templates/modular/procedure-call.ejs +13 -1
- package/templates/modular/route-types.ejs +1 -1
- package/dist/src-BY6Hz6vz.cjs.map +0 -1
- package/dist/src-Dex5t5WU.mjs.map +0 -1
|
@@ -171,7 +171,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region package.json
|
|
173
173
|
var name = "swagger-typescript-api";
|
|
174
|
-
var version = "13.
|
|
174
|
+
var version = "13.13.0";
|
|
175
175
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/constants.ts
|
|
@@ -296,6 +296,10 @@ var CodeGenConfig = class {
|
|
|
296
296
|
enumStyle = "enum";
|
|
297
297
|
/** @deprecated Use enumStyle: "union" instead */
|
|
298
298
|
generateUnionEnums = false;
|
|
299
|
+
/** CLI flag. Extension appended to generated relative imports: "" (default), ".js", or ".ts". */
|
|
300
|
+
importFileExtension = "";
|
|
301
|
+
/** CLI flag. Emit `import type` / inline `type` for type-only imports. */
|
|
302
|
+
typeOnlyImports = false;
|
|
299
303
|
/** CLI flag */
|
|
300
304
|
addReadonly = false;
|
|
301
305
|
enumNamesAsValues = false;
|
|
@@ -384,6 +388,7 @@ var CodeGenConfig = class {
|
|
|
384
388
|
enumKeyPrefix = "";
|
|
385
389
|
enumKeySuffix = "";
|
|
386
390
|
patch = false;
|
|
391
|
+
disableExternalSchemas = false;
|
|
387
392
|
preferExistingSchemaNamesForExternalRefs = false;
|
|
388
393
|
componentTypeNameResolver;
|
|
389
394
|
/** name of the main exported class */
|
|
@@ -665,6 +670,12 @@ var CodeGenConfig = class {
|
|
|
665
670
|
}
|
|
666
671
|
update = (update) => {
|
|
667
672
|
objectAssign(this, update);
|
|
673
|
+
this.importFileExtension ??= "";
|
|
674
|
+
if (![
|
|
675
|
+
"",
|
|
676
|
+
".js",
|
|
677
|
+
".ts"
|
|
678
|
+
].includes(this.importFileExtension)) throw new Error(`Invalid \`importFileExtension\` value "${this.importFileExtension}". Expected "", ".js", or ".ts".`);
|
|
668
679
|
if (this.enumNamesAsValues) this.extractEnums = true;
|
|
669
680
|
if (this.generateUnionEnums) {
|
|
670
681
|
consola$1.warn("`generateUnionEnums` is deprecated. Use `enumStyle: \"union\"` instead.");
|
|
@@ -827,6 +838,7 @@ var SchemaComponentsMap = class {
|
|
|
827
838
|
if (localFound != null) return localFound;
|
|
828
839
|
const { resolvedSwaggerSchema } = this.config;
|
|
829
840
|
if (resolvedSwaggerSchema.isLocalRef($ref)) return null;
|
|
841
|
+
if (this.config.disableExternalSchemas) return null;
|
|
830
842
|
const foundByRef = resolvedSwaggerSchema.getRef($ref);
|
|
831
843
|
const refDetails = resolvedSwaggerSchema.getRefDetails($ref);
|
|
832
844
|
if (foundByRef != null) {
|
|
@@ -1047,6 +1059,7 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
1047
1059
|
const complexSchemaItems = Array.isArray(this.schema[complexType]) ? this.schema[complexType] : [];
|
|
1048
1060
|
const simpleSchema = omit(this.schema, Object.keys(this.schemaParser._complexSchemaParsers));
|
|
1049
1061
|
const complexSchemaContent = this.schemaParser._complexSchemaParsers[complexType](this.schema);
|
|
1062
|
+
const shouldParseSimpleSchema = this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT || this.schemaUtils.isRefSchema(simpleSchema);
|
|
1050
1063
|
return {
|
|
1051
1064
|
...typeof this.schema === "object" ? this.schema : {},
|
|
1052
1065
|
$schemaPath: this.schemaPath.slice(),
|
|
@@ -1056,10 +1069,10 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
|
|
|
1056
1069
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
1057
1070
|
name: this.typeName,
|
|
1058
1071
|
description: this.schemaFormatters.formatDescription(this.schema.description || compact(complexSchemaItems.map((item) => item.description))[0] || ""),
|
|
1059
|
-
content: this.config.Ts.IntersectionType(
|
|
1072
|
+
content: this.config.Ts.IntersectionType(this.schemaUtils.filterSchemaContents(compact([complexSchemaContent, shouldParseSimpleSchema && this.schemaParserFabric.createSchemaParser({
|
|
1060
1073
|
schema: simpleSchema,
|
|
1061
1074
|
schemaPath: this.schemaPath
|
|
1062
|
-
}).getInlineParseContent()
|
|
1075
|
+
}).getInlineParseContent()]), (content) => content !== this.config.Ts.Keyword.Any).map((content) => this.config.Ts.ExpressionGroup(content))) || this.config.Ts.Keyword.Any
|
|
1063
1076
|
};
|
|
1064
1077
|
}
|
|
1065
1078
|
};
|
|
@@ -1571,6 +1584,7 @@ var SchemaParser = class {
|
|
|
1571
1584
|
if (!this.schema.$parsed) {
|
|
1572
1585
|
if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) this.typeName = this.schemaUtils.getSchemaType(this.schema);
|
|
1573
1586
|
if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) this.schema.type = SCHEMA_TYPES$1.ARRAY;
|
|
1587
|
+
if (this.schema.additionalProperties && !this.schema.type) this.schema.type = SCHEMA_TYPES$1.OBJECT;
|
|
1574
1588
|
if (Array.isArray(this.schema.enum) && this.schema.enum.length === 1 && this.schema.enum[0] == null) {
|
|
1575
1589
|
consola$1.debug("invalid enum schema", this.schema);
|
|
1576
1590
|
this.schema = { type: this.config.Ts.Keyword.Null };
|
|
@@ -1923,10 +1937,12 @@ var SchemaRoutes = class {
|
|
|
1923
1937
|
})]);
|
|
1924
1938
|
}
|
|
1925
1939
|
/**
|
|
1926
|
-
* `extractResponseBody` / `extractResponseError`
|
|
1927
|
-
* registers `#/components/schemas/<typeName>`. If that
|
|
1928
|
-
* `MergeFluffyData` in definitions
|
|
1929
|
-
*
|
|
1940
|
+
* `extractResponseBody` / `extractResponseError` / `extractRequestParams` call
|
|
1941
|
+
* `createParsedComponent`, which registers `#/components/schemas/<typeName>`. If that
|
|
1942
|
+
* key already exists (e.g. `MergeFluffyData` in definitions, or a request-body model
|
|
1943
|
+
* named `GetOrderParams` next to a `getOrder` operation), the map entry would be
|
|
1944
|
+
* overwritten unless we pick another name via `resolveTypeName` after reserving the
|
|
1945
|
+
* colliding one.
|
|
1930
1946
|
*
|
|
1931
1947
|
* `getComponents` may be missing in narrow unit tests that pass a stub map.
|
|
1932
1948
|
*
|
|
@@ -2290,7 +2306,7 @@ var SchemaRoutes = class {
|
|
|
2290
2306
|
const fixedSchema = this.config.hooks.onCreateRequestParams(schema);
|
|
2291
2307
|
if (fixedSchema) return fixedSchema;
|
|
2292
2308
|
if (extractRequestParams) {
|
|
2293
|
-
const generatedTypeName = this.
|
|
2309
|
+
const generatedTypeName = this.extractTypeNameWithoutSchemaKeyCollision(routeName.usage, {
|
|
2294
2310
|
suffixes: this.config.extractingOptions.requestParamsSuffix,
|
|
2295
2311
|
resolver: this.config.extractingOptions.requestParamsNameResolver
|
|
2296
2312
|
});
|
|
@@ -4226,4 +4242,4 @@ async function generateApi(config) {
|
|
|
4226
4242
|
//#endregion
|
|
4227
4243
|
export { SCHEMA_TYPES as a, constants_exports as c, version as d, RequestContentKind as i, description as l, generateTemplates as n, CodeGenConfig as o, TemplatesGenConfig as r, HTTP_CLIENT as s, generateApi as t, name as u };
|
|
4228
4244
|
|
|
4229
|
-
//# sourceMappingURL=src-
|
|
4245
|
+
//# sourceMappingURL=src-DXotSN2p.mjs.map
|