orval icon indicating copy to clipboard operation
orval copied to clipboard

Zod generate big files

Open mortezakarimi opened this issue 1 year ago • 3 comments

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).+/],
      },
    },
  },
})

mortezakarimi avatar Jun 23 '24 09:06 mortezakarimi

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 avatar Jun 23 '24 11:06 melloware

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

mortezakarimi avatar Jun 23 '24 13:06 mortezakarimi

Understood

melloware avatar Jun 23 '24 14:06 melloware