Skip to content

[plugin/zod] "Maximum call stack size exceeded" depending on order of schema definition #1731

Open
@pzeinlinger

Description

Description

Hi @mrlubos,

I've encountered a "Maximum call stack size exceeded" error when using the zod plugin with a recursive schema. The issue appears to be related to the order of schema definitions in the openapi.yaml file.

Steps to Reproduce:

  1. Define schemas in openapi.yaml in the order A → B.
  2. Run the build process.
  3. The build fails with the "Maximum call stack size exceeded" error.

Workaround: Reordering the schema definitions to B → A allows the build to succeed.

Other plugins work

Please let me know if more details are needed.

Reproducible example or configuration

export default defineConfig({
  input: "./openapi.yaml",
  output: "./src/client",
  plugins: ["zod"],
});

OpenAPI specification (optional)

Failing:

components:
  schemas:
    A:
      additionalProperties: false
      properties:
        b:
          $ref: "#/components/schemas/B"
      required:
        - b
      type: object
    B:
      additionalProperties: false
      properties:
        bs:
          items:
            $ref: "#/components/schemas/B"
          type:
            - array
            - "null"
      required:
        - bs
      type: object
info:
  title: API
  version: development
openapi: 3.1.0

Working:

components:
  schemas:
    B:
      additionalProperties: false
      properties:
        bs:
          items:
            $ref: "#/components/schemas/B"
          type:
            - array
            - "null"
      required:
        - bs
      type: object
    A:
      additionalProperties: false
      properties:
        b:
          $ref: "#/components/schemas/B"
      required:
        - b
      type: object
info:
  title: API
  version: development
openapi: 3.1.0


System information (optional)

@hey-api/openapi-ts: v0.64.4
node: v20.18.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions