hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.43k stars 106 forks source link

@hey-api/client-fetch is incompatible with `asClass: true` #1097

Closed danilofuchs closed 2 weeks ago

danilofuchs commented 2 months ago

Description

We really like using class services in our tRPC router, as it avoids the need for passing client to every request

As it is server side, we don't care about code splitting

When using both @hey-api/client-fetch and asClass: true, the output is broken:

Reproducible example or configuration

https://github.com/danilofuchs/openapi-ts-repro

import { defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({
  input:
    "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/refs/heads/main/examples/v3.0/api-with-examples.yaml",
  output: {
    path: "src/server",
  },
  client: "@hey-api/client-fetch",
  name: "Service",
  services: {
    asClass: true,
  },
});

OpenAPI specification (optional)

No response

System information (optional)

No response

mrlubos commented 2 months ago

@danilofuchs Remove the ‘name` option, that's what's causing the trouble

Iczp commented 2 months ago

我也遇到了同样的问题,他 service.name 取的是 operation.description 的值