https://github.com/christian-draeger/orval-name-override-example
https://github.com/christian-draeger/orval-name-override-example
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/christian-draeger/orval-name-override-example
- Owner: christian-draeger
- Created: 2023-07-17T11:38:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T08:39:07.000Z (about 2 years ago)
- Last Synced: 2024-12-25T19:23:44.559Z (10 months ago)
- Language: TypeScript
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Orval Name Override Example
An Example Project to showcase how to avoid name conflicts with Orval.
This Project generates models and clients based on 2 different open-api specs, which both have a models and operations
with the same name.The goal is to be able to:
1. Generate models and react-query hooks without name clashes
1. Create barrel file exports without clashes ==> see [Problem](#problem)## Run Orval
```shell
npm run generate-api
```#### Problem
Generated barrel file will clash because of export name duplications:## Solution
### 🤔 1. Generate models and react-query hooks without name clashes
💡Putting the output of the generated models and react-query hooks in different folders.
⚠️ generated model and hook names exists twice (per spec).### 🤔 2. Create barrel file exports without clashes
1. 💡 create barrel file on output root ==> set workspace in orval.config.ts
2. 💡 suffix the name of the generated models ==> output.override.components.suffix in orval.config.ts
3. 💡 override the name of the generated hooks ==> output.override.operationName in orval.config.ts