astahmer / openapi-zod-client

Generate a zodios (typescript http client with zod validation) from an OpenAPI spec (json/yaml)
openapi-zod-client.vercel.app
734 stars 82 forks source link

additionalProps type evalulation seems to have issues #215

Open PeterMK85 opened 1 year ago

PeterMK85 commented 1 year ago

Describe the bug With --export-types options the following declarations:

    Order:
      type: object
      additionalProperties:
          type: string

!Note: no properties defined

Will evaluate to:

type Order = {}

I think it should be: Easy fix:

type Order = {[key: string]: string}

Or

type Order = Record<string, string>

As a workaround, I tried the following:

    Order:
      type: object
      properties: {}
      additionalProperties:
          type: string

Which yields to:

type Order = Partial<{} & {[key: string]: string}>

Minimal reproduction Online example (Modified the Order)

Expected behavior I have a local patch to make it work I will open a PR today.

Additional context Rootcause