feat: Add my-clients library for external apis #5
No reviewers
Labels
No labels
automerge
bug
dependencies
duplicate
enhancement
help wanted
invalid
migrations
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Personal/my-rust-lib!5
Loading…
Reference in a new issue
No description provided.
Delete branch "client-library"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Client library for external dependencies using openapi-to-rust to generate the code
WIP: feat: Add my-clients library for external apisto feat: Add my-clients library for external apisBased on my review of the PR, here is my assessment:
{"summary": "# Review Summary\n\nThe PR adds a
my-clientsworkspace crate that generates typed HTTP clients from OpenAPI specs usingopenapi-to-rust, starting with a Forgejo client. Overall this is a solid, well-structured addition: the codegen config (configs/forgejo.toml) is clean, the committed contract is pinned to Forgejo 16.0.2, the README documents the regeneration workflow, response bodies are read with a hard memory bound (__read_bounded_response_body), the RFC 9457 problem-details handling is a nice touch, and the integration test smoke-tests the client end-to-end. I also verified that the generatedAuthorization: Bearer <token>scheme is valid — Forgejo's docs explicitly supportBearertokens, sowith_api_keyworks as-is.\n\nThere are a few issues worth addressing before merge:\n\n1. Configured timeout is never applied.configs/forgejo.tomldeclarestimeout_seconds = 30, but the generatedHttpClient::new()buildsreqwest::Client::new()with no timeout and no request ever calls.timeout(), so the setting is dead and requests can hang indefinitely. TheHttpError::Timeoutvariant is never constructed anywhere.\n2. All response bodies are fully buffered in memory. Despite enabling thestreamfeature, every response (including binary ones likedownload_action_artifact/repo_get_archive) is buffered into aVeccapped at 8 MB. Downloads larger than 8 MB fail withResponseTooLarge, and there is no true streaming.\n3. Contract regeneration depends on an unpinned third-party converter.convert-forgejo.shfetches the spec throughconverter.swagger.ioat regeneration time, so the committed contract can silently drift from what regeneration produces and reproducibility depends on an external service.\n4. Heavy native dependency tree in the workspace.my-clientspulls inaws-lc-sys(cmake/cc build),ring,rustls, etc. Since it's a workspace member, every workspace-wide build, clippy, and CI job now compiles all of this, noticeably increasing build times.\n\nMinor notes: the generated 61k-line files are committed (maintainable as long as the documentedopenapi-to-rust 0.12.1is what people actually have installed — consider pinning it in the flake dev shell), and the deadif false ||guards in generated code are cosmetic only.", "verdict": "changes", "comments": [{"file": "crates/my-clients/configs/forgejo.toml", "line": 18, "severity": "bug", "message": "timeout_seconds = 30has no effect. The generatedHttpClient::new()buildsreqwest::Client::new()without a timeout (client.rs:235) and no generated request calls.timeout()beforereq.send(). reqwest's default is no timeout, so a non-responsive server causes the call to hang forever; theHttpError::Timeoutvariant is never constructed. Apply the timeout (e.g. via the reqwestClientBuilder/ a.timeout()on each request) so the configured value is honored, or remove the dead setting."}, {"file": "crates/my-clients/configs/forgejo.toml", "line": 19, "severity": "performance", "message": "max_response_body_bytes = 8388608together with__read_bounded_response_bodymeans every response is fully buffered in memory and thestreamfeature is never used. Binary/streaming endpoints (download_action_artifact,repo_get_archive, release attachments, raw file/LFS) will error out withResponseTooLargeas soon as a payload exceeds 8 MB and cannot be streamed to disk. Consider exposing per-endpoint streaming or a larger/raising limit for the download-style operations."}, {"file": "crates/my-clients/scripts/convert-forgejo.sh", "line": 5, "severity": "style", "message": "The contract is regenerated live through the third-partyconverter.swagger.ioservice with no pinned source version, so the fetched spec (and thus the generated API surface) can change between runs and diverge from the committedcontracts/forgejo.json. Since the contract is already committed with a fixed version (16.0.2), consider documenting/pinning the upstream Forgejo version the script targets and validating the output is a well-formed OpenAPI document before overwriting the file."}, {"file": "crates/my-clients/Cargo.toml", "line": 13, "severity": "performance", "message": "This crate's rustls/aws-lc dependency tree (aws-lc-sys, ring, cmake/cc, etc.) is heavy to compile. Becausemy-clientsis a workspace member,cargo build, the strictcargo clippy --workspace, and all CI/Nix jobs for the whole workspace now build these native deps, noticeably increasing build time and CI wall-clock. Worth confirming this is acceptable or scoping the workspace build (e.g. excluding the client crate from default workspace builds)."}]}*🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: comment