anymaniax / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.59k stars 290 forks source link

Zod generate big files #1477

Open mortezakarimi opened 3 weeks ago

mortezakarimi commented 3 weeks ago

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 commented 3 weeks ago

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?

mortezakarimi commented 3 weeks ago

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 commented 3 weeks ago

Understood