orval-labs / 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
3.21k stars 337 forks source link

Orval overuses `AnyOf` types delimiter #1644

Open jaxxreal opened 1 month ago

jaxxreal commented 1 month ago

What are the steps to reproduce this issue?

  1. Generate orval client with the following config:
    export default defineConfig({
    apiClient: {
    input: {
      target: 'http://localhost:3001/swagger-json',
    },
    output: {
      target: './src/client/orval.ts',
      schemas: './src/orval-types',
      mode: 'single',
      client: 'swr',
      override: {
        mutator: {
          path: './src/client/httpClient.ts',
          name: 'makeRequest',
        },
        useNamedParameters: true
      },
    },
    hooks: {
      afterAllFilesWrite: 'eslint --fix',
    },
    },
    });

What happens?

Look at the types generated. Names like ListOfActivitiesResponseAnyOfDataAnyOfItemAnyOfAttributesAnyOfDataAnyOfItemAnyOfTargetAnyOfId are pretty common. OpenAPI schema for the given example has NO anyOf conditions.

What were you expecting to happen?

If an OpenAPI spec has no anyOf condition I don't expect to see them on my types. So the expected type name would be: ListOfActivitiesResponseDataItemAttributesDataItemTargetId

Any logs, error output, etc?

-

Any other comments?

It's an issue because nearly every single generated file has a decent amount of AnyOf.

I know that the project is looking for contributors, so I would appreciate minimal guidance on where to start my search for a solution. Maybe it's a configuration issue? Please let me know.

What versions are you using?

orval@6.28.2

Please execute npx envinfo --system --npmPackages orval,zod,axios,msw,swr,@tanstack/react-query,@tanstack/vue-query,react,vue and paste the results here.

System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 94.64 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh