@orval/core 8.9.0 → 8.9.1
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/index.d.mts +6 -4
- package/dist/index.mjs +29 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -959,6 +959,8 @@ interface GeneratorClient {
|
|
|
959
959
|
implementation: string;
|
|
960
960
|
imports: GeneratorImport[];
|
|
961
961
|
mutators?: GeneratorMutator[];
|
|
962
|
+
/** When set, overrides the default verbOption.doc prepended to the implementation */
|
|
963
|
+
docComment?: string;
|
|
962
964
|
}
|
|
963
965
|
interface GeneratorMutatorParsingInfo {
|
|
964
966
|
numberOfParams: number;
|
|
@@ -1643,10 +1645,10 @@ declare function combineSchemas({
|
|
|
1643
1645
|
declare function resolveDiscriminators(schemas: OpenApiSchemasObject, context: ContextSpec): OpenApiSchemasObject;
|
|
1644
1646
|
//#endregion
|
|
1645
1647
|
//#region src/getters/enum.d.ts
|
|
1646
|
-
declare function getEnumNames(schemaObject: OpenApiSchemaObject | undefined): string[] | undefined;
|
|
1647
|
-
declare function getEnumDescriptions(schemaObject: OpenApiSchemaObject | undefined): string[] | undefined;
|
|
1648
|
-
declare function getEnum(value: string, enumName: string, names: string[] | undefined, enumGenerationType: EnumGeneration, descriptions?: string[], enumNamingConvention?: NamingConvention): string;
|
|
1649
|
-
declare function getEnumImplementation(value: string, names?: string[], descriptions?: string[], enumNamingConvention?: NamingConvention): string;
|
|
1648
|
+
declare function getEnumNames(schemaObject: OpenApiSchemaObject | undefined): (string | undefined)[] | undefined;
|
|
1649
|
+
declare function getEnumDescriptions(schemaObject: OpenApiSchemaObject | undefined): (string | undefined)[] | undefined;
|
|
1650
|
+
declare function getEnum(value: string, enumName: string, names: (string | undefined)[] | undefined, enumGenerationType: EnumGeneration, descriptions?: (string | undefined)[], enumNamingConvention?: NamingConvention): string;
|
|
1651
|
+
declare function getEnumImplementation(value: string, names?: (string | undefined)[], descriptions?: (string | undefined)[], enumNamingConvention?: NamingConvention): string;
|
|
1650
1652
|
interface CombinedEnumInput {
|
|
1651
1653
|
value: string;
|
|
1652
1654
|
isRef: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1038,12 +1038,20 @@ function replaceSpecialCharacters(key) {
|
|
|
1038
1038
|
function getEnumNames(schemaObject) {
|
|
1039
1039
|
const names = schemaObject?.["x-enumNames"] ?? schemaObject?.["x-enumnames"] ?? schemaObject?.["x-enum-varnames"];
|
|
1040
1040
|
if (!names) return;
|
|
1041
|
-
return names.map((name) => jsStringEscape(name));
|
|
1041
|
+
if (Array.isArray(names)) return names.map((name) => jsStringEscape(name));
|
|
1042
|
+
if (typeof names === "object") return (schemaObject?.enum ?? []).map((enumVal) => {
|
|
1043
|
+
const key = String(enumVal);
|
|
1044
|
+
return key in names ? jsStringEscape(names[key]) : void 0;
|
|
1045
|
+
});
|
|
1042
1046
|
}
|
|
1043
1047
|
function getEnumDescriptions(schemaObject) {
|
|
1044
1048
|
const descriptions = schemaObject?.["x-enumDescriptions"] ?? schemaObject?.["x-enumdescriptions"] ?? schemaObject?.["x-enum-descriptions"];
|
|
1045
1049
|
if (!descriptions) return;
|
|
1046
|
-
return descriptions.map((description) => jsStringEscape(description));
|
|
1050
|
+
if (Array.isArray(descriptions)) return descriptions.map((description) => jsStringEscape(description));
|
|
1051
|
+
if (typeof descriptions === "object") return (schemaObject?.enum ?? []).map((enumVal) => {
|
|
1052
|
+
const key = String(enumVal);
|
|
1053
|
+
return key in descriptions ? jsStringEscape(descriptions[key]) : void 0;
|
|
1054
|
+
});
|
|
1047
1055
|
}
|
|
1048
1056
|
function getEnum(value, enumName, names, enumGenerationType, descriptions, enumNamingConvention) {
|
|
1049
1057
|
if (enumGenerationType === EnumGeneration.CONST) return getTypeConstEnum(value, enumName, names, descriptions, enumNamingConvention);
|
|
@@ -2273,6 +2281,8 @@ function getObject({ item, name, context, nullable, formDataContext }) {
|
|
|
2273
2281
|
const keyType = getIndexSignatureKey(schemaItem);
|
|
2274
2282
|
acc.value += `\n [key: ${keyType}]: ${resolvedValue.value};\n}`;
|
|
2275
2283
|
}
|
|
2284
|
+
acc.imports.push(...resolvedValue.imports);
|
|
2285
|
+
acc.schemas.push(...resolvedValue.schemas);
|
|
2276
2286
|
acc.dependencies.push(...resolvedValue.dependencies);
|
|
2277
2287
|
}
|
|
2278
2288
|
else acc.value += "\n}";
|
|
@@ -3274,18 +3284,18 @@ function addDependency({ implementation, exports, dependency, projectName, isAll
|
|
|
3274
3284
|
});
|
|
3275
3285
|
if (types.length > 0) {
|
|
3276
3286
|
let uniqueTypes = types;
|
|
3277
|
-
if (values.length > 0)
|
|
3278
|
-
|
|
3279
|
-
dep += "\n";
|
|
3287
|
+
if (values.length > 0) uniqueTypes = types.filter((t) => !values.some((v) => v.name === t.name && (v.alias ?? "") === (t.alias ?? "")));
|
|
3288
|
+
if (uniqueTypes.length > 0) {
|
|
3289
|
+
if (values.length > 0) dep += "\n";
|
|
3290
|
+
dep += generateDependency({
|
|
3291
|
+
deps: uniqueTypes,
|
|
3292
|
+
isAllowSyntheticDefaultImports,
|
|
3293
|
+
dependency,
|
|
3294
|
+
projectName,
|
|
3295
|
+
key,
|
|
3296
|
+
onlyTypes: true
|
|
3297
|
+
});
|
|
3280
3298
|
}
|
|
3281
|
-
dep += generateDependency({
|
|
3282
|
-
deps: uniqueTypes,
|
|
3283
|
-
isAllowSyntheticDefaultImports,
|
|
3284
|
-
dependency,
|
|
3285
|
-
projectName,
|
|
3286
|
-
key,
|
|
3287
|
-
onlyTypes: true
|
|
3288
|
-
});
|
|
3289
3299
|
}
|
|
3290
3300
|
return dep;
|
|
3291
3301
|
}).join("\n") + "\n";
|
|
@@ -4644,8 +4654,8 @@ async function writeSplitMode({ builder, output, projectName, header, needSchema
|
|
|
4644
4654
|
isAllowSyntheticDefaultImports,
|
|
4645
4655
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4646
4656
|
});
|
|
4647
|
-
const schemasPath = output.schemas
|
|
4648
|
-
if (schemasPath
|
|
4657
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
4658
|
+
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4649
4659
|
if (mutators) implementationData += generateMutatorImports({
|
|
4650
4660
|
mutators,
|
|
4651
4661
|
implementation
|
|
@@ -4853,8 +4863,8 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
|
|
|
4853
4863
|
isAllowSyntheticDefaultImports,
|
|
4854
4864
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4855
4865
|
});
|
|
4856
|
-
const schemasPath = output.schemas
|
|
4857
|
-
if (schemasPath
|
|
4866
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
4867
|
+
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4858
4868
|
if (mutators) implementationData += generateMutatorImports({
|
|
4859
4869
|
mutators,
|
|
4860
4870
|
implementation,
|
|
@@ -4962,8 +4972,8 @@ async function writeTagsMode({ builder, output, projectName, header, needSchema,
|
|
|
4962
4972
|
options: isFunction(output.mock) ? void 0 : output.mock
|
|
4963
4973
|
});
|
|
4964
4974
|
}
|
|
4965
|
-
const schemasPath = output.schemas
|
|
4966
|
-
if (schemasPath
|
|
4975
|
+
const schemasPath = !output.schemas && needSchema ? nodePath.join(dirname, filename + ".schemas" + extension) : void 0;
|
|
4976
|
+
if (schemasPath) await writeGeneratedFile(schemasPath, generateSchemasInline ? header + generateSchemasInline() : header + generateModelsInline(builder.schemas));
|
|
4967
4977
|
if (mutators) data += generateMutatorImports({
|
|
4968
4978
|
mutators,
|
|
4969
4979
|
implementation
|