Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pzeinlinger opened this issue Feb 18, 2025 · 0 comments
Labels
bug 🔥 Something isn't working

Comments

@pzeinlinger
Copy link

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

@pzeinlinger pzeinlinger added the bug 🔥 Something isn't working label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant