hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
MIT License
743 stars 58 forks source link

Proper support for integer types #751

Closed mfinelli closed 1 week ago

mfinelli commented 2 weeks ago

Description

In my openapi spec I define integers like int32 or int64, which this library then uses directly instead of number and so I get errors like E: Cannot find name 'int32'.. Could this library return proper number types for these integers? (Also int8, int16)

OpenAPI specification (optional)

paths:
  /test:
    get:
      summary: Show the problem
      parameters:
        - name: page
          in: query
          description: If specified, returns a single page of results
          schema:
            type: int32

Configuration

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

export default defineConfig({
  client: "@hey-api/client-fetch",
  input: "openapi.yaml",
  output: "src/lib/client",
  types: {
    dates: "types+transform",
  },
});

System information (optional)

node --version
v20.15.0
npm --version
10.7.0
mrlubos commented 2 weeks ago

Hey @mfinelli, can you please provide a reproducible StackBlitz example?

mfinelli commented 1 week ago

Hi @mrlubos, it turns out that this was a problem with my openapi spec. For the schema I need to use type: integer and format: int32 or format: int64 and everything works as expected. Sorry for the noise