feat: generate concern-level file structures instead of one large restapi.rs - #120
Conversation
restapi.rs into smaller filesd7b21b2 to
28a32c3
Compare
restapi.rs
28a32c3 to
7d6e493
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 183 changed files in this pull request and generated no new comments.
Suppressed comments (1)
crates/oapi-codegen/src/package.rs:233
audit()returns early whenpackage.children()is empty. That means a models-only run (or any run that currently emits a single root file) will not detect or clean up a companion directory left behind by an earlier operations-generating run with the same output stem. This can leave stale generated files on disk and lets--checkpass even though leftover generated files remain beside the output.
fn audit(output_path: &Path, package: &GeneratedPackage) -> Result<Vec<PathBuf>> {
if package.children().is_empty() {
return Ok(Vec::new());
}
let directory = companion_of(output_path)?;
let parent = output_path.parent().unwrap_or_else(|| return Path::new(""));
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 183 changed files in this pull request and generated no new comments.
Suppressed comments (1)
docs/workflow.md:25
- The module-tree example implies that
models.rs,server_urls.rs,server.rs, andclient.rsare always written when operations exist, but the generator only writes the modules enabled by the config (andmodels.rscan also be absent when models are provided via import-mapping). This can mislead users comparing their output to the documentation; consider marking these entries as conditional or rewording the example to reflect that only some modules may exist.
735739b to
fbe5780
Compare
|
🎉 This PR is included in version 1.1.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 183 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
docs/configuration.md:33
- The
outputrow says the root output file must end in.rs, but the implementation only requires an extension when the run emits operations (i.e. when it needs a companion directory). Models-only runs currently still produce a single file without needing a stem-derived directory.
Either tighten the implementation to require .rs for all runs, or adjust the docs here to make the requirement conditional on emitting operations.
docs/workflow.md:54
- This section is otherwise using
generated/restapi.rsas the canonical example, but the nesting warning switches togenerated/api.rs. That makes it less clear that the same ownership rule applies to the earlierrestapiexample.
Consider keeping the example consistent (or using a placeholder like generated/<name>.rs).
docs/workflow.md:57
- The sentence implies the output path always needs a
.rsextension, but earlier in this doc you note that a models-only run writes a single file and has nothing to split. In the current implementation, the extension requirement only matters when operations are emitted (so a companion directory named after the file stem is needed).
Please clarify that the .rs extension is required for runs that split output (i.e. runs that emit operations).
| let text = name.logical(); | ||
| let stem = if text == "mod" { | ||
| format!("{text}_") | ||
| } else { | ||
| text.to_owned() |
Generated APIs currently produce one flat
restapi.rs, making larger specifications difficult to navigate. This planning PR proposes granular modules while preserving existing public paths.restapi.rsas a re-exporting facade.Compatibility
restapi::Apiandrestapi::ListBooksResponse.Output management
Scope
restapi.rs#103