-
-
Notifications
You must be signed in to change notification settings - Fork 24
Integrate Orval for OpenAPI-based Fetch Generation in React #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
|
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 ❤️ |
lbroudoux
left a comment
There was a problem hiding this 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.
Type of Pull Request:
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:
react/package.jsonwith all required peer dependencies (@apidevtools/swagger-parser,@asyncapi/specs,@commander-js/extra-typings, etc.)react/orval.config.tsto generate fetch functions fromapi/microcks-hub-openapi-v1.0.yamlinto./.api/microcksHub/index.tsfetchApihelper insrc/shared/helpers/fetchApi/fetchApi.tswith error handling and type safety (supports both JSON and text responses).api/microcksHub/index.tswith TypeScript interfaces for all OpenAPI schemas (APIPackage, APIVersion, APIPackageFull, etc.)MicrocksHubServiceinsrc/services/microcksHubService/MicrocksHubService.tsas an abstraction layer for API operations with methods:getPackages(),getPackageDetails(),getAPIVersions(),getAPIVersionDetails()operationId: GetAPIVersionsto the OpenAPI spec for better generated function namingmise.tomlfor consistent tool versioning (npm 11.7.0, node 24.12.0)Checklist:
Additional Information:
fetchApihelper is designed to work as a custom mutator for Orval, ensuring all generated functions use consistent error handling and request/response processing