Skip to content

Commit 6a28b6a

Browse files
committed
feat(ws): automate generation of types and HTTP client layer from Swagger definitions
Signed-off-by: Guilherme Caponetto <[email protected]>
1 parent 4f0a29d commit 6a28b6a

File tree

90 files changed

+2286
-1575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2286
-1575
lines changed

.github/workflows/ws-frontend-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
2527

2628
- name: Set up Node.js
2729
uses: actions/setup-node@v3
@@ -35,6 +37,10 @@ jobs:
3537
- name: Clean
3638
working-directory: workspaces/frontend
3739
run: npm run build:clean
40+
41+
- name: Regenerate API layer code
42+
working-directory: workspaces/frontend
43+
run: npm run generate:api
3844

3945
- name: Build
4046
working-directory: workspaces/frontend

workspaces/frontend/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,25 @@ Automatically fix linting issues:
7777
```bash
7878
npm run test:fix
7979
```
80+
81+
### API Types & Client Generation
82+
83+
The TypeScript types and the HTTP client layer for interacting with the backend APIs are automatically generated from the backend's `swagger.json` file. This ensures the frontend remains aligned with the backend API contract at all times.
84+
85+
#### Generated Code Location
86+
87+
All generated files live in the `src/generated` directory.
88+
89+
⚠️ Do not manually edit any files in this folder.
90+
91+
#### Updating the Generated Code
92+
93+
To update the generated code, first update the `swagger.version` file in the `scripts` directory to the desired commit hash of the backend's `swagger.json` file.
94+
95+
Then run the following command to update the generated code:
96+
97+
```bash
98+
npm run generate:api
99+
```
100+
101+
Finally, make any necessary adaptations based on the changes in the generated code.

0 commit comments

Comments
 (0)