Skip to content

Conversation

@pplancq
Copy link
Contributor

@pplancq pplancq commented Dec 19, 2025

Type of Pull Request:

  • New feature
  • Bug fix
  • Documentation
  • Other (specify):

Associated Issue:
Closes #196

Context:
This PR addresses the need to generate type-safe fetch functions from the OpenAPI specification using Orval. This improves developer experience by enabling automatic API client generation, reducing manual API integration code, and ensuring consistency between the API contract and React client implementation.

Proposed Changes:

  • Added Orval as a dev dependency in react/package.json with all required peer dependencies (@apidevtools/swagger-parser, @asyncapi/specs, @commander-js/extra-typings, etc.)
  • Configured Orval in react/orval.config.ts to generate fetch functions from api/microcks-hub-openapi-v1.0.yaml into ./.api/microcksHub/index.ts
  • Created custom fetchApi helper in src/shared/helpers/fetchApi/fetchApi.ts with error handling and type safety (supports both JSON and text responses)
  • Generated initial API client functions in .api/microcksHub/index.ts with TypeScript interfaces for all OpenAPI schemas (APIPackage, APIVersion, APIPackageFull, etc.)
  • Created MicrocksHubService in src/services/microcksHubService/MicrocksHubService.ts as an abstraction layer for API operations with methods: getPackages(), getPackageDetails(), getAPIVersions(), getAPIVersionDetails()
  • Added operationId: GetAPIVersions to the OpenAPI spec for better generated function naming
  • Updated npm dependencies and added mise.toml for consistent tool versioning (npm 11.7.0, node 24.12.0)
  • Added prompt file for intelligently renaming generic Vitest test cases

Checklist:

  • I have verified that my changes work as expected
  • I have updated the documentation if necessary
  • I have thought to rebase my branch
  • I have applied the correct label according to the type of PR (bug/feature/documentation)

Additional Information:

  • The fetchApi helper is designed to work as a custom mutator for Orval, ensuring all generated functions use consistent error handling and request/response processing
  • The MicrocksHubService provides a clean abstraction over generated fetch functions for React components
  • All generated code is TypeScript with proper typing
  • Future API endpoints can be added to the OpenAPI spec and automatically regenerated without manual updates
  • No impact on Angular or backend code as per acceptance criteria

Add Orval configuration for generating API clients from OpenAPI specs.
Update package.json to include Orval command in prepare script and
enhance path mappings in tsconfig.json for better module resolution.

Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
Renamed mock handler and server files for clarity.
Updated tsconfig to include new mock paths and added orval.config.ts to the include list.

Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
Add a generic API fetch utility with automatic type conversion and error handling.
Includes constants for HTTP methods, headers, and MIME types.
Also introduces tests for various fetch scenarios to ensure reliability.

Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
Implement MicrocksHubService to handle API package and version
fetching, along with unit tests to ensure functionality and
correctness of the service methods.

Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
Signed-off-by: Paul PLANCQ <paul.plancq@outlook.fr>
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 30 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale State due to inactivity label Jan 19, 2026
@lbroudoux lbroudoux added keep-open Explicitily keep open kind/enhancement Enhancement of existing feature component/build and removed stale State due to inactivity labels Jan 19, 2026
@lbroudoux lbroudoux added this to the 0.9.0 milestone Jan 19, 2026
Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pplancq ! Thanks for the PR - it is crystal clear and well-aligned with the contract first development approach we advocate for. I got 2 questions though - not blockers but better for my own understanding.

@lbroudoux lbroudoux merged commit 905213d into microcks:master Jan 19, 2026
5 of 6 checks passed
@pplancq pplancq deleted the feature/orval branch January 19, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/build keep-open Explicitily keep open kind/enhancement Enhancement of existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate Orval for OpenAPI-based Fetch Generation in React

2 participants