Skip to content

Invalid Zod output for basic objectΒ #3036

@benbrandt

Description

@benbrandt

Description

When having a basic object type, the produced Zod validator is missing a keyParam

It is generating

z.record(z.unknown())

When it should be

z.record(z.string(), z.unknown())

Reproducible example or configuration

For some reason I can't get this to work in stackblitz, but this is roughly the minimal requirement:

export default defineConfig({
  input: {
    openapi: '3.1.0',
    info: {
      title: 'Eample',
      version: '1.0.0',
    },
    components: {
      schemas: {
        example: {
          properties: {
            _meta: {
              additionalProperties: {},
              description: 'hi',
              type: ['object', 'null'],
            },
          },
          type: 'object',
        },
      },
    },
  },
  output: {
    path: './src/schema',
  },
  plugins: ['@hey-api/transformers', '@hey-api/typescript', 'zod'],
});

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug πŸ”₯Something isn't workingjavascriptPull requests that update Javascript code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions