๐ฆ๐ฐ๐ฎ๐ฟ๐ฎ๐ฏ ๐๐ถ๐ฎ๐ด๐ป๐ผ๐๐๐ถ๐ฐ ๐๐ถ๐ฒ๐น๐ฑ ๐ง๐ฒ๐๐ #๐ฌ๐ฎ๐ด
A generator must keep its promises.
We found a bug in the OpenAPI Generator Rust server. The generator creates code, but it failed to provide the tools that code needs to run.
The Problem: The generator produced Rust code for shared models. These models used pattern validation. This validation required two specific crates: lazy_static and regex.
However, when a user enabled only the "client" feature, the generator forgot to include those two crates in the build settings. This caused the build to fail.
This is a generator contract problem. If the generator emits code that needs a dependency, the generator must also emit the instructions to include that dependency.
The Fix: We did not suggest adding every dependency to every build. That is messy. We also did not tell users to fix it manually. That is not the generator's job.
Instead, we tightened the feature wiring. Now, if the client feature compiles shared models that use validation, the build automatically includes the required crates.
The Results:
- The repair stays within the generator's control.
- The fix is precise and avoids unnecessary bloat.
- The patch includes a regression test to prevent this from happening again.
- Full validation passed, including builds across 769 different generators.
When generated code and build metadata disagree, you must repair the seam where the contract breaks.
Optional learning community: https://t.me/GyaanSetuAi