feat: Replace openapi-generator with openapi-to-rust #22
Loading…
Reference in a new issue
No description provided.
Delete branch "openapi-to-rust"
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?
Replace openapi-generator with openapi-to-rust
Review Summary
This revision resolves nearly all prior review findings: the
unwrap()/swallowed-end_datepaths are now mapped to 400/422 with aProblemDetail, theoverride_titleshadowing is gone, the$refindentation is fixed, the devshell shipsopenapi-to-rust,serve_openapi_yamlservesapplication/yamlagain, CI installs the generator only in the Generate step (artifacts persist to Build/Test/Clippy via the shared workspace), and the aws-lc/cmake concern is moot withjsonschemabuilt withdefault-features = false. The contract-first layout, generated-code wiring, and docs are coherent.Still open from prior reviews: (1)
.nix/openapi-to-rust.nixusesrustPlatform.buildPackagewithoutcargoHash/cargoLock/cargoVendorDir, so a sandboxednix build/nix developwill attempt to fetch crates over the network and fail; (2){{CARGO_PKG_VERSION}}is substituted only at serve-time inserve_openapi_yaml, while codegen runs against the raw placeholder (latent today, but input/served-spec divergence).New findings on this revision:
EventRequest::try_newcomputes the default end as(start + ONE_YEAR).date()(src/server.rs:62).start_date_timeis only validated againstformat: date-time, which does not bound the year, so a value like9999-12-31T00:00:00Zwithoutend_dateoverflows chrono's range and panics → 500 instead of a 4xx (the same panic-on-overflow pattern remains indate_service.rs:17'schecked_add_months(...).unwrap()).parse_date_or_date_timeforend_date, but the spec still types/'send_dateasformat: dateand/ics's asformat: date-time. Since router-level format validation demonstrably runs (the new 422 tests), one acceptance branch is dead per endpoint, and/ics?end_date=2025-03-15is rejected with 422 even though the handler's parser would accept it — the endpoints behave stricter than the shared parser suggests.get_calendar_missing_required_params_returns_400andget_calendar_invalid_recurring_returns_400assertUNPROCESSABLE_ENTITY, and the new ICS tests are named..._returns_bad_requestwhile asserting 422.Verdict: changes — mostly cosmetic, but the overflow panic deserves a
checked_add_days+ 400 fix given this PR's input-hardening intent.*🤖 Review by opencode (opencode/deepseek-v4-flash-free) — verdict: changes
Code review findings from opencode.
@ -7,0 +10,4 @@pname = "openapi-to-rust";version = "0.12.0";src = openapi-to-rust-src;cargoLock = "${openapi-to-rust-src}/Cargo.lock";@ -20,3 +17,1 @@- test -s /usr/local/bin/openapi-generator-cli.jar- printf '#!/bin/sh\nexec java -jar /usr/local/bin/openapi-generator-cli.jar "$@"\n' > /usr/local/bin/openapi-generator-cli- chmod +x /usr/local/bin/openapi-generator-cli- cargo install --locked openapi-to-rust --version 0.12.0@ -48,0 +39,4 @@override_title: Option<String>,) -> GetIcsResponse {let start = chrono::DateTime::parse_from_rfc3339(&start_date_time).unwrap()@ -48,0 +41,4 @@let start = chrono::DateTime::parse_from_rfc3339(&start_date_time).unwrap().naive_utc();let end = end_date@ -118,3 +129,2 @@};let title = if let Some(override_str) = &query.override_condition&& let Some(title) = &query.override_titlelet title = if let Some(override_str) = override_conditionCode review findings from opencode.
@ -8,3 +29,3 @@src = lib.cleanSource ../.;src = source;SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";nativeBuildInputs = with pkgs; [@ -155,3 +155,3 @@application/json:schema:$ref: "#/components/schemas/HealthResponse"$ref: "#/components/schemas/HealthStatusResponse"@ -48,1 +51,4 @@.map(|dt| dt.date_naive())})}).unwrap_or_else(|| (start + TimeDelta::days(365)).date());Code review findings from opencode.
@ -25,0 +25,4 @@- name: Testimage: docker.io/rust:1.97-bookwormcommands:- cargo install cargo-nextest --locked@ -61,7 +67,6 @@devShells.default = mkDevShell {tooltip = "defaultToolchain";packages = with pkgs; [@ -39,3 +46,3 @@([(http::header::CONTENT_TYPE, "application/yaml")],recurring_events_core::OPENAPI_YAML,include_str!("../openapi.yaml").replace("{{CARGO_PKG_VERSION}}", env!("CARGO_PKG_VERSION")),Code review findings from opencode.
@ -18,4 +17,2 @@recurring_events_core = { package = "recurring-events-core", path = "core" }axum = { version = "0.8" }axum-extra = { version = "0.12", features = ["cookie"] }@ -3,3 +7,3 @@mod service;use crate::server::RecurringEventsServer;use crate::{generated::build_router, server::RecurringEventsServer};@ -39,3 +48,2 @@([(http::header::CONTENT_TYPE, "application/yaml")],recurring_events_core::OPENAPI_YAML,[(CONTENT_TYPE, APPLICATION_JSON.essence_str())],Code review findings from opencode.
@ -29,0 +57,4 @@start,end: match end_date {Some(date) => {parse_date_or_date_time(&date).ok_or(String::from("Invalid end date"))?@ -29,0 +59,4 @@Some(date) => {parse_date_or_date_time(&date).ok_or(String::from("Invalid end date"))?}None => (start + ONE_YEAR).date(),@ -221,7 +263,7 @@ mod tests {#[tokio::test]async fn get_calendar_missing_required_params_returns_400() {