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

Zod generate big files #1477

Closed
mortezakarimi opened this issue Jun 23, 2024 · 3 comments · Fixed by #1480
Closed

Zod generate big files #1477

mortezakarimi opened this issue Jun 23, 2024 · 3 comments · Fixed by #1480
Assignees
Labels
zod Zod related issue
Milestone

Comments

@mortezakarimi
Copy link
Contributor

mortezakarimi commented Jun 23, 2024

What are the steps to reproduce this issue?

  1. have big API documentation
  2. run zod output to generate schema
  3. files generated bigger than 1MB

What happens?

Running lint and project performance decrease

What were you expecting to happen?

Use zod objects for relation data

Any logs, error output, etc?

/src/api/schemas/xyz.ts lint ━━━━━━━━━━

  × Size of src/api/schemas/xyz.ts is 1.2 MiB which exceeds configured maximum of 1.0 MiB for this project.
    The file size limit exists to prevent us inadvertently slowing down and loading large files that we shouldn't.
    Use the `files.maxSize` configuration to change the maximum size of files processed.

Any other comments?

Add ability to exclude some type of generations
for example I don't need to generate zod validation for responses

What versions are you using?

What versions are you using?
Operating System MacOS sonoma
Package Version v6.30.2
Browser Version Chrome Version 126.0.6478.115 (Official Build) (arm64)
Node Version v20.14.0

Suggestion

export default defineConfig({
  xyzProject: {
    output: {
      mode: 'tags',
      workspace: 'src/api',
      schemas: './model',
      target: './schemas',
      indexFiles: true,
      client: 'zod',
      mock: false,
      biome: true,
      override: {
        header: false,
        useDates: true,
        useNamedParameters: true,
        useNativeEnums: true,
        zod: {
          // this can be a temporary solution
          generate: {
            response: false,
            body: true,
            query: true,
          },
         // end of solution
          coerce: {
            query: true,
            param: true,
            body: true,
          },
        },
      },
    },
    input: {
      target: 'http://localhost:4000/api.json',
      validation: true,
      filters: {
        tags: [/^(?!app).+/],
      },
    },
  },
})
@melloware
Copy link
Collaborator

Can you just ignore these files in your lint setup? They are generated code so they really don't need to be linted do they?

@melloware melloware added the question Further information is requested label Jun 23, 2024
@mortezakarimi
Copy link
Contributor Author

Can you just ignore these files in your lint setup? They are generated code so they really don't need to be linted do they?

Actually, the main problem is performance issues, files are so big

@melloware
Copy link
Collaborator

Understood

@melloware melloware added zod Zod related issue and removed question Further information is requested labels Jun 23, 2024
mortezakarimi added a commit to mortezakarimi/orval that referenced this issue Jun 24, 2024
Now we can configure zod generator to generate only selected type of schemas

Closes: orval-labs#1477
@melloware melloware modified the milestones: 6.31.0, 6.32.0 Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zod Zod related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants