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

Overwriting schema names #1658

Open
razzeee opened this issue Oct 9, 2024 · 0 comments
Open

Overwriting schema names #1658

razzeee opened this issue Oct 9, 2024 · 0 comments

Comments

@razzeee
Copy link

razzeee commented Oct 9, 2024

What are the steps to reproduce this issue?

  1. Write an orval config consuming two apis
import { InfoObject } from "openapi3-ts/oas30"

import { defineConfig } from "orval"

export default defineConfig({
  "one": {
    output: {
      workspace: "src/api",
      client: "react-query",
      mode: "tags-split",
      mock: true,
      prettier: true,
      clean: true,
      override: {
        query: {
          useQuery: true,
          useSuspenseQuery: true,
        },
        header: (info: InfoObject): string[] => [
          `Generated by orval 🍺`,
          `Do not edit manually.`,
          ...(info.title ? [info.title] : []),
          ...(info.description ? [info.description] : []),
          ...(info.version ? [`OpenAPI spec version: ${info.version}`] : []),
        ],
      },
    },
    input: {
      target: "./one.openapi.yaml",
    },
  },
  "two": {
    output: {
      workspace: "src/api",
      client: "react-query",
      mode: "tags-split",
      mock: true,
      prettier: true,
      clean: true,
      override: {
        query: {
          useQuery: true,
          useSuspenseQuery: true,
        },
        header: (info: InfoObject): string[] => [
          `Generated by orval 🍺`,
          `Do not edit manually.`,
          ...(info.title ? [info.title] : []),
          ...(info.description ? [info.description] : []),
          ...(info.version ? [`OpenAPI spec version: ${info.version}`] : []),
        ],
      },
    },
    input: {
      target: "./two.openapi.yaml",
    },
  }
  1. Run orval to generate

What happens?

Get errors in src/api/index.ts as the names are the same

What were you expecting to happen?

I can't find a way to change the generated schema names
Operation names seem solveable by doing

{
 override: {
         operationName: (operation, route, verb) => {
          return `two${operation.operationId}`
        }
  }
}

What versions are you using?

System:
OS: Linux 6.10 Fedora Linux 40 (Workstation Edition)
CPU: (16) x64 AMD Ryzen 7 PRO 8840U w/ Radeon 780M Graphics
Memory: 11.21 GB / 30.00 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
npmPackages:
@tanstack/react-query: ^5.52.2 => 5.52.2
axios: ^1.7.2 => 1.7.5
msw: ^2.3.5 => 2.3.5
orval: ^7.0.1 => 7.0.1
react: ^18.3.1 => 18.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant