Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The generated types.gen.ts do not escape apostrophes #1501

Open
ThomasCedrini opened this issue Dec 22, 2024 · 1 comment
Open

The generated types.gen.ts do not escape apostrophes #1501

ThomasCedrini opened this issue Dec 22, 2024 · 1 comment
Labels
bug 🔥 Something isn't working

Comments

@ThomasCedrini
Copy link

ThomasCedrini commented Dec 22, 2024

Description

Hello,

I noticed that whenever there is an apostrophe in an enum, the generator does not escape it in the types. The result is that the syntax of types.gen.ts is wrong.

Reproducible example or configuration

Using this dummy openapi file to generate the API :

openapi: 3.0.0
info:
  title: Hey API Generator example with apostroph
  description: Minimal reproductible openapi file for the non-escaped apostroph in the generated types.
  version: 0.0.1

paths:
  /users:
    get:
      responses:
        "200":
          description: A JSON array of user names
          content:
            application/json:
              schema:
                type: string
                enum:
                  - "test1"
                  - "test'2"

With this configuration :

// openapi-ts.config.ts
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
  client: "@hey-api/client-axios",
  input: "./openapi.yaml",
  output: {
    format: "prettier",
    path: "./src/client",
    lint: "eslint",
  },
  plugins: ["@hey-api/typescript", { asClass: false, name: "@hey-api/sdk" }],
});

Produces this types.gen.ts file

// This file is auto-generated by @hey-api/openapi-ts

export type GetUsersResponse = ('test1' | 'test'2');

export type GetUsersError = unknown;

OpenAPI specification (optional)

No response

System information (optional)

Deps :

  • "@hey-api/client-axios": "^0.3.4",

Dev deps :

  • "@hey-api/openapi-ts": "^0.60.1",
@ThomasCedrini ThomasCedrini added the bug 🔥 Something isn't working label Dec 22, 2024
@mrlubos
Copy link
Member

mrlubos commented Dec 22, 2024

Hi @ThomasCedrini, check out the update on the experimental parser https://github.com/orgs/hey-api/discussions/1495

Switching to it should resolve the issue! https://heyapi.dev/openapi-ts/configuration#parser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants