refactor: generate orpc contract from openapi#31490
Conversation
Summary of ChangesHello @hyoban, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the API contract generation process for the web frontend by integrating the Kubb code generation tool. This change automates the creation of ORPC contracts and Zod schemas directly from OpenAPI specifications, aiming to streamline development, reduce manual errors, and ensure strong type consistency between the frontend and backend API definitions. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a code generation setup using Kubb to generate ORPC contracts from an OpenAPI specification. This is a good step towards automating contract generation and ensuring consistency.
However, I've found a few issues:
- Critical: The
package.jsonfile uses localpnpm linkfor@kubb/plugin-orpcand@kubb/plugin-zod. This will prevent other developers from installing dependencies and building the project. These should be replaced with packages from a public or private registry. - Medium: The dependencies
@kubb/plugin-react-queryand@kubb/plugin-tsare installed but not used inkubb.config.ts. They should be removed if they are not needed. - The refactoring appears to be incomplete. The new contracts are generated into the
./gendirectory, but the old manually created contract files inweb/contract/are not removed, and their usages are not updated to point to the new generated files. This leaves dead code and an incomplete feature.
Please address these points to ensure the project remains maintainable and buildable for the whole team.
# Conflicts: # web/package.json # web/pnpm-lock.yaml
Important
Fixes #<issue number>.Summary
close #31448
While most interfaces remain in Swagger v2, the OpenAPI v3 migration has already begun.
However, it is in its early stages, and many have not yet been migrated.
Missing $ref pointer "#/components/schemas/DocumentMetadataOperation". Token "DocumentMetadataOperation" does not exist.Missing $ref pointer "#/components/schemas/SegmentUpdateArgs". Token "SegmentUpdateArgs" does not exist.Missing $ref pointer "#/components/schemas/RetrievalMethod". Token "RetrievalMethod" does not exist.related pull request
Flask-RESTX Swagger UI (Legacy)
Each Blueprint using
ExternalApihas its own Swagger UI at{url_prefix}/swagger-ui.html:/console/api/swagger-ui.html/console/api/swagger.json/v1/swagger-ui.html/v1/swagger.json/api/swagger-ui.html/api/swagger.json/files/swagger-ui.html/files/swagger.json/inner/api/swagger-ui.html/inner/api/swagger.jsonFastOpenAPI Documentation (New)
Configured in
extensions/ext_fastopenapi.py:/fastopenapi/docs/fastopenapi/redoc/fastopenapi/openapi.jsonFastOpenAPI is currently a PoC and only covers a subset of
/console/apiendpoints.Configuration
Controlled via environment variables:
SWAGGER_UI_ENABLED: Enable/disable docs (defaulttrue)SWAGGER_UI_PATH: Custom path (default/swagger-ui.html)Screenshots
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods