orval 6.20.0 → 6.22.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.d.ts +0 -0
- package/dist/bin/orval.js +124 -86
- package/dist/index.js +124 -86
- package/package.json +11 -10
package/dist/bin/orval.d.ts
CHANGED
|
File without changes
|
package/dist/bin/orval.js
CHANGED
|
@@ -29,6 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
// ../../node_modules/lodash.omit/index.js
|
|
30
30
|
var require_lodash = __commonJS({
|
|
31
31
|
"../../node_modules/lodash.omit/index.js"(exports2, module2) {
|
|
32
|
+
"use strict";
|
|
32
33
|
var LARGE_ARRAY_SIZE = 200;
|
|
33
34
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
34
35
|
var INFINITY = 1 / 0;
|
|
@@ -3252,28 +3253,28 @@ var import_lodash = __toESM(require_lodash());
|
|
|
3252
3253
|
|
|
3253
3254
|
// src/api.ts
|
|
3254
3255
|
var import_core2 = require("@orval/core");
|
|
3255
|
-
var
|
|
3256
|
+
var import_mock = require("@orval/mock");
|
|
3256
3257
|
|
|
3257
3258
|
// src/client.ts
|
|
3258
3259
|
var import_angular = __toESM(require("@orval/angular"));
|
|
3259
3260
|
var import_axios = __toESM(require("@orval/axios"));
|
|
3260
3261
|
var import_core = require("@orval/core");
|
|
3261
|
-
var
|
|
3262
|
+
var mock = __toESM(require("@orval/mock"));
|
|
3262
3263
|
var import_query = __toESM(require("@orval/query"));
|
|
3263
3264
|
var import_swr = __toESM(require("@orval/swr"));
|
|
3264
3265
|
var import_zod = __toESM(require("@orval/zod"));
|
|
3265
3266
|
var DEFAULT_CLIENT = import_core.OutputClient.AXIOS;
|
|
3266
|
-
var
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3267
|
+
var getGeneratorClient = (outputClient, output) => {
|
|
3268
|
+
const GENERATOR_CLIENT = {
|
|
3269
|
+
axios: (0, import_axios.default)({ type: "axios" })(),
|
|
3270
|
+
"axios-functions": (0, import_axios.default)({ type: "axios-functions" })(),
|
|
3271
|
+
angular: (0, import_angular.default)()(),
|
|
3272
|
+
"react-query": (0, import_query.default)({ output, type: "react-query" })(),
|
|
3273
|
+
"svelte-query": (0, import_query.default)({ output, type: "svelte-query" })(),
|
|
3274
|
+
"vue-query": (0, import_query.default)({ output, type: "vue-query" })(),
|
|
3275
|
+
swr: (0, import_swr.default)()(),
|
|
3276
|
+
zod: (0, import_zod.default)()()
|
|
3277
|
+
};
|
|
3277
3278
|
const generator = (0, import_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
|
|
3278
3279
|
if (!generator) {
|
|
3279
3280
|
throw `Oups... \u{1F37B}. Client not found: ${outputClient}`;
|
|
@@ -3289,9 +3290,10 @@ var generateClientImports = ({
|
|
|
3289
3290
|
isAllowSyntheticDefaultImports,
|
|
3290
3291
|
hasGlobalMutator,
|
|
3291
3292
|
hasParamsSerializerOptions,
|
|
3292
|
-
packageJson
|
|
3293
|
+
packageJson,
|
|
3294
|
+
output
|
|
3293
3295
|
}) => {
|
|
3294
|
-
const { dependencies } = getGeneratorClient(client);
|
|
3296
|
+
const { dependencies } = getGeneratorClient(client, output);
|
|
3295
3297
|
return (0, import_core.generateDependencyImports)(
|
|
3296
3298
|
implementation,
|
|
3297
3299
|
dependencies ? [
|
|
@@ -3314,9 +3316,10 @@ var generateClientHeader = ({
|
|
|
3314
3316
|
isMutator,
|
|
3315
3317
|
provideIn,
|
|
3316
3318
|
hasAwaitedType,
|
|
3317
|
-
titles
|
|
3319
|
+
titles,
|
|
3320
|
+
output
|
|
3318
3321
|
}) => {
|
|
3319
|
-
const { header } = getGeneratorClient(outputClient);
|
|
3322
|
+
const { header } = getGeneratorClient(outputClient, output);
|
|
3320
3323
|
return {
|
|
3321
3324
|
implementation: header ? header({
|
|
3322
3325
|
title: titles.implementation,
|
|
@@ -3326,7 +3329,7 @@ var generateClientHeader = ({
|
|
|
3326
3329
|
provideIn,
|
|
3327
3330
|
hasAwaitedType
|
|
3328
3331
|
}) : "",
|
|
3329
|
-
|
|
3332
|
+
implementationMock: `export const ${titles.implementationMock} = () => [
|
|
3330
3333
|
`
|
|
3331
3334
|
};
|
|
3332
3335
|
};
|
|
@@ -3335,13 +3338,14 @@ var generateClientFooter = ({
|
|
|
3335
3338
|
operationNames,
|
|
3336
3339
|
hasMutator,
|
|
3337
3340
|
hasAwaitedType,
|
|
3338
|
-
titles
|
|
3341
|
+
titles,
|
|
3342
|
+
output
|
|
3339
3343
|
}) => {
|
|
3340
|
-
const { footer } = getGeneratorClient(outputClient);
|
|
3344
|
+
const { footer } = getGeneratorClient(outputClient, output);
|
|
3341
3345
|
if (!footer) {
|
|
3342
3346
|
return {
|
|
3343
3347
|
implementation: "",
|
|
3344
|
-
|
|
3348
|
+
implementationMock: `]
|
|
3345
3349
|
`
|
|
3346
3350
|
};
|
|
3347
3351
|
}
|
|
@@ -3372,35 +3376,36 @@ var generateClientFooter = ({
|
|
|
3372
3376
|
}
|
|
3373
3377
|
return {
|
|
3374
3378
|
implementation,
|
|
3375
|
-
|
|
3379
|
+
implementationMock: `]
|
|
3376
3380
|
`
|
|
3377
3381
|
};
|
|
3378
3382
|
};
|
|
3379
3383
|
var generateClientTitle = ({
|
|
3380
3384
|
outputClient = DEFAULT_CLIENT,
|
|
3381
3385
|
title,
|
|
3382
|
-
customTitleFunc
|
|
3386
|
+
customTitleFunc,
|
|
3387
|
+
output
|
|
3383
3388
|
}) => {
|
|
3384
|
-
const { title: generatorTitle } = getGeneratorClient(outputClient);
|
|
3389
|
+
const { title: generatorTitle } = getGeneratorClient(outputClient, output);
|
|
3385
3390
|
if (!generatorTitle) {
|
|
3386
3391
|
return {
|
|
3387
3392
|
implementation: "",
|
|
3388
|
-
|
|
3393
|
+
implementationMock: `get${(0, import_core.pascal)(title)}Mock`
|
|
3389
3394
|
};
|
|
3390
3395
|
}
|
|
3391
3396
|
if (customTitleFunc) {
|
|
3392
3397
|
const customTitle = customTitleFunc(title);
|
|
3393
3398
|
return {
|
|
3394
3399
|
implementation: generatorTitle(customTitle),
|
|
3395
|
-
|
|
3400
|
+
implementationMock: `get${(0, import_core.pascal)(customTitle)}Mock`
|
|
3396
3401
|
};
|
|
3397
3402
|
}
|
|
3398
3403
|
return {
|
|
3399
3404
|
implementation: generatorTitle(title),
|
|
3400
|
-
|
|
3405
|
+
implementationMock: `get${(0, import_core.pascal)(title)}Mock`
|
|
3401
3406
|
};
|
|
3402
3407
|
};
|
|
3403
|
-
var
|
|
3408
|
+
var generateMock2 = (verbOption, options) => {
|
|
3404
3409
|
if (!options.mock) {
|
|
3405
3410
|
return {
|
|
3406
3411
|
implementation: {
|
|
@@ -3413,23 +3418,31 @@ var generateMock = (verbOption, options) => {
|
|
|
3413
3418
|
if ((0, import_core.isFunction)(options.mock)) {
|
|
3414
3419
|
return options.mock(verbOption, options);
|
|
3415
3420
|
}
|
|
3416
|
-
return
|
|
3421
|
+
return mock.generateMock(
|
|
3422
|
+
verbOption,
|
|
3423
|
+
options
|
|
3424
|
+
);
|
|
3417
3425
|
};
|
|
3418
|
-
var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options) => {
|
|
3426
|
+
var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options, output) => {
|
|
3419
3427
|
return (0, import_core.asyncReduce)(
|
|
3420
3428
|
verbsOptions,
|
|
3421
3429
|
async (acc, verbOption) => {
|
|
3422
|
-
const { client: generatorClient } = getGeneratorClient(
|
|
3430
|
+
const { client: generatorClient } = getGeneratorClient(
|
|
3431
|
+
outputClient,
|
|
3432
|
+
output
|
|
3433
|
+
);
|
|
3423
3434
|
const client = await generatorClient(verbOption, options, outputClient);
|
|
3424
|
-
const
|
|
3435
|
+
const generatedMock = generateMock2(verbOption, options);
|
|
3425
3436
|
if (!client.implementation) {
|
|
3426
3437
|
return acc;
|
|
3427
3438
|
}
|
|
3428
3439
|
acc[verbOption.operationId] = {
|
|
3429
3440
|
implementation: verbOption.doc + client.implementation,
|
|
3430
3441
|
imports: client.imports,
|
|
3431
|
-
|
|
3432
|
-
|
|
3442
|
+
// @ts-expect-error // FIXME
|
|
3443
|
+
implementationMock: generatedMock.implementation,
|
|
3444
|
+
// @ts-expect-error // FIXME
|
|
3445
|
+
importsMock: generatedMock.imports,
|
|
3433
3446
|
tags: verbOption.tags,
|
|
3434
3447
|
mutator: verbOption.mutator,
|
|
3435
3448
|
clientMutators: client.mutators,
|
|
@@ -3515,9 +3528,11 @@ var getApiBuilder = async ({
|
|
|
3515
3528
|
pathRoute,
|
|
3516
3529
|
override: output.override,
|
|
3517
3530
|
context: resolvedContext,
|
|
3518
|
-
mock:
|
|
3531
|
+
mock: output.mock,
|
|
3532
|
+
// @ts-expect-error // FIXME
|
|
3519
3533
|
output: output.target
|
|
3520
|
-
}
|
|
3534
|
+
},
|
|
3535
|
+
output
|
|
3521
3536
|
);
|
|
3522
3537
|
acc.schemas.push(...schemas);
|
|
3523
3538
|
acc.operations = { ...acc.operations, ...pathOperations };
|
|
@@ -3535,7 +3550,7 @@ var getApiBuilder = async ({
|
|
|
3535
3550
|
header: generateClientHeader,
|
|
3536
3551
|
footer: generateClientFooter,
|
|
3537
3552
|
imports: generateClientImports,
|
|
3538
|
-
importsMock:
|
|
3553
|
+
importsMock: import_mock.generateMockImports
|
|
3539
3554
|
};
|
|
3540
3555
|
};
|
|
3541
3556
|
|
|
@@ -3551,6 +3566,7 @@ var importOpenApi = async ({
|
|
|
3551
3566
|
const specs = await generateInputSpecs({ specs: data, input, workspace });
|
|
3552
3567
|
const schemas = getApiSchemas({ output, target, workspace, specs });
|
|
3553
3568
|
const api = await getApiBuilder({
|
|
3569
|
+
// @ts-expect-error // FIXME
|
|
3554
3570
|
input,
|
|
3555
3571
|
output,
|
|
3556
3572
|
context: {
|
|
@@ -3731,6 +3747,7 @@ var importSpecs = async (workspace, options) => {
|
|
|
3731
3747
|
if ((0, import_core4.isObject)(input.target)) {
|
|
3732
3748
|
return importOpenApi({
|
|
3733
3749
|
data: { [workspace]: input.target },
|
|
3750
|
+
// @ts-expect-error // FIXME
|
|
3734
3751
|
input,
|
|
3735
3752
|
output,
|
|
3736
3753
|
target: workspace,
|
|
@@ -3739,6 +3756,7 @@ var importSpecs = async (workspace, options) => {
|
|
|
3739
3756
|
}
|
|
3740
3757
|
const isPathUrl = (0, import_core4.isUrl)(input.target);
|
|
3741
3758
|
const data = await resolveSpecs(
|
|
3759
|
+
// @ts-expect-error // FIXME
|
|
3742
3760
|
input.target,
|
|
3743
3761
|
input.parserOptions,
|
|
3744
3762
|
isPathUrl,
|
|
@@ -3746,8 +3764,10 @@ var importSpecs = async (workspace, options) => {
|
|
|
3746
3764
|
);
|
|
3747
3765
|
return importOpenApi({
|
|
3748
3766
|
data,
|
|
3767
|
+
// @ts-expect-error // FIXME
|
|
3749
3768
|
input,
|
|
3750
3769
|
output,
|
|
3770
|
+
// @ts-expect-error // FIXME
|
|
3751
3771
|
target: input.target,
|
|
3752
3772
|
workspace
|
|
3753
3773
|
});
|
|
@@ -3755,13 +3775,14 @@ var importSpecs = async (workspace, options) => {
|
|
|
3755
3775
|
|
|
3756
3776
|
// src/utils/options.ts
|
|
3757
3777
|
var import_core7 = require("@orval/core");
|
|
3778
|
+
var import_mock2 = require("@orval/mock");
|
|
3758
3779
|
var import_chalk2 = __toESM(require("chalk"));
|
|
3759
3780
|
|
|
3760
3781
|
// package.json
|
|
3761
3782
|
var package_default = {
|
|
3762
3783
|
name: "orval",
|
|
3763
3784
|
description: "A swagger client generator for typescript",
|
|
3764
|
-
version: "6.
|
|
3785
|
+
version: "6.22.0",
|
|
3765
3786
|
license: "MIT",
|
|
3766
3787
|
files: [
|
|
3767
3788
|
"dist"
|
|
@@ -3804,7 +3825,8 @@ var package_default = {
|
|
|
3804
3825
|
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --dts",
|
|
3805
3826
|
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --watch ./src --onSuccess 'yarn generate-api'",
|
|
3806
3827
|
lint: "eslint src/**/*.ts",
|
|
3807
|
-
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts"
|
|
3828
|
+
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts",
|
|
3829
|
+
test: "tsc --noEmit && vitest --passWithNoTests"
|
|
3808
3830
|
},
|
|
3809
3831
|
devDependencies: {
|
|
3810
3832
|
"@types/inquirer": "^9.0.6",
|
|
@@ -3813,13 +3835,13 @@ var package_default = {
|
|
|
3813
3835
|
},
|
|
3814
3836
|
dependencies: {
|
|
3815
3837
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
3816
|
-
"@orval/angular": "6.
|
|
3817
|
-
"@orval/axios": "6.
|
|
3818
|
-
"@orval/core": "6.
|
|
3819
|
-
"@orval/
|
|
3820
|
-
"@orval/query": "6.
|
|
3821
|
-
"@orval/swr": "6.
|
|
3822
|
-
"@orval/zod": "6.
|
|
3838
|
+
"@orval/angular": "6.22.0",
|
|
3839
|
+
"@orval/axios": "6.22.0",
|
|
3840
|
+
"@orval/core": "6.22.0",
|
|
3841
|
+
"@orval/mock": "6.22.0",
|
|
3842
|
+
"@orval/query": "6.22.0",
|
|
3843
|
+
"@orval/swr": "6.22.0",
|
|
3844
|
+
"@orval/zod": "6.22.0",
|
|
3823
3845
|
ajv: "^8.12.0",
|
|
3824
3846
|
cac: "^6.7.14",
|
|
3825
3847
|
chalk: "^4.1.2",
|
|
@@ -3827,7 +3849,7 @@ var package_default = {
|
|
|
3827
3849
|
enquirer: "^2.4.1",
|
|
3828
3850
|
execa: "^5.1.1",
|
|
3829
3851
|
"find-up": "5.0.0",
|
|
3830
|
-
"fs-extra": "^
|
|
3852
|
+
"fs-extra": "^11.2.0",
|
|
3831
3853
|
"lodash.uniq": "^4.5.0",
|
|
3832
3854
|
"openapi-types": "^12.1.3",
|
|
3833
3855
|
"openapi3-ts": "^3.2.0",
|
|
@@ -4045,7 +4067,7 @@ var loadTsconfig = async (tsconfig, workspace = process.cwd()) => {
|
|
|
4045
4067
|
|
|
4046
4068
|
// src/utils/options.ts
|
|
4047
4069
|
var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
|
|
4048
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja;
|
|
4070
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma;
|
|
4049
4071
|
const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
|
|
4050
4072
|
if (!options.input) {
|
|
4051
4073
|
(0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
|
|
@@ -4061,7 +4083,7 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4061
4083
|
outputOptions.workspace || "",
|
|
4062
4084
|
workspace
|
|
4063
4085
|
);
|
|
4064
|
-
const { clean, prettier, client, mode,
|
|
4086
|
+
const { clean, prettier, client, mode, tslint } = globalOptions;
|
|
4065
4087
|
const tsconfig = await loadTsconfig(
|
|
4066
4088
|
outputOptions.tsconfig || globalOptions.tsconfig,
|
|
4067
4089
|
workspace
|
|
@@ -4070,20 +4092,31 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4070
4092
|
outputOptions.packageJson || globalOptions.packageJson,
|
|
4071
4093
|
workspace
|
|
4072
4094
|
);
|
|
4095
|
+
let mock2 = (_a = outputOptions.mock) != null ? _a : globalOptions.mock;
|
|
4096
|
+
if (typeof mock2 === "boolean" && mock2) {
|
|
4097
|
+
mock2 = import_mock2.DEFAULT_MOCK_OPTIONS;
|
|
4098
|
+
} else if (!mock2) {
|
|
4099
|
+
mock2 = void 0;
|
|
4100
|
+
} else {
|
|
4101
|
+
mock2 = {
|
|
4102
|
+
...import_mock2.DEFAULT_MOCK_OPTIONS,
|
|
4103
|
+
...mock2
|
|
4104
|
+
};
|
|
4105
|
+
}
|
|
4073
4106
|
const normalizedOptions = {
|
|
4074
4107
|
input: {
|
|
4075
4108
|
target: globalOptions.input ? normalizePathOrUrl(globalOptions.input, process.cwd()) : normalizePathOrUrl(inputOptions.target, workspace),
|
|
4076
4109
|
validation: inputOptions.validation || false,
|
|
4077
4110
|
override: {
|
|
4078
4111
|
transformer: normalizePath(
|
|
4079
|
-
(
|
|
4112
|
+
(_b = inputOptions.override) == null ? void 0 : _b.transformer,
|
|
4080
4113
|
workspace
|
|
4081
4114
|
)
|
|
4082
4115
|
},
|
|
4083
|
-
converterOptions: (
|
|
4116
|
+
converterOptions: (_c = inputOptions.converterOptions) != null ? _c : {},
|
|
4084
4117
|
parserOptions: (0, import_core7.mergeDeep)(
|
|
4085
4118
|
parserDefaultOptions,
|
|
4086
|
-
(
|
|
4119
|
+
(_d = inputOptions.parserOptions) != null ? _d : {}
|
|
4087
4120
|
),
|
|
4088
4121
|
filters: inputOptions.filters
|
|
4089
4122
|
},
|
|
@@ -4091,83 +4124,86 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4091
4124
|
target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
|
|
4092
4125
|
schemas: normalizePath(outputOptions.schemas, outputWorkspace),
|
|
4093
4126
|
workspace: outputOptions.workspace ? outputWorkspace : void 0,
|
|
4094
|
-
client: (
|
|
4095
|
-
mode: normalizeOutputMode((
|
|
4096
|
-
mock:
|
|
4097
|
-
clean: (
|
|
4098
|
-
prettier: (
|
|
4099
|
-
tslint: (
|
|
4127
|
+
client: (_f = (_e = outputOptions.client) != null ? _e : client) != null ? _f : import_core7.OutputClient.AXIOS_FUNCTIONS,
|
|
4128
|
+
mode: normalizeOutputMode((_g = outputOptions.mode) != null ? _g : mode),
|
|
4129
|
+
mock: mock2,
|
|
4130
|
+
clean: (_i = (_h = outputOptions.clean) != null ? _h : clean) != null ? _i : false,
|
|
4131
|
+
prettier: (_k = (_j = outputOptions.prettier) != null ? _j : prettier) != null ? _k : false,
|
|
4132
|
+
tslint: (_m = (_l = outputOptions.tslint) != null ? _l : tslint) != null ? _m : false,
|
|
4100
4133
|
tsconfig,
|
|
4101
4134
|
packageJson,
|
|
4102
|
-
headers: (
|
|
4103
|
-
indexFiles: (
|
|
4135
|
+
headers: (_n = outputOptions.headers) != null ? _n : false,
|
|
4136
|
+
indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
|
|
4104
4137
|
baseUrl: outputOptions.baseUrl,
|
|
4105
4138
|
override: {
|
|
4106
4139
|
...outputOptions.override,
|
|
4107
4140
|
mock: {
|
|
4108
|
-
arrayMin: (
|
|
4109
|
-
arrayMax: (
|
|
4110
|
-
...(
|
|
4141
|
+
arrayMin: (_r = (_q = (_p = outputOptions.override) == null ? void 0 : _p.mock) == null ? void 0 : _q.arrayMin) != null ? _r : 1,
|
|
4142
|
+
arrayMax: (_u = (_t = (_s = outputOptions.override) == null ? void 0 : _s.mock) == null ? void 0 : _t.arrayMax) != null ? _u : 10,
|
|
4143
|
+
...(_w = (_v = outputOptions.override) == null ? void 0 : _v.mock) != null ? _w : {}
|
|
4111
4144
|
},
|
|
4112
4145
|
operations: normalizeOperationsAndTags(
|
|
4113
|
-
(
|
|
4146
|
+
(_y = (_x = outputOptions.override) == null ? void 0 : _x.operations) != null ? _y : {},
|
|
4114
4147
|
outputWorkspace
|
|
4115
4148
|
),
|
|
4116
4149
|
tags: normalizeOperationsAndTags(
|
|
4117
|
-
(
|
|
4150
|
+
(_A = (_z = outputOptions.override) == null ? void 0 : _z.tags) != null ? _A : {},
|
|
4118
4151
|
outputWorkspace
|
|
4119
4152
|
),
|
|
4120
4153
|
mutator: normalizeMutator(
|
|
4121
4154
|
outputWorkspace,
|
|
4122
|
-
(
|
|
4155
|
+
(_B = outputOptions.override) == null ? void 0 : _B.mutator
|
|
4123
4156
|
),
|
|
4124
|
-
formData: (
|
|
4157
|
+
formData: (_F = !(0, import_core7.isBoolean)((_C = outputOptions.override) == null ? void 0 : _C.formData) ? normalizeMutator(
|
|
4125
4158
|
outputWorkspace,
|
|
4126
|
-
(
|
|
4127
|
-
) : (
|
|
4128
|
-
formUrlEncoded: (
|
|
4159
|
+
(_D = outputOptions.override) == null ? void 0 : _D.formData
|
|
4160
|
+
) : (_E = outputOptions.override) == null ? void 0 : _E.formData) != null ? _F : true,
|
|
4161
|
+
formUrlEncoded: (_J = !(0, import_core7.isBoolean)((_G = outputOptions.override) == null ? void 0 : _G.formUrlEncoded) ? normalizeMutator(
|
|
4129
4162
|
outputWorkspace,
|
|
4130
|
-
(
|
|
4131
|
-
) : (
|
|
4163
|
+
(_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded
|
|
4164
|
+
) : (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded) != null ? _J : true,
|
|
4132
4165
|
paramsSerializer: normalizeMutator(
|
|
4133
4166
|
outputWorkspace,
|
|
4134
|
-
(
|
|
4167
|
+
(_K = outputOptions.override) == null ? void 0 : _K.paramsSerializer
|
|
4135
4168
|
),
|
|
4136
|
-
header: ((
|
|
4137
|
-
requestOptions: (
|
|
4169
|
+
header: ((_L = outputOptions.override) == null ? void 0 : _L.header) === false ? false : (0, import_core7.isFunction)((_M = outputOptions.override) == null ? void 0 : _M.header) ? (_N = outputOptions.override) == null ? void 0 : _N.header : getDefaultFilesHeader,
|
|
4170
|
+
requestOptions: (_P = (_O = outputOptions.override) == null ? void 0 : _O.requestOptions) != null ? _P : true,
|
|
4138
4171
|
components: {
|
|
4139
4172
|
schemas: {
|
|
4140
4173
|
suffix: import_core7.RefComponentSuffix.schemas,
|
|
4141
|
-
...(
|
|
4174
|
+
...(_S = (_R = (_Q = outputOptions.override) == null ? void 0 : _Q.components) == null ? void 0 : _R.schemas) != null ? _S : {}
|
|
4142
4175
|
},
|
|
4143
4176
|
responses: {
|
|
4144
4177
|
suffix: import_core7.RefComponentSuffix.responses,
|
|
4145
|
-
...(
|
|
4178
|
+
...(_V = (_U = (_T = outputOptions.override) == null ? void 0 : _T.components) == null ? void 0 : _U.responses) != null ? _V : {}
|
|
4146
4179
|
},
|
|
4147
4180
|
parameters: {
|
|
4148
4181
|
suffix: import_core7.RefComponentSuffix.parameters,
|
|
4149
|
-
...(
|
|
4182
|
+
...(_Y = (_X = (_W = outputOptions.override) == null ? void 0 : _W.components) == null ? void 0 : _X.parameters) != null ? _Y : {}
|
|
4150
4183
|
},
|
|
4151
4184
|
requestBodies: {
|
|
4152
4185
|
suffix: import_core7.RefComponentSuffix.requestBodies,
|
|
4153
|
-
...(
|
|
4186
|
+
...(_$ = (__ = (_Z = outputOptions.override) == null ? void 0 : _Z.components) == null ? void 0 : __.requestBodies) != null ? _$ : {}
|
|
4154
4187
|
}
|
|
4155
4188
|
},
|
|
4156
4189
|
query: {
|
|
4157
4190
|
useQuery: true,
|
|
4158
4191
|
useMutation: true,
|
|
4159
4192
|
signal: true,
|
|
4160
|
-
...normalizeQueryOptions((
|
|
4193
|
+
...normalizeQueryOptions((_aa = outputOptions.override) == null ? void 0 : _aa.query, workspace)
|
|
4161
4194
|
},
|
|
4162
4195
|
swr: {
|
|
4163
|
-
...(
|
|
4196
|
+
...(_ca = (_ba = outputOptions.override) == null ? void 0 : _ba.swr) != null ? _ca : {}
|
|
4164
4197
|
},
|
|
4165
4198
|
angular: {
|
|
4166
|
-
provideIn: (
|
|
4199
|
+
provideIn: (_fa = (_ea = (_da = outputOptions.override) == null ? void 0 : _da.angular) == null ? void 0 : _ea.provideIn) != null ? _fa : "root"
|
|
4167
4200
|
},
|
|
4168
|
-
useDates: ((
|
|
4169
|
-
useDeprecatedOperations: (
|
|
4170
|
-
|
|
4201
|
+
useDates: ((_ga = outputOptions.override) == null ? void 0 : _ga.useDates) || false,
|
|
4202
|
+
useDeprecatedOperations: (_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.useDeprecatedOperations) != null ? _ia : true,
|
|
4203
|
+
useNativeEnums: (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.useNativeEnums) != null ? _ka : false
|
|
4204
|
+
},
|
|
4205
|
+
allParamsOptional: (_la = outputOptions.allParamsOptional) != null ? _la : false,
|
|
4206
|
+
urlEncodeParameters: (_ma = outputOptions.urlEncodeParameters) != null ? _ma : false
|
|
4171
4207
|
},
|
|
4172
4208
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
4173
4209
|
};
|
|
@@ -4445,7 +4481,9 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4445
4481
|
}
|
|
4446
4482
|
if (output.workspace) {
|
|
4447
4483
|
const workspacePath = output.workspace;
|
|
4448
|
-
let imports = implementationPaths.filter(
|
|
4484
|
+
let imports = implementationPaths.filter(
|
|
4485
|
+
(path) => !output.mock || !path.endsWith(`.${(0, import_core10.getMockFileExtensionByTypeName)(output.mock)}.ts`)
|
|
4486
|
+
).map(
|
|
4449
4487
|
(path) => import_core10.upath.relativeSafe(
|
|
4450
4488
|
workspacePath,
|
|
4451
4489
|
(0, import_core10.getFileInfo)(path).pathWithoutExtension
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// ../../node_modules/lodash.omit/index.js
|
|
34
34
|
var require_lodash = __commonJS({
|
|
35
35
|
"../../node_modules/lodash.omit/index.js"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
36
37
|
var LARGE_ARRAY_SIZE = 200;
|
|
37
38
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
38
39
|
var INFINITY = 1 / 0;
|
|
@@ -3263,28 +3264,28 @@ var import_lodash = __toESM(require_lodash());
|
|
|
3263
3264
|
|
|
3264
3265
|
// src/api.ts
|
|
3265
3266
|
var import_core2 = require("@orval/core");
|
|
3266
|
-
var
|
|
3267
|
+
var import_mock = require("@orval/mock");
|
|
3267
3268
|
|
|
3268
3269
|
// src/client.ts
|
|
3269
3270
|
var import_angular = __toESM(require("@orval/angular"));
|
|
3270
3271
|
var import_axios = __toESM(require("@orval/axios"));
|
|
3271
3272
|
var import_core = require("@orval/core");
|
|
3272
|
-
var
|
|
3273
|
+
var mock = __toESM(require("@orval/mock"));
|
|
3273
3274
|
var import_query = __toESM(require("@orval/query"));
|
|
3274
3275
|
var import_swr = __toESM(require("@orval/swr"));
|
|
3275
3276
|
var import_zod = __toESM(require("@orval/zod"));
|
|
3276
3277
|
var DEFAULT_CLIENT = import_core.OutputClient.AXIOS;
|
|
3277
|
-
var
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3278
|
+
var getGeneratorClient = (outputClient, output) => {
|
|
3279
|
+
const GENERATOR_CLIENT = {
|
|
3280
|
+
axios: (0, import_axios.default)({ type: "axios" })(),
|
|
3281
|
+
"axios-functions": (0, import_axios.default)({ type: "axios-functions" })(),
|
|
3282
|
+
angular: (0, import_angular.default)()(),
|
|
3283
|
+
"react-query": (0, import_query.default)({ output, type: "react-query" })(),
|
|
3284
|
+
"svelte-query": (0, import_query.default)({ output, type: "svelte-query" })(),
|
|
3285
|
+
"vue-query": (0, import_query.default)({ output, type: "vue-query" })(),
|
|
3286
|
+
swr: (0, import_swr.default)()(),
|
|
3287
|
+
zod: (0, import_zod.default)()()
|
|
3288
|
+
};
|
|
3288
3289
|
const generator = (0, import_core.isFunction)(outputClient) ? outputClient(GENERATOR_CLIENT) : GENERATOR_CLIENT[outputClient];
|
|
3289
3290
|
if (!generator) {
|
|
3290
3291
|
throw `Oups... \u{1F37B}. Client not found: ${outputClient}`;
|
|
@@ -3300,9 +3301,10 @@ var generateClientImports = ({
|
|
|
3300
3301
|
isAllowSyntheticDefaultImports,
|
|
3301
3302
|
hasGlobalMutator,
|
|
3302
3303
|
hasParamsSerializerOptions,
|
|
3303
|
-
packageJson
|
|
3304
|
+
packageJson,
|
|
3305
|
+
output
|
|
3304
3306
|
}) => {
|
|
3305
|
-
const { dependencies } = getGeneratorClient(client);
|
|
3307
|
+
const { dependencies } = getGeneratorClient(client, output);
|
|
3306
3308
|
return (0, import_core.generateDependencyImports)(
|
|
3307
3309
|
implementation,
|
|
3308
3310
|
dependencies ? [
|
|
@@ -3325,9 +3327,10 @@ var generateClientHeader = ({
|
|
|
3325
3327
|
isMutator,
|
|
3326
3328
|
provideIn,
|
|
3327
3329
|
hasAwaitedType,
|
|
3328
|
-
titles
|
|
3330
|
+
titles,
|
|
3331
|
+
output
|
|
3329
3332
|
}) => {
|
|
3330
|
-
const { header } = getGeneratorClient(outputClient);
|
|
3333
|
+
const { header } = getGeneratorClient(outputClient, output);
|
|
3331
3334
|
return {
|
|
3332
3335
|
implementation: header ? header({
|
|
3333
3336
|
title: titles.implementation,
|
|
@@ -3337,7 +3340,7 @@ var generateClientHeader = ({
|
|
|
3337
3340
|
provideIn,
|
|
3338
3341
|
hasAwaitedType
|
|
3339
3342
|
}) : "",
|
|
3340
|
-
|
|
3343
|
+
implementationMock: `export const ${titles.implementationMock} = () => [
|
|
3341
3344
|
`
|
|
3342
3345
|
};
|
|
3343
3346
|
};
|
|
@@ -3346,13 +3349,14 @@ var generateClientFooter = ({
|
|
|
3346
3349
|
operationNames,
|
|
3347
3350
|
hasMutator,
|
|
3348
3351
|
hasAwaitedType,
|
|
3349
|
-
titles
|
|
3352
|
+
titles,
|
|
3353
|
+
output
|
|
3350
3354
|
}) => {
|
|
3351
|
-
const { footer } = getGeneratorClient(outputClient);
|
|
3355
|
+
const { footer } = getGeneratorClient(outputClient, output);
|
|
3352
3356
|
if (!footer) {
|
|
3353
3357
|
return {
|
|
3354
3358
|
implementation: "",
|
|
3355
|
-
|
|
3359
|
+
implementationMock: `]
|
|
3356
3360
|
`
|
|
3357
3361
|
};
|
|
3358
3362
|
}
|
|
@@ -3383,35 +3387,36 @@ var generateClientFooter = ({
|
|
|
3383
3387
|
}
|
|
3384
3388
|
return {
|
|
3385
3389
|
implementation,
|
|
3386
|
-
|
|
3390
|
+
implementationMock: `]
|
|
3387
3391
|
`
|
|
3388
3392
|
};
|
|
3389
3393
|
};
|
|
3390
3394
|
var generateClientTitle = ({
|
|
3391
3395
|
outputClient = DEFAULT_CLIENT,
|
|
3392
3396
|
title,
|
|
3393
|
-
customTitleFunc
|
|
3397
|
+
customTitleFunc,
|
|
3398
|
+
output
|
|
3394
3399
|
}) => {
|
|
3395
|
-
const { title: generatorTitle } = getGeneratorClient(outputClient);
|
|
3400
|
+
const { title: generatorTitle } = getGeneratorClient(outputClient, output);
|
|
3396
3401
|
if (!generatorTitle) {
|
|
3397
3402
|
return {
|
|
3398
3403
|
implementation: "",
|
|
3399
|
-
|
|
3404
|
+
implementationMock: `get${(0, import_core.pascal)(title)}Mock`
|
|
3400
3405
|
};
|
|
3401
3406
|
}
|
|
3402
3407
|
if (customTitleFunc) {
|
|
3403
3408
|
const customTitle = customTitleFunc(title);
|
|
3404
3409
|
return {
|
|
3405
3410
|
implementation: generatorTitle(customTitle),
|
|
3406
|
-
|
|
3411
|
+
implementationMock: `get${(0, import_core.pascal)(customTitle)}Mock`
|
|
3407
3412
|
};
|
|
3408
3413
|
}
|
|
3409
3414
|
return {
|
|
3410
3415
|
implementation: generatorTitle(title),
|
|
3411
|
-
|
|
3416
|
+
implementationMock: `get${(0, import_core.pascal)(title)}Mock`
|
|
3412
3417
|
};
|
|
3413
3418
|
};
|
|
3414
|
-
var
|
|
3419
|
+
var generateMock2 = (verbOption, options) => {
|
|
3415
3420
|
if (!options.mock) {
|
|
3416
3421
|
return {
|
|
3417
3422
|
implementation: {
|
|
@@ -3424,23 +3429,31 @@ var generateMock = (verbOption, options) => {
|
|
|
3424
3429
|
if ((0, import_core.isFunction)(options.mock)) {
|
|
3425
3430
|
return options.mock(verbOption, options);
|
|
3426
3431
|
}
|
|
3427
|
-
return
|
|
3432
|
+
return mock.generateMock(
|
|
3433
|
+
verbOption,
|
|
3434
|
+
options
|
|
3435
|
+
);
|
|
3428
3436
|
};
|
|
3429
|
-
var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options) => {
|
|
3437
|
+
var generateOperations = (outputClient = DEFAULT_CLIENT, verbsOptions, options, output) => {
|
|
3430
3438
|
return (0, import_core.asyncReduce)(
|
|
3431
3439
|
verbsOptions,
|
|
3432
3440
|
async (acc, verbOption) => {
|
|
3433
|
-
const { client: generatorClient } = getGeneratorClient(
|
|
3441
|
+
const { client: generatorClient } = getGeneratorClient(
|
|
3442
|
+
outputClient,
|
|
3443
|
+
output
|
|
3444
|
+
);
|
|
3434
3445
|
const client = await generatorClient(verbOption, options, outputClient);
|
|
3435
|
-
const
|
|
3446
|
+
const generatedMock = generateMock2(verbOption, options);
|
|
3436
3447
|
if (!client.implementation) {
|
|
3437
3448
|
return acc;
|
|
3438
3449
|
}
|
|
3439
3450
|
acc[verbOption.operationId] = {
|
|
3440
3451
|
implementation: verbOption.doc + client.implementation,
|
|
3441
3452
|
imports: client.imports,
|
|
3442
|
-
|
|
3443
|
-
|
|
3453
|
+
// @ts-expect-error // FIXME
|
|
3454
|
+
implementationMock: generatedMock.implementation,
|
|
3455
|
+
// @ts-expect-error // FIXME
|
|
3456
|
+
importsMock: generatedMock.imports,
|
|
3444
3457
|
tags: verbOption.tags,
|
|
3445
3458
|
mutator: verbOption.mutator,
|
|
3446
3459
|
clientMutators: client.mutators,
|
|
@@ -3526,9 +3539,11 @@ var getApiBuilder = async ({
|
|
|
3526
3539
|
pathRoute,
|
|
3527
3540
|
override: output.override,
|
|
3528
3541
|
context: resolvedContext,
|
|
3529
|
-
mock:
|
|
3542
|
+
mock: output.mock,
|
|
3543
|
+
// @ts-expect-error // FIXME
|
|
3530
3544
|
output: output.target
|
|
3531
|
-
}
|
|
3545
|
+
},
|
|
3546
|
+
output
|
|
3532
3547
|
);
|
|
3533
3548
|
acc.schemas.push(...schemas);
|
|
3534
3549
|
acc.operations = { ...acc.operations, ...pathOperations };
|
|
@@ -3546,7 +3561,7 @@ var getApiBuilder = async ({
|
|
|
3546
3561
|
header: generateClientHeader,
|
|
3547
3562
|
footer: generateClientFooter,
|
|
3548
3563
|
imports: generateClientImports,
|
|
3549
|
-
importsMock:
|
|
3564
|
+
importsMock: import_mock.generateMockImports
|
|
3550
3565
|
};
|
|
3551
3566
|
};
|
|
3552
3567
|
|
|
@@ -3562,6 +3577,7 @@ var importOpenApi = async ({
|
|
|
3562
3577
|
const specs = await generateInputSpecs({ specs: data, input, workspace });
|
|
3563
3578
|
const schemas = getApiSchemas({ output, target, workspace, specs });
|
|
3564
3579
|
const api = await getApiBuilder({
|
|
3580
|
+
// @ts-expect-error // FIXME
|
|
3565
3581
|
input,
|
|
3566
3582
|
output,
|
|
3567
3583
|
context: {
|
|
@@ -3742,6 +3758,7 @@ var importSpecs = async (workspace, options) => {
|
|
|
3742
3758
|
if ((0, import_core4.isObject)(input.target)) {
|
|
3743
3759
|
return importOpenApi({
|
|
3744
3760
|
data: { [workspace]: input.target },
|
|
3761
|
+
// @ts-expect-error // FIXME
|
|
3745
3762
|
input,
|
|
3746
3763
|
output,
|
|
3747
3764
|
target: workspace,
|
|
@@ -3750,6 +3767,7 @@ var importSpecs = async (workspace, options) => {
|
|
|
3750
3767
|
}
|
|
3751
3768
|
const isPathUrl = (0, import_core4.isUrl)(input.target);
|
|
3752
3769
|
const data = await resolveSpecs(
|
|
3770
|
+
// @ts-expect-error // FIXME
|
|
3753
3771
|
input.target,
|
|
3754
3772
|
input.parserOptions,
|
|
3755
3773
|
isPathUrl,
|
|
@@ -3757,8 +3775,10 @@ var importSpecs = async (workspace, options) => {
|
|
|
3757
3775
|
);
|
|
3758
3776
|
return importOpenApi({
|
|
3759
3777
|
data,
|
|
3778
|
+
// @ts-expect-error // FIXME
|
|
3760
3779
|
input,
|
|
3761
3780
|
output,
|
|
3781
|
+
// @ts-expect-error // FIXME
|
|
3762
3782
|
target: input.target,
|
|
3763
3783
|
workspace
|
|
3764
3784
|
});
|
|
@@ -3766,13 +3786,14 @@ var importSpecs = async (workspace, options) => {
|
|
|
3766
3786
|
|
|
3767
3787
|
// src/utils/options.ts
|
|
3768
3788
|
var import_core7 = require("@orval/core");
|
|
3789
|
+
var import_mock2 = require("@orval/mock");
|
|
3769
3790
|
var import_chalk2 = __toESM(require("chalk"));
|
|
3770
3791
|
|
|
3771
3792
|
// package.json
|
|
3772
3793
|
var package_default = {
|
|
3773
3794
|
name: "orval",
|
|
3774
3795
|
description: "A swagger client generator for typescript",
|
|
3775
|
-
version: "6.
|
|
3796
|
+
version: "6.22.0",
|
|
3776
3797
|
license: "MIT",
|
|
3777
3798
|
files: [
|
|
3778
3799
|
"dist"
|
|
@@ -3815,7 +3836,8 @@ var package_default = {
|
|
|
3815
3836
|
build: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --dts",
|
|
3816
3837
|
dev: "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --watch ./src --onSuccess 'yarn generate-api'",
|
|
3817
3838
|
lint: "eslint src/**/*.ts",
|
|
3818
|
-
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts"
|
|
3839
|
+
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts",
|
|
3840
|
+
test: "tsc --noEmit && vitest --passWithNoTests"
|
|
3819
3841
|
},
|
|
3820
3842
|
devDependencies: {
|
|
3821
3843
|
"@types/inquirer": "^9.0.6",
|
|
@@ -3824,13 +3846,13 @@ var package_default = {
|
|
|
3824
3846
|
},
|
|
3825
3847
|
dependencies: {
|
|
3826
3848
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
3827
|
-
"@orval/angular": "6.
|
|
3828
|
-
"@orval/axios": "6.
|
|
3829
|
-
"@orval/core": "6.
|
|
3830
|
-
"@orval/
|
|
3831
|
-
"@orval/query": "6.
|
|
3832
|
-
"@orval/swr": "6.
|
|
3833
|
-
"@orval/zod": "6.
|
|
3849
|
+
"@orval/angular": "6.22.0",
|
|
3850
|
+
"@orval/axios": "6.22.0",
|
|
3851
|
+
"@orval/core": "6.22.0",
|
|
3852
|
+
"@orval/mock": "6.22.0",
|
|
3853
|
+
"@orval/query": "6.22.0",
|
|
3854
|
+
"@orval/swr": "6.22.0",
|
|
3855
|
+
"@orval/zod": "6.22.0",
|
|
3834
3856
|
ajv: "^8.12.0",
|
|
3835
3857
|
cac: "^6.7.14",
|
|
3836
3858
|
chalk: "^4.1.2",
|
|
@@ -3838,7 +3860,7 @@ var package_default = {
|
|
|
3838
3860
|
enquirer: "^2.4.1",
|
|
3839
3861
|
execa: "^5.1.1",
|
|
3840
3862
|
"find-up": "5.0.0",
|
|
3841
|
-
"fs-extra": "^
|
|
3863
|
+
"fs-extra": "^11.2.0",
|
|
3842
3864
|
"lodash.uniq": "^4.5.0",
|
|
3843
3865
|
"openapi-types": "^12.1.3",
|
|
3844
3866
|
"openapi3-ts": "^3.2.0",
|
|
@@ -4059,7 +4081,7 @@ function defineConfig(options) {
|
|
|
4059
4081
|
return options;
|
|
4060
4082
|
}
|
|
4061
4083
|
var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOptions = {}) => {
|
|
4062
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja;
|
|
4084
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma;
|
|
4063
4085
|
const options = await ((0, import_core7.isFunction)(optionsExport) ? optionsExport() : optionsExport);
|
|
4064
4086
|
if (!options.input) {
|
|
4065
4087
|
(0, import_core7.createLogger)().error(import_chalk2.default.red(`Config require an input`));
|
|
@@ -4075,7 +4097,7 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4075
4097
|
outputOptions.workspace || "",
|
|
4076
4098
|
workspace
|
|
4077
4099
|
);
|
|
4078
|
-
const { clean, prettier, client, mode,
|
|
4100
|
+
const { clean, prettier, client, mode, tslint } = globalOptions;
|
|
4079
4101
|
const tsconfig = await loadTsconfig(
|
|
4080
4102
|
outputOptions.tsconfig || globalOptions.tsconfig,
|
|
4081
4103
|
workspace
|
|
@@ -4084,20 +4106,31 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4084
4106
|
outputOptions.packageJson || globalOptions.packageJson,
|
|
4085
4107
|
workspace
|
|
4086
4108
|
);
|
|
4109
|
+
let mock2 = (_a = outputOptions.mock) != null ? _a : globalOptions.mock;
|
|
4110
|
+
if (typeof mock2 === "boolean" && mock2) {
|
|
4111
|
+
mock2 = import_mock2.DEFAULT_MOCK_OPTIONS;
|
|
4112
|
+
} else if (!mock2) {
|
|
4113
|
+
mock2 = void 0;
|
|
4114
|
+
} else {
|
|
4115
|
+
mock2 = {
|
|
4116
|
+
...import_mock2.DEFAULT_MOCK_OPTIONS,
|
|
4117
|
+
...mock2
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4087
4120
|
const normalizedOptions = {
|
|
4088
4121
|
input: {
|
|
4089
4122
|
target: globalOptions.input ? normalizePathOrUrl(globalOptions.input, process.cwd()) : normalizePathOrUrl(inputOptions.target, workspace),
|
|
4090
4123
|
validation: inputOptions.validation || false,
|
|
4091
4124
|
override: {
|
|
4092
4125
|
transformer: normalizePath(
|
|
4093
|
-
(
|
|
4126
|
+
(_b = inputOptions.override) == null ? void 0 : _b.transformer,
|
|
4094
4127
|
workspace
|
|
4095
4128
|
)
|
|
4096
4129
|
},
|
|
4097
|
-
converterOptions: (
|
|
4130
|
+
converterOptions: (_c = inputOptions.converterOptions) != null ? _c : {},
|
|
4098
4131
|
parserOptions: (0, import_core7.mergeDeep)(
|
|
4099
4132
|
parserDefaultOptions,
|
|
4100
|
-
(
|
|
4133
|
+
(_d = inputOptions.parserOptions) != null ? _d : {}
|
|
4101
4134
|
),
|
|
4102
4135
|
filters: inputOptions.filters
|
|
4103
4136
|
},
|
|
@@ -4105,83 +4138,86 @@ var normalizeOptions = async (optionsExport, workspace = process.cwd(), globalOp
|
|
|
4105
4138
|
target: globalOptions.output ? normalizePath(globalOptions.output, process.cwd()) : normalizePath(outputOptions.target, outputWorkspace),
|
|
4106
4139
|
schemas: normalizePath(outputOptions.schemas, outputWorkspace),
|
|
4107
4140
|
workspace: outputOptions.workspace ? outputWorkspace : void 0,
|
|
4108
|
-
client: (
|
|
4109
|
-
mode: normalizeOutputMode((
|
|
4110
|
-
mock:
|
|
4111
|
-
clean: (
|
|
4112
|
-
prettier: (
|
|
4113
|
-
tslint: (
|
|
4141
|
+
client: (_f = (_e = outputOptions.client) != null ? _e : client) != null ? _f : import_core7.OutputClient.AXIOS_FUNCTIONS,
|
|
4142
|
+
mode: normalizeOutputMode((_g = outputOptions.mode) != null ? _g : mode),
|
|
4143
|
+
mock: mock2,
|
|
4144
|
+
clean: (_i = (_h = outputOptions.clean) != null ? _h : clean) != null ? _i : false,
|
|
4145
|
+
prettier: (_k = (_j = outputOptions.prettier) != null ? _j : prettier) != null ? _k : false,
|
|
4146
|
+
tslint: (_m = (_l = outputOptions.tslint) != null ? _l : tslint) != null ? _m : false,
|
|
4114
4147
|
tsconfig,
|
|
4115
4148
|
packageJson,
|
|
4116
|
-
headers: (
|
|
4117
|
-
indexFiles: (
|
|
4149
|
+
headers: (_n = outputOptions.headers) != null ? _n : false,
|
|
4150
|
+
indexFiles: (_o = outputOptions.indexFiles) != null ? _o : true,
|
|
4118
4151
|
baseUrl: outputOptions.baseUrl,
|
|
4119
4152
|
override: {
|
|
4120
4153
|
...outputOptions.override,
|
|
4121
4154
|
mock: {
|
|
4122
|
-
arrayMin: (
|
|
4123
|
-
arrayMax: (
|
|
4124
|
-
...(
|
|
4155
|
+
arrayMin: (_r = (_q = (_p = outputOptions.override) == null ? void 0 : _p.mock) == null ? void 0 : _q.arrayMin) != null ? _r : 1,
|
|
4156
|
+
arrayMax: (_u = (_t = (_s = outputOptions.override) == null ? void 0 : _s.mock) == null ? void 0 : _t.arrayMax) != null ? _u : 10,
|
|
4157
|
+
...(_w = (_v = outputOptions.override) == null ? void 0 : _v.mock) != null ? _w : {}
|
|
4125
4158
|
},
|
|
4126
4159
|
operations: normalizeOperationsAndTags(
|
|
4127
|
-
(
|
|
4160
|
+
(_y = (_x = outputOptions.override) == null ? void 0 : _x.operations) != null ? _y : {},
|
|
4128
4161
|
outputWorkspace
|
|
4129
4162
|
),
|
|
4130
4163
|
tags: normalizeOperationsAndTags(
|
|
4131
|
-
(
|
|
4164
|
+
(_A = (_z = outputOptions.override) == null ? void 0 : _z.tags) != null ? _A : {},
|
|
4132
4165
|
outputWorkspace
|
|
4133
4166
|
),
|
|
4134
4167
|
mutator: normalizeMutator(
|
|
4135
4168
|
outputWorkspace,
|
|
4136
|
-
(
|
|
4169
|
+
(_B = outputOptions.override) == null ? void 0 : _B.mutator
|
|
4137
4170
|
),
|
|
4138
|
-
formData: (
|
|
4171
|
+
formData: (_F = !(0, import_core7.isBoolean)((_C = outputOptions.override) == null ? void 0 : _C.formData) ? normalizeMutator(
|
|
4139
4172
|
outputWorkspace,
|
|
4140
|
-
(
|
|
4141
|
-
) : (
|
|
4142
|
-
formUrlEncoded: (
|
|
4173
|
+
(_D = outputOptions.override) == null ? void 0 : _D.formData
|
|
4174
|
+
) : (_E = outputOptions.override) == null ? void 0 : _E.formData) != null ? _F : true,
|
|
4175
|
+
formUrlEncoded: (_J = !(0, import_core7.isBoolean)((_G = outputOptions.override) == null ? void 0 : _G.formUrlEncoded) ? normalizeMutator(
|
|
4143
4176
|
outputWorkspace,
|
|
4144
|
-
(
|
|
4145
|
-
) : (
|
|
4177
|
+
(_H = outputOptions.override) == null ? void 0 : _H.formUrlEncoded
|
|
4178
|
+
) : (_I = outputOptions.override) == null ? void 0 : _I.formUrlEncoded) != null ? _J : true,
|
|
4146
4179
|
paramsSerializer: normalizeMutator(
|
|
4147
4180
|
outputWorkspace,
|
|
4148
|
-
(
|
|
4181
|
+
(_K = outputOptions.override) == null ? void 0 : _K.paramsSerializer
|
|
4149
4182
|
),
|
|
4150
|
-
header: ((
|
|
4151
|
-
requestOptions: (
|
|
4183
|
+
header: ((_L = outputOptions.override) == null ? void 0 : _L.header) === false ? false : (0, import_core7.isFunction)((_M = outputOptions.override) == null ? void 0 : _M.header) ? (_N = outputOptions.override) == null ? void 0 : _N.header : getDefaultFilesHeader,
|
|
4184
|
+
requestOptions: (_P = (_O = outputOptions.override) == null ? void 0 : _O.requestOptions) != null ? _P : true,
|
|
4152
4185
|
components: {
|
|
4153
4186
|
schemas: {
|
|
4154
4187
|
suffix: import_core7.RefComponentSuffix.schemas,
|
|
4155
|
-
...(
|
|
4188
|
+
...(_S = (_R = (_Q = outputOptions.override) == null ? void 0 : _Q.components) == null ? void 0 : _R.schemas) != null ? _S : {}
|
|
4156
4189
|
},
|
|
4157
4190
|
responses: {
|
|
4158
4191
|
suffix: import_core7.RefComponentSuffix.responses,
|
|
4159
|
-
...(
|
|
4192
|
+
...(_V = (_U = (_T = outputOptions.override) == null ? void 0 : _T.components) == null ? void 0 : _U.responses) != null ? _V : {}
|
|
4160
4193
|
},
|
|
4161
4194
|
parameters: {
|
|
4162
4195
|
suffix: import_core7.RefComponentSuffix.parameters,
|
|
4163
|
-
...(
|
|
4196
|
+
...(_Y = (_X = (_W = outputOptions.override) == null ? void 0 : _W.components) == null ? void 0 : _X.parameters) != null ? _Y : {}
|
|
4164
4197
|
},
|
|
4165
4198
|
requestBodies: {
|
|
4166
4199
|
suffix: import_core7.RefComponentSuffix.requestBodies,
|
|
4167
|
-
...(
|
|
4200
|
+
...(_$ = (__ = (_Z = outputOptions.override) == null ? void 0 : _Z.components) == null ? void 0 : __.requestBodies) != null ? _$ : {}
|
|
4168
4201
|
}
|
|
4169
4202
|
},
|
|
4170
4203
|
query: {
|
|
4171
4204
|
useQuery: true,
|
|
4172
4205
|
useMutation: true,
|
|
4173
4206
|
signal: true,
|
|
4174
|
-
...normalizeQueryOptions((
|
|
4207
|
+
...normalizeQueryOptions((_aa = outputOptions.override) == null ? void 0 : _aa.query, workspace)
|
|
4175
4208
|
},
|
|
4176
4209
|
swr: {
|
|
4177
|
-
...(
|
|
4210
|
+
...(_ca = (_ba = outputOptions.override) == null ? void 0 : _ba.swr) != null ? _ca : {}
|
|
4178
4211
|
},
|
|
4179
4212
|
angular: {
|
|
4180
|
-
provideIn: (
|
|
4213
|
+
provideIn: (_fa = (_ea = (_da = outputOptions.override) == null ? void 0 : _da.angular) == null ? void 0 : _ea.provideIn) != null ? _fa : "root"
|
|
4181
4214
|
},
|
|
4182
|
-
useDates: ((
|
|
4183
|
-
useDeprecatedOperations: (
|
|
4184
|
-
|
|
4215
|
+
useDates: ((_ga = outputOptions.override) == null ? void 0 : _ga.useDates) || false,
|
|
4216
|
+
useDeprecatedOperations: (_ia = (_ha = outputOptions.override) == null ? void 0 : _ha.useDeprecatedOperations) != null ? _ia : true,
|
|
4217
|
+
useNativeEnums: (_ka = (_ja = outputOptions.override) == null ? void 0 : _ja.useNativeEnums) != null ? _ka : false
|
|
4218
|
+
},
|
|
4219
|
+
allParamsOptional: (_la = outputOptions.allParamsOptional) != null ? _la : false,
|
|
4220
|
+
urlEncodeParameters: (_ma = outputOptions.urlEncodeParameters) != null ? _ma : false
|
|
4185
4221
|
},
|
|
4186
4222
|
hooks: options.hooks ? normalizeHooks(options.hooks) : {}
|
|
4187
4223
|
};
|
|
@@ -4459,7 +4495,9 @@ var writeSpecs = async (builder, workspace, options, projectName) => {
|
|
|
4459
4495
|
}
|
|
4460
4496
|
if (output.workspace) {
|
|
4461
4497
|
const workspacePath = output.workspace;
|
|
4462
|
-
let imports = implementationPaths.filter(
|
|
4498
|
+
let imports = implementationPaths.filter(
|
|
4499
|
+
(path) => !output.mock || !path.endsWith(`.${(0, import_core10.getMockFileExtensionByTypeName)(output.mock)}.ts`)
|
|
4500
|
+
).map(
|
|
4463
4501
|
(path) => import_core10.upath.relativeSafe(
|
|
4464
4502
|
workspacePath,
|
|
4465
4503
|
(0, import_core10.getFileInfo)(path).pathWithoutExtension
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orval",
|
|
3
3
|
"description": "A swagger client generator for typescript",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.22.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"build": "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --dts",
|
|
45
45
|
"dev": "tsup ./src/bin/orval.ts ./src/index.ts --target node12 --clean --watch ./src --onSuccess 'yarn generate-api'",
|
|
46
46
|
"lint": "eslint src/**/*.ts",
|
|
47
|
-
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts"
|
|
47
|
+
"generate-api": "node ./dist/bin/orval.js --config ../../samples/react-query/basic/orval.config.ts",
|
|
48
|
+
"test": "tsc --noEmit && vitest --passWithNoTests"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/inquirer": "^9.0.6",
|
|
@@ -53,13 +54,13 @@
|
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
56
|
-
"@orval/angular": "6.
|
|
57
|
-
"@orval/axios": "6.
|
|
58
|
-
"@orval/core": "6.
|
|
59
|
-
"@orval/
|
|
60
|
-
"@orval/query": "6.
|
|
61
|
-
"@orval/swr": "6.
|
|
62
|
-
"@orval/zod": "6.
|
|
57
|
+
"@orval/angular": "6.22.0",
|
|
58
|
+
"@orval/axios": "6.22.0",
|
|
59
|
+
"@orval/core": "6.22.0",
|
|
60
|
+
"@orval/mock": "6.22.0",
|
|
61
|
+
"@orval/query": "6.22.0",
|
|
62
|
+
"@orval/swr": "6.22.0",
|
|
63
|
+
"@orval/zod": "6.22.0",
|
|
63
64
|
"ajv": "^8.12.0",
|
|
64
65
|
"cac": "^6.7.14",
|
|
65
66
|
"chalk": "^4.1.2",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"enquirer": "^2.4.1",
|
|
68
69
|
"execa": "^5.1.1",
|
|
69
70
|
"find-up": "5.0.0",
|
|
70
|
-
"fs-extra": "^
|
|
71
|
+
"fs-extra": "^11.2.0",
|
|
71
72
|
"lodash.uniq": "^4.5.0",
|
|
72
73
|
"openapi-types": "^12.1.3",
|
|
73
74
|
"openapi3-ts": "^3.2.0",
|