orval 8.20.0 → 8.21.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/bin/orval.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as description, i as startWatcher, l as name, n as loadConfigFile, r as generateSpec, s as normalizeOptions, t as findConfigFile, u as version } from "../config-
|
|
2
|
+
import { c as description, i as startWatcher, l as name, n as loadConfigFile, r as generateSpec, s as normalizeOptions, t as findConfigFile, u as version } from "../config-DGhExJ4J.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Option, program } from "@commander-js/extra-typings";
|
|
5
5
|
import { ErrorWithTag, OutputClient, OutputMode, SupportedFormatter, getWarningCount, isString, log, logError, resetWarnings, setVerbose, startMessage } from "@orval/core";
|
|
@@ -29,7 +29,7 @@ import { parseTsconfig } from "get-tsconfig";
|
|
|
29
29
|
import { createJiti } from "jiti";
|
|
30
30
|
//#region package.json
|
|
31
31
|
var name = "orval";
|
|
32
|
-
var version = "8.
|
|
32
|
+
var version = "8.21.0";
|
|
33
33
|
var description = "A swagger client generator for typescript";
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/client.ts
|
|
@@ -98,7 +98,7 @@ const generateClientHeader = ({ outputClient = DEFAULT_CLIENT, isRequestOptions,
|
|
|
98
98
|
sharedTypes: normalizedHeader.sharedTypes
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
|
-
const generateClientFooter = ({ outputClient, operationNames, hasMutator, hasAwaitedType, titles, output }) => {
|
|
101
|
+
const generateClientFooter = ({ outputClient, operationNames, operations, hasMutator, hasAwaitedType, titles, output }) => {
|
|
102
102
|
const { footer } = getGeneratorClient(outputClient, output);
|
|
103
103
|
if (!footer) return {
|
|
104
104
|
implementation: "",
|
|
@@ -111,6 +111,7 @@ const generateClientFooter = ({ outputClient, operationNames, hasMutator, hasAwa
|
|
|
111
111
|
logWarning("⚠️ Passing an array of strings for operations names to the footer function is deprecated and will be removed in a future major release. Please pass them in an object instead: { operationNames: string[] }.");
|
|
112
112
|
} else implementation = footer({
|
|
113
113
|
operationNames,
|
|
114
|
+
operations,
|
|
114
115
|
title: titles.implementation,
|
|
115
116
|
hasMutator,
|
|
116
117
|
hasAwaitedType
|
|
@@ -118,6 +119,7 @@ const generateClientFooter = ({ outputClient, operationNames, hasMutator, hasAwa
|
|
|
118
119
|
} catch {
|
|
119
120
|
implementation = footer({
|
|
120
121
|
operationNames,
|
|
122
|
+
operations,
|
|
121
123
|
title: titles.implementation,
|
|
122
124
|
hasMutator,
|
|
123
125
|
hasAwaitedType
|
|
@@ -202,7 +204,8 @@ const generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options
|
|
|
202
204
|
paramsSerializer: verbOption.paramsSerializer,
|
|
203
205
|
paramsFilter: verbOption.paramsFilter,
|
|
204
206
|
operationName: verbOption.operationName,
|
|
205
|
-
fetchReviver: verbOption.fetchReviver
|
|
207
|
+
fetchReviver: verbOption.fetchReviver,
|
|
208
|
+
...client.returnType ? { types: { result: client.returnType } } : void 0
|
|
206
209
|
};
|
|
207
210
|
return acc;
|
|
208
211
|
}, {});
|
|
@@ -252,10 +255,12 @@ async function getApiBuilder({ input, output, context }) {
|
|
|
252
255
|
}, output);
|
|
253
256
|
for (const verbOption of verbsOptions) acc.verbOptions[verbOption.operationId] = verbOption;
|
|
254
257
|
acc.schemas.push(...schemas);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
for (const [key, value] of Object.entries(pathOperations)) {
|
|
259
|
+
let operationKey = key;
|
|
260
|
+
let counter = 1;
|
|
261
|
+
while (Object.hasOwn(acc.operations, operationKey)) operationKey = `${key}::${++counter}`;
|
|
262
|
+
acc.operations[operationKey] = value;
|
|
263
|
+
}
|
|
259
264
|
return acc;
|
|
260
265
|
}, {
|
|
261
266
|
operations: {},
|
|
@@ -1126,6 +1131,7 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
1126
1131
|
useBrandedTypes: outputOptions.override?.zod?.useBrandedTypes ?? false,
|
|
1127
1132
|
generateReusableSchemas: outputOptions.override?.zod?.generateReusableSchemas ?? false,
|
|
1128
1133
|
generateMeta: outputOptions.override?.zod?.generateMeta ?? false,
|
|
1134
|
+
generateDiscriminatedUnion: outputOptions.override?.zod?.generateDiscriminatedUnion ?? false,
|
|
1129
1135
|
dateTimeOptions: outputOptions.override?.zod?.dateTimeOptions ?? { offset: true },
|
|
1130
1136
|
timeOptions: outputOptions.override?.zod?.timeOptions ?? {}
|
|
1131
1137
|
},
|
|
@@ -1138,6 +1144,7 @@ async function normalizeOptions(optionsExport, workspace = process.cwd(), global
|
|
|
1138
1144
|
provideIn: outputOptions.override?.angular?.provideIn ?? "root",
|
|
1139
1145
|
client: outputOptions.override?.angular?.retrievalClient ?? outputOptions.override?.angular?.client ?? "httpClient",
|
|
1140
1146
|
runtimeValidation: outputOptions.override?.angular?.runtimeValidation ?? false,
|
|
1147
|
+
queryObjectSerialization: outputOptions.override?.angular?.queryObjectSerialization ?? "spec",
|
|
1141
1148
|
...outputOptions.override?.angular?.httpResource ? { httpResource: outputOptions.override.angular.httpResource } : {}
|
|
1142
1149
|
},
|
|
1143
1150
|
fetch: {
|
|
@@ -1274,7 +1281,8 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global, source)
|
|
|
1274
1281
|
"timeOptions",
|
|
1275
1282
|
"generateEachHttpStatus",
|
|
1276
1283
|
"generateReusableSchemas",
|
|
1277
|
-
"generateMeta"
|
|
1284
|
+
"generateMeta",
|
|
1285
|
+
"generateDiscriminatedUnion"
|
|
1278
1286
|
];
|
|
1279
1287
|
return Object.fromEntries(Object.entries(operationsOrTags).map(([key, { transformer, mutator, formData, formUrlEncoded, paramsSerializer, paramsFilter, query, angular, zod, effect, ...rest }]) => {
|
|
1280
1288
|
const unsupportedOperationZodKeys = zod && unsupportedZodKeys.filter((unsupportedKey) => zod[unsupportedKey] !== void 0);
|
|
@@ -1286,6 +1294,7 @@ function normalizeOperationsAndTags(operationsOrTags, workspace, global, source)
|
|
|
1286
1294
|
provideIn: angular.provideIn ?? "root",
|
|
1287
1295
|
client: angular.retrievalClient ?? angular.client ?? "httpClient",
|
|
1288
1296
|
runtimeValidation: angular.runtimeValidation ?? false,
|
|
1297
|
+
queryObjectSerialization: angular.queryObjectSerialization ?? "spec",
|
|
1289
1298
|
...angular.httpResource ? { httpResource: angular.httpResource } : {}
|
|
1290
1299
|
} } : {},
|
|
1291
1300
|
...query ? { query: normalizeQueryOptions(query, workspace, global.query) } : {},
|
|
@@ -2038,7 +2047,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
|
|
|
2038
2047
|
const [bodyContentType, bodyMedia] = jsonBodyMedia ? ["application/json", jsonBodyMedia] : formDataBodyMedia ? ["multipart/form-data", formDataBodyMedia] : formUrlEncodedBodyMedia ? ["application/x-www-form-urlencoded", formUrlEncodedBodyMedia] : [void 0, void 0];
|
|
2039
2048
|
const bodySchema = bodyMedia?.schema;
|
|
2040
2049
|
const bodySchemas = shouldGenerate.body && bodySchema ? [{
|
|
2041
|
-
name: `${pascal(verbOption.
|
|
2050
|
+
name: `${pascal(verbOption.typeName)}Body`,
|
|
2042
2051
|
schema: useReusableSchemas ? bodySchema : dereference(bodySchema, zodContext),
|
|
2043
2052
|
bodyContentType,
|
|
2044
2053
|
encoding: bodyMedia?.encoding
|
|
@@ -2046,7 +2055,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
|
|
|
2046
2055
|
const parameters = operation.parameters;
|
|
2047
2056
|
const pathParams = parameters?.filter((p) => "in" in p && p.in === "path");
|
|
2048
2057
|
const pathParamsSchemas = useNamedParameters && shouldGenerate.param && pathParams && pathParams.length > 0 ? [{
|
|
2049
|
-
name: `${pascal(verbOption.
|
|
2058
|
+
name: `${pascal(verbOption.typeName)}PathParameters`,
|
|
2050
2059
|
schema: {
|
|
2051
2060
|
type: "object",
|
|
2052
2061
|
properties: Object.fromEntries(pathParams.filter((p) => "schema" in p && p.schema).map((p) => [p.name, useReusableSchemas ? p.schema : dereference(p.schema, zodContext)])),
|
|
@@ -2055,7 +2064,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
|
|
|
2055
2064
|
}] : [];
|
|
2056
2065
|
const queryParams = parameters?.filter((p) => "in" in p && p.in === "query");
|
|
2057
2066
|
const queryParamsSchemas = shouldGenerate.query && queryParams && queryParams.length > 0 ? [{
|
|
2058
|
-
name: `${pascal(verbOption.
|
|
2067
|
+
name: `${pascal(verbOption.typeName)}Params`,
|
|
2059
2068
|
schema: {
|
|
2060
2069
|
type: "object",
|
|
2061
2070
|
properties: Object.fromEntries(queryParams.filter((p) => "schema" in p && p.schema).map((p) => [p.name, useReusableSchemas ? p.schema : dereference(p.schema, zodContext)])),
|
|
@@ -2064,7 +2073,7 @@ async function writeZodSchemasFromVerbs(verbOptions, schemasPath, fileExtension,
|
|
|
2064
2073
|
}] : [];
|
|
2065
2074
|
const headerParams = parameters?.filter((p) => "in" in p && p.in === "header");
|
|
2066
2075
|
const headerParamsSchemas = shouldGenerate.header && headerParams && headerParams.length > 0 ? [{
|
|
2067
|
-
name: `${pascal(verbOption.
|
|
2076
|
+
name: `${pascal(verbOption.typeName)}Headers`,
|
|
2068
2077
|
schema: {
|
|
2069
2078
|
type: "object",
|
|
2070
2079
|
properties: Object.fromEntries(headerParams.filter((p) => "schema" in p && p.schema).map((p) => [p.name, useReusableSchemas ? p.schema : dereference(p.schema, zodContext)])),
|
|
@@ -2601,4 +2610,4 @@ async function loadConfigFile(configFilePath) {
|
|
|
2601
2610
|
//#endregion
|
|
2602
2611
|
export { defineConfig as a, description as c, startWatcher as i, name as l, loadConfigFile as n, defineTransformer as o, generateSpec as r, normalizeOptions as s, findConfigFile as t, version as u };
|
|
2603
2612
|
|
|
2604
|
-
//# sourceMappingURL=config-
|
|
2613
|
+
//# sourceMappingURL=config-DGhExJ4J.mjs.map
|