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.01k stars 328 forks source link

ReactQuery: params not convert case. #1657

Open Bill-Park opened 3 weeks ago

Bill-Park commented 3 weeks ago

What are the steps to reproduce this issue?

  1. My openapi input is json type and use snake_case.
  2. When create react-query, I got params with snake_case.

What happens?

Typescript use variables as camelCase. My API server need snake_case but I concider to set customInstance with axios-case-converter.

Are there any solution or update for this?

What were you expecting to happen?

Add case-convert option for configuration and step for params case convert.

Any logs, error output, etc?

image

What versions are you using?

  System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 57.17 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  npmPackages:
    @tanstack/react-query: ^5.56.2 => 5.56.2 
    axios: ^1.7.2 => 1.7.2 
    msw: ^2.3.1 => 2.3.1 
    orval: ^7.1.1 => 7.1.1 
    react: ^18.2.0 => 18.2.0 
pedsm commented 1 week ago

There are ways to handle this with a custom client,

In the example here https://orval.dev/guides/custom-client you can find some of it.

If you combine this with ts-case-convert you can get a pretty solid, solution. Can't quite produce an example of it now but if you. can't figure it out let me know and I can probably put something together