feat: emit server and client together - #30
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for emitting both the axum server and blocking reqwest client in a single generated output by namespacing them into server/client submodules while keeping shared models at the crate root. This expands generator coverage with a combined fixture and compile-checks, and also improves client URL path-parameter encoding for String parameters.
Changes:
- Emit server + client together via
emit_with_service_and_client, producingpub mod server { … }andpub mod client { … }with shared root-level models. - Add a combined server+client fixture and golden output, plus coverage + compile-check wiring.
- Optimize reqwest client path-param encoding to avoid
String::to_string()when the parameter is already aString.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oapi-codegen/src/lib.rs | Generates service once when either server/client is enabled; routes to combined emission when both are set. |
| crates/oapi-codegen/src/lower/prune.rs | Adds references_models() to decide whether submodules need use super::*;. |
| crates/oapi-codegen/src/lower/mod.rs | Re-exports references_models() from lower. |
| crates/oapi-codegen/src/emit/mod.rs | Implements combined emission with submodule wrapping + indentation/render helpers. |
| crates/oapi-codegen/src/emit/reqwest.rs | Adjusts URL building to use as_str() for String path params (but currently introduces a compile issue; see PR comment). |
| crates/oapi-codegen/tests/fixtures/combined_server_client.yaml | New fixture spec used to exercise combined emission. |
| crates/oapi-codegen/tests/generated/combined_server_client.rs | New committed golden output for combined server+client generation. |
| crates/oapi-codegen/tests/coverage.rs | Adds COMBINED_FIXTURES plus drift-guard tests and includes combined fixtures in compile-check expectations. |
| crates/oapi-codegen/tests/generated_compiles.rs | Includes the new combined golden file to ensure it type-checks. |
| crates/oapi-codegen/tests/generated/client_widgets.rs | Updates generated client code to use as_str() in path encoding for widget routes. |
Contributor
|
🎉 This PR is included in version 1.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.