An open API service indexing awesome lists of open source software.

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

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:
image

## 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