orval-labs/orval

`clean: true` deletes the entire working directory when `schemas` has no `path`

已关闭

#3,752 创建于 2026年7月22日

 (1 条评论) (0 个反应) (0 位负责人)TypeScript (648 个派生)auto 404
bughelp wanted

仓库指标

星标
 (6,272 个星标)
PR 合并指标
 (平均合并 2天 15小时) (30 天内合并 73 个 PR)

描述

Description

Repro:

mkdir repro && cd repro
echo '{"openapi":"3.0.0","info":{"title":"t","version":"1"},"paths":{}}' > openapi.json
echo "keep me" > important.txt

cat > orval.config.ts <<'EOF'
import { defineConfig } from "orval";

export default defineConfig({
  api: {
    input: "./openapi.json",
    output: {
      target: "./src/generated/api.ts",
      client: "fetch",
      httpClient: "fetch",
      schemas: { type: "zod" },   // no path
      mode: "single",
      clean: true,
      override: { fetch: { runtimeValidation: true } },
    },
  },
});
EOF

npx orval --config ./orval.config.ts

repro/ is now empty and the command errors.

Output client

fetch

Configuration (orval.config)

export default defineConfig({
  api: {
    input: "./openapi.json",
    output: {
      target: "./src/generated/api.ts",
      client: "fetch",
      httpClient: "fetch",
      schemas: { type: "zod" },   // no path
      mode: "single",
      clean: true,
      override: { fetch: { runtimeValidation: true } },
    },
  },
});

Environment

System: OS: macOS 26.5.2 CPU: (18) arm64 Apple M5 Max Memory: 70.76 GB / 128.00 GB Shell: 5.9 - /bin/zsh npmPackages: @tanstack/react-query: ^5.101.4 => 5.101.4 orval: ^8.22.0 => 8.22.0 react: ^19.2.0 => 19.2.8 zod: ^4.4.3 => 4.4.3

Expected behavior

It shouldn't wipe the entire directory

Actual behavior

It wipes the entire directory

OpenAPI document (minimal, if applicable)

openapi: 3.0.3
info:
  title: Demo
  version: 0.0.0
paths: {}

Additional context

I ran into this because an agent was setting up orval and it would keep deleting the entire directory and it couldn't figure out why, nothing in the output mentions deleting anything. I was lucky it didn't delete anything meaningful but its a real footgun

This is similar to #3538/#3657

贡献者指南