chore: implement Orval to generate API fetch functions and types - #1159
Open
GuillaumeKESTEMAN wants to merge 12 commits into
Open
chore: implement Orval to generate API fetch functions and types#1159GuillaumeKESTEMAN wants to merge 12 commits into
GuillaumeKESTEMAN wants to merge 12 commits into
Conversation
GuillaumeKESTEMAN
force-pushed
the
chore/implement-orval-to-generate-api-fetch-functions-and-types
branch
from
July 18, 2026 11:06
e7f3b20 to
62b5b30
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Confidence: 98%.
This PR introduces Orval-based OpenAPI client generation for the frontend, replacing hand-written API wrappers/types with generated fetch clients and a shared custom mutator (including token refresh + error handling) to keep the frontend aligned with the backend Swagger contract.
Changes:
- Added Orval configuration + Swagger preparation script and wired
generate:apiinto local dev and CI setup. - Implemented a custom Orval fetch mutator and refactored authentication/signup flows to use generated endpoints.
- Updated mocks/fixtures and documentation, and removed legacy manual API wrappers/types.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Runs npm run generate:api during make start / make front. |
| front/src/types/Authentication/tokenRefresh/tokenRefresh.types.ts | Removes unused TokenRefreshResponseType alias; keeps error code typing. |
| front/src/types/Authentication/authStatus/AuthStatusErrorResponse.ts | Removes legacy custom error response class. |
| front/src/types/Authentication/authStatus/authStatus.types.ts | Removes unused AuthStatusResponseType alias; keeps error code typing. |
| front/src/pages/Authentication/SignUp/useSignUp.ts | Updates React Query mutation typing/error type to shared ErrorResponse; aligns with generated signup call. |
| front/src/contexts/AuthenticationContext/useCheckAuthentication.ts | Switches auth status call to generated getV1AuthStatus and shared ErrorResponse typing. |
| front/src/api/README.md | Updates API layer docs to describe Orval-generated structure and workflow. |
| front/src/api/orval/fetchApiMutator.ts | Adds Orval mutator implementing shared fetch behavior + token refresh retry. |
| front/src/api/fetchApi.ts | Removes legacy custom fetch wrapper. |
| front/src/api/constant.ts | Removes now-unused HTTP method/MIME enums; keeps header constants. |
| front/src/api/authentication/signUpApi.ts | Switches signup to generated postV1Account and builds DTO expected by API. |
| front/src/api/authentication/refreshTokenApi.ts | Removes legacy refresh API wrapper. |
| front/src/api/authentication/authStatusApi.ts | Removes legacy auth status API wrapper. |
| front/scripts/prepare-swagger.mjs | Adds Swagger normalization step (remove securityDefinitions, strip /api prefix). |
| front/README.md | Documents Orval API generation workflow. |
| front/package.json | Adds generate:api script and Orval dev dependency. |
| front/package-lock.json | Locks Orval and its transitive deps. |
| front/orval.config.ts | Adds Orval config targeting fetch client with custom mutator. |
| front/mocks/fixtures/tokenRefreshFixtures.ts | Adjusts fixtures after removing response type alias. |
| front/mocks/fixtures/authStatusFixtures.ts | Switches fixtures to generated schema error type. |
| front/mocks/fixtures/accountFixtures.ts | Updates error fixture typing; keeps “real API returns token” fixture shape. |
| front/mocks/browser.ts | Registers a generated auth status handler in the MSW worker. |
| front/.gitignore | Ignores generated Orval output and prepared swagger JSON. |
| .github/actions/setup-node/action.yaml | Extends setup-node composite action to run API generation. |
Files not reviewed (1)
- front/package-lock.json: Generated file
Collaborator
Author
|
Utiliser un script |
GuillaumeKESTEMAN
force-pushed
the
chore/implement-orval-to-generate-api-fetch-functions-and-types
branch
from
July 21, 2026 17:51
545d0e8 to
42db0fb
Compare
GuillaumeKESTEMAN
force-pushed
the
chore/implement-orval-to-generate-api-fetch-functions-and-types
branch
2 times, most recently
from
July 22, 2026 19:38
7fc0709 to
573cad3
Compare
…tion - added script to prepare Swagger for Orval code generation - replaced custom API calls with Orval-generated functions for authentication - removed obsolete API files and error response classes - updated authentication context and sign-up logic to use new API structure - introduced custom fetch mutator for handling token refresh and error responses
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Refactor the setup-node action and Makefile to remove the API generation step. Update the postinstall script in package.json to ensure API generation occurs after initializing MSW and installing dependencies.
…ckage-lock.json Includes updates to the signUpApi to utilize Temporal for time zone handling.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
GuillaumeKESTEMAN
force-pushed
the
chore/implement-orval-to-generate-api-fetch-functions-and-types
branch
from
July 25, 2026 09:38
573cad3 to
287fe28
Compare
Enhance the CI workflow to check for changes in both front-end and back-end files. This includes updating job names and conditions for installation, linting, testing, and building.
GuillaumeKESTEMAN
force-pushed
the
chore/implement-orval-to-generate-api-fetch-functions-and-types
branch
from
July 25, 2026 10:24
7a0a86d to
380b262
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: Implement Orval to generate API fetch functions and types from Swagger
Type of Pull Request:
Associated Issue:
Closes #278
Context:
Currently, API types and fetch functions are manually maintained in the frontend, causing sync issues between the backend OpenAPI/Swagger specification and frontend implementations. This PR introduces Orval as an automated code generation tool to sync TypeScript types and API client functions directly from the backend's Swagger specification, reducing manual maintenance and ensuring consistency.
Proposed Changes:
Setup Orval & Swagger Normalization:
orval.config.tswith configuration for generating API clients using thefetchclient and custom mutatorprepare-swagger.mjsscript to normalize the Swagger spec: removes non-standard security definitions and strips the/apiprefix from paths to enable dynamic backend URL injectionnpm run generate:apiduring frontend startup.gitignoreto exclude generated API files (/src/api/generated/,swagger.json)Custom Fetch Mutator:
fetchApiMutator.tsto integrate Orval-generated clients with existing error handling and token refresh logicRefactored Authentication APIs:
authStatusApi.ts,refreshTokenApi.ts) now generated by OrvalsignUpApi.tsto use generatedpostV1AccountfunctionuseCheckAuthentication) to use generatedgetV1AuthStatusfunctionuseSignUp) to use generated mutation functionsType Consolidation:
AuthStatusErrorResponse.ts)slotFinderAPI.schemasDependencies:
orval@^8.22.0as dev dependency with all required sub-packagesChecklist:
Additional Information:
/apiprefix is stripped to support dynamic backend URL injection (/mocked-api,/api, etc.)usernamefield is accepted by the real API but is absent from the OpenAPI spec; the generated code accepts it without casting via structural subtypingsrc/api/generated/are gitignored and regenerated on every build