Skip to content

if an enum value contains "/", it will be converted to "\/" since v8.15.0 #3530

@mdoi2

Description

@mdoi2

Description

#3507
fix(core): use jsStringEscape for enum/const values to prevent backslash corruption

I suspect this fix is ​​the cause, but it seems to be trying to escape not only backslashes but also slashes that don't need escaping.

Minimal reproduction

# openapi.yaml

openapi: 3.1.0
info:
  title: "api"
  version: 0.0.0
paths:
  /:
    get:
      operationId: getRoot
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: string
                enum:
                  - Asia/Tokyo
                  - America/New_York
// orval.config.ts

import { defineConfig } from 'orval';

export default defineConfig({
  api: {
    input: {
      target: './openapi.yaml',
    },
    output: {
      target: './output',
    },
  },
});
// output/api.ts

/**
 * Generated by orval v8.15.0 🍺
 * Do not edit manually.
 * api
 * OpenAPI spec version: 0.0.0
 */
import axios from 'axios';
import type {
  AxiosRequestConfig,
  AxiosResponse
} from 'axios';

export type GetRoot200 = typeof GetRoot200[keyof typeof GetRoot200];


export const GetRoot200 = {
  'Asia\/Tokyo': 'Asia\/Tokyo',
  'America\/New_York': 'America\/New_York',
} as const;

export const getRoot = (
     options?: AxiosRequestConfig
 ): Promise<AxiosResponse<GetRoot200>> => {
    return axios.get(
      `/`,options
    );
  }

export type GetRootResult = AxiosResponse<GetRoot200>

Expected behavior

Do not escape the slash.
Up to v8.14.0, the output was as expected.

export const GetRoot200 = {
  'Asia/Tokyo': 'Asia/Tokyo',
  'America/New_York': 'America/New_York',
} as const;

Environment

System:
OS: macOS 26.5
CPU: (12) arm64 Apple M2 Pro
Memory: 92.48 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
npmPackages:
orval: 8.15.0 => 8.15.0
zod: 4.4.3 => 4.4.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions