hey-api / openapi-ts

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

Core files not included in generated types #1208

Closed mdole closed 3 weeks ago

mdole commented 3 weeks ago

Description

Hey! I'm trying to set up heyapi's type generation with @hey-api/openapi-ts, and the generated files are trying to import files from a core directory that doesn't exist.

Steps to reproduce (or see repo linked below):

  1. Create new NextJS app npx create-next-app@latest
  2. Install Hey's OpenAPI tools npm install @hey-api/openapi-ts -D
  3. Create config file (see below)
  4. Run curl https://petstore.swagger.io/v2/swagger.json -o src/clients/openapi.json && npx openapi-ts
  5. Note that the newly-created test.ts file has several broken imports

Let me know if I'm missing something obvious! And thanks for making a cool tool :)

Reproducible example or configuration

Config:

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

export default defineConfig({
  input: "src/clients/openapi.json",
  output: "src/clients",
  client: "@hey-api/client-fetch",
  base: "http://localhost:3002",
  name: "test",
});

Full repo example: https://github.com/mdole/heyapi-openapi-test

OpenAPI specification (optional)

No response

System information (optional)

No response

mrlubos commented 3 weeks ago

Hey @mdole! Where did you get the base and name options from? For client packages, base will have no impact as it's configured during runtime. name has an impact but not a positive one as you found out 😀 wonder where you got that from and what your intent is by using that value, since it's not documented on the website. Are you able to remove both of these options?

mrlubos commented 3 weeks ago

And to explain why those options exist, they're from the legacy package and are intended to work with the legacy clients only

mdole commented 3 weeks ago

Hey @mdole! Where did you get the base and name options from? For client packages, base will have no impact as it's configured during runtime. name has an impact but not a positive one as you found out 😀 wonder where you got that from and what your intent is by using that value, since it's not documented on the website. Are you able to remove both of these options?

Ah good callout! I started with a config for an older version that we were using for a different repo. Removing those options fixed the issue!

Thanks for the âš¡ fast response :)

mrlubos commented 3 weeks ago

I think you finally made me inspect this configuration and handle it in a way that doesn't cause failing output, so a good shout. You're definitely not the first person to complain about this