Fix axum doctest examples; infer Json early responses; forward OperationIo early responses #285
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.
Fixes #255.
Fixes #272.
Fixes #235.
This PR addresses two high-impact adoption pain points:
axum::serve(...)which is feature-gated in axum (tokio + http1/http2). Withaxumused withdefault-features = false,axum::serveis not always available, causing doctest failures.aide::axumexample also unnecessarily forced the/api.jsonroute throughIntoApiResponseeven though it is not documented (added via.route, not.api_route).Changes:
crates/aide/src/axum/mod.rscrates/aide/src/redoc/mod.rscrates/aide/src/swagger/mod.rscrates/aide/src/scalar/mod.rsto avoid calling
axum::servein doctests.routing::get+IntoResponsefor the non-documented/api.jsonhandler in theaide::axumdocs example.OperationIowithinput_with = ...previously delegatedoperation_inputbut did not delegateOperationInput::inferred_early_responses, so early responses were silently dropped.axum::Json<T>did not provide inferred early responses, even though axum returns rejections before the handler body for invalid JSON and content-type mismatches.Changes:
OperationIonow forwardsinferred_early_responseswheninput_withis used.axum::Json<T>now reports inferred early responses:Content-Type: application/jsonTests:
OperationIoforwarding ofinferred_early_responsesaxum::Json<T>inferred early response status codesCommands run:
cargo test -p aide --doc --all-featurescargo test --workspace --all-featurescargo build --examples --all-features(These changes should also reduce confusion seen in #278 and #265 by removing common docs-triggered failure modes.)