Add smoke tests for OpenAPI examples - #49
Conversation
Add a smoke test script that generates and compiles every supported JSON OpenAPI example, run it from CI, and document how to use it locally. The smoke sweep also hardens generated model and API code for name collisions, empty identifiers, and unresolved path placeholders found in real specs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe pull request introduces a dedicated PowerShell smoke-test suite ( Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CI as CI System
participant Script as smoke-tests.ps1
participant Builder as Zig Builder
participant Generator as openapi2zig CLI
participant Compiler as Zig Compiler
participant Harness as Test Harness
User->>CI: Trigger CI workflow
CI->>Script: Execute smoke-tests.ps1
Script->>Builder: Build openapi2zig (ReleaseFast)
Builder-->>Script: Compiled CLI binary
Script->>Script: Discover JSON specs in openapi/
loop For each spec file
Script->>Generator: Run openapi2zig generate
Generator-->>Script: generated.zig
Script->>Script: Write compile.zig harness
Script->>Compiler: Execute zig test
Compiler->>Harness: Compile & test harness
Harness-->>Compiler: Pass/Fail result
Compiler-->>Script: Test result
Script->>Script: Log result or collect failure
end
Script->>CI: Report aggregate pass/fail
CI-->>User: Workflow status
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Pull request overview
This PR expands repository validation by adding a smoke-test workflow that iterates over the real OpenAPI/Swagger JSON examples under openapi/, generates Zig clients for each, and verifies the generated code compiles—while also hardening the unified generators based on issues found by the broader sweep.
Changes:
- Added a PowerShell smoke-test runner that discovers JSON example specs, generates output per spec, and compiles each via a tiny Zig
testharness. - Updated CI to run the smoke-test script instead of only exercising the petstore generation path.
- Hardened unified code generation to avoid compile failures from edge-case spec inputs (empty identifiers, casing collisions, and brace escaping in URI format strings).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
test/smoke-tests.ps1 |
New smoke-test runner: discover JSON specs, generate per spec, and compile via Zig test harness with per-spec logging. |
src/generators/unified/model_generator.zig |
Avoid invalid Zig identifiers for empty names; adjust helper type-name casing to reduce collisions. |
src/generators/unified/api_generator.zig |
Escape {/} in paths before embedding into writer.print(...) format strings, while preserving generated format placeholders. |
README.md |
Documents how to run the smoke tests locally. |
.gitignore |
Ignores local smoke outputs under generated/smoke/. |
.github/workflows/ci.yml |
Runs the smoke-test script in CI to validate the full JSON example matrix. |
Why
The repo only smoke-tested a small canned generation path, which made it easy for spec-specific generation bugs to slip through. This adds a broader smoke test flow that exercises the real example specs under
openapi/and verifies the generated Zig actually compiles.What changed
test/smoke-tests.ps1to discover supported JSON OpenAPI and Swagger examples, generate code one spec at a time, and compile each generated client through a tiny Zig test harness with clear per-spec logging.generated/smoke/so local runs do not leave noisy artifacts behind.writer.print(...)format stringsNotes for reviewers
The smoke suite intentionally covers only supported JSON OpenAPI and Swagger inputs. YAML examples and
openapi/json-schema/**are excluded because YAML generation is still unsupported and the JSON Schema fixtures are not OpenAPI smoke targets.The generator fixes are tightly coupled to the smoke work because the new sweep immediately exposed real compile failures in
ingram-micro.json. Those fixes are included here so the new CI coverage is green instead of introducing a permanently failing workflow.Validation
zig build test -Doptimize=ReleaseFastSummary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation