@orval/core 6.30.1 → 6.31.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/README.md CHANGED
@@ -26,3 +26,4 @@ You can find below some samples
26
26
  - [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
27
27
  - [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
28
28
  - [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
29
+ - [next app with fetch](https://github.com/anymaniax/orval/tree/master/samples/next-app-with-fetch)
package/dist/index.d.ts CHANGED
@@ -322,6 +322,7 @@ type ZodOptions = {
322
322
  body?: Mutator;
323
323
  response?: Mutator;
324
324
  };
325
+ generateEachHttpStatus?: boolean;
325
326
  };
326
327
  type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date';
327
328
  type NormalizedZodOptions = {
@@ -346,6 +347,7 @@ type NormalizedZodOptions = {
346
347
  body?: NormalizedMutator;
347
348
  response?: NormalizedMutator;
348
349
  };
350
+ generateEachHttpStatus: boolean;
349
351
  };
350
352
  type HonoOptions = {
351
353
  handlers?: string;
@@ -1347,19 +1349,21 @@ declare const ibmOpenapiValidator: (specs: OpenAPIObject) => Promise<void>;
1347
1349
 
1348
1350
  declare const writeModelInline: (acc: string, model: string) => string;
1349
1351
  declare const writeModelsInline: (array: GeneratorSchema[]) => string;
1350
- declare const writeSchema: ({ path, schema, target, specKey, isRootKey, specsName, header, }: {
1352
+ declare const writeSchema: ({ path, schema, target, fileExtension, specKey, isRootKey, specsName, header, }: {
1351
1353
  path: string;
1352
1354
  schema: GeneratorSchema;
1353
1355
  target: string;
1356
+ fileExtension: string;
1354
1357
  specKey: string;
1355
1358
  isRootKey: boolean;
1356
1359
  specsName: Record<string, string>;
1357
1360
  header: string;
1358
1361
  }) => Promise<void>;
1359
- declare const writeSchemas: ({ schemaPath, schemas, target, specKey, isRootKey, specsName, header, indexFiles, }: {
1362
+ declare const writeSchemas: ({ schemaPath, schemas, target, fileExtension, specKey, isRootKey, specsName, header, indexFiles, }: {
1360
1363
  schemaPath: string;
1361
1364
  schemas: GeneratorSchema[];
1362
1365
  target: string;
1366
+ fileExtension: string;
1363
1367
  specKey: string;
1364
1368
  isRootKey: boolean;
1365
1369
  specsName: Record<string, string>;
package/dist/index.js CHANGED
@@ -45575,7 +45575,7 @@ var getObject = ({
45575
45575
  if (item.additionalProperties) {
45576
45576
  if (isBoolean(item.additionalProperties)) {
45577
45577
  acc.value += `
45578
- [key: string]: any;
45578
+ [key: string]: unknown;
45579
45579
  }`;
45580
45580
  } else {
45581
45581
  const resolvedValue2 = resolveValue({
@@ -45611,7 +45611,7 @@ var getObject = ({
45611
45611
  if (item.additionalProperties) {
45612
45612
  if (isBoolean(item.additionalProperties)) {
45613
45613
  return {
45614
- value: `{ [key: string]: any }` + nullable,
45614
+ value: `{ [key: string]: unknown }` + nullable,
45615
45615
  imports: [],
45616
45616
  schemas: [],
45617
45617
  isEnum: false,
@@ -45648,7 +45648,7 @@ var getObject = ({
45648
45648
  };
45649
45649
  }
45650
45650
  return {
45651
- value: (item.type === "object" ? "{ [key: string]: any }" : "unknown") + nullable,
45651
+ value: (item.type === "object" ? "{ [key: string]: unknown }" : "unknown") + nullable,
45652
45652
  imports: [],
45653
45653
  schemas: [],
45654
45654
  isEnum: false,
@@ -47434,7 +47434,7 @@ var getSchema2 = ({
47434
47434
  file += model;
47435
47435
  return file;
47436
47436
  };
47437
- var getPath = (path2, name) => path_exports.join(path2, `/${name}.ts`);
47437
+ var getPath = (path2, name, fileExtension) => path_exports.join(path2, `/${name}${fileExtension}`);
47438
47438
  var writeModelInline = (acc, model) => acc + `${model}
47439
47439
  `;
47440
47440
  var writeModelsInline = (array) => array.reduce((acc, { model }) => writeModelInline(acc, model), "");
@@ -47442,6 +47442,7 @@ var writeSchema = async ({
47442
47442
  path: path2,
47443
47443
  schema,
47444
47444
  target,
47445
+ fileExtension,
47445
47446
  specKey,
47446
47447
  isRootKey: isRootKey2,
47447
47448
  specsName,
@@ -47450,7 +47451,7 @@ var writeSchema = async ({
47450
47451
  const name = camel(schema.name);
47451
47452
  try {
47452
47453
  await import_fs_extra2.default.outputFile(
47453
- getPath(path2, name),
47454
+ getPath(path2, name, fileExtension),
47454
47455
  getSchema2({ schema, target, isRootKey: isRootKey2, specsName, header, specKey })
47455
47456
  );
47456
47457
  } catch (e3) {
@@ -47461,6 +47462,7 @@ var writeSchemas = async ({
47461
47462
  schemaPath,
47462
47463
  schemas,
47463
47464
  target,
47465
+ fileExtension,
47464
47466
  specKey,
47465
47467
  isRootKey: isRootKey2,
47466
47468
  specsName,
@@ -47473,6 +47475,7 @@ var writeSchemas = async ({
47473
47475
  path: schemaPath,
47474
47476
  schema,
47475
47477
  target,
47478
+ fileExtension,
47476
47479
  specKey,
47477
47480
  isRootKey: isRootKey2,
47478
47481
  specsName,
@@ -47481,7 +47484,7 @@ var writeSchemas = async ({
47481
47484
  )
47482
47485
  );
47483
47486
  if (indexFiles) {
47484
- const schemaFilePath = path_exports.join(schemaPath, "/index.ts");
47487
+ const schemaFilePath = path_exports.join(schemaPath, `/index${fileExtension}`);
47485
47488
  await import_fs_extra2.default.ensureFile(schemaFilePath);
47486
47489
  const schemaNamesSet = /* @__PURE__ */ new Set();
47487
47490
  const duplicateNamesMap = /* @__PURE__ */ new Map();
@@ -47503,9 +47506,14 @@ var writeSchemas = async ({
47503
47506
  try {
47504
47507
  const data = await import_fs_extra2.default.readFile(schemaFilePath);
47505
47508
  const stringData = data.toString();
47509
+ const ext = fileExtension.endsWith(".ts") ? fileExtension.slice(0, -3) : fileExtension;
47506
47510
  const importStatements = schemas.filter((schema) => {
47507
- return !stringData.includes(`export * from './${camel(schema.name)}'`) && !stringData.includes(`export * from "./${camel(schema.name)}"`);
47508
- }).map((schema) => `export * from './${camel(schema.name)}';`);
47511
+ return !stringData.includes(
47512
+ `export * from './${camel(schema.name)}${ext}'`
47513
+ ) && !stringData.includes(
47514
+ `export * from "./${camel(schema.name)}${ext}"`
47515
+ );
47516
+ }).map((schema) => `export * from './${camel(schema.name)}${ext}';`);
47509
47517
  const currentFileExports = stringData.match(/export \* from(.*)('|")/g)?.map((s2) => s2 + ";") ?? [];
47510
47518
  const exports2 = [...currentFileExports, ...importStatements].sort().join("\n");
47511
47519
  const fileContent = `${header}