Skip to content

docs: fix axum examples and doctests#286

Open
kieled wants to merge 1 commit intotamasfe:mainfrom
kieled:fix/docs-doctests
Open

docs: fix axum examples and doctests#286
kieled wants to merge 1 commit intotamasfe:mainfrom
kieled:fix/docs-doctests

Conversation

@kieled
Copy link

@kieled kieled commented Feb 7, 2026

Summary

  • Update the doctest examples in aide::axum, aide::redoc, aide::swagger, and aide::scalar to avoid calling axum::serve, since it is feature-gated in axum.
  • Use plain IntoResponse for the non-documented /api.json handler in the aide::axum docs example.

Test Plan

  • cargo test -p aide --doc --all-features

(Originally part of #285; split out per review feedback.)

@jplatte
Copy link
Collaborator

jplatte commented Feb 7, 2026

Why not add a dev-dependency on axum with the tokio feature? Then axum::serve can be used in doctests.

@kieled
Copy link
Author

kieled commented Feb 8, 2026

axum::serve isn't enabled by tokio alone. It also needs http1 or http2 / default features. Most importantly, I avoided adding extra axum features only for doctests because aide depends on axum with default-features = false, and making doctests pass via a beefier dev-dep can mask “docs don’t compile” cases for users running minimal axum features.

@jplatte
Copy link
Collaborator

jplatte commented Feb 8, 2026

beefier dev-dep can mask “docs don’t compile” cases for users running minimal axum features

I don't think this should be a serious concern nowadays. rustc has supported "this item exists, but is under a disabled cfg" hints for a couple versions now.

Add axum as a dev-dependency with tokio and http1 features so that
axum::serve compiles in doctests without requiring workarounds.
@kieled kieled force-pushed the fix/docs-doctests branch from 73110f9 to 0d96566 Compare February 8, 2026 20:52
@kieled
Copy link
Author

kieled commented Feb 8, 2026

Fair point — updated the PR to add axum as a dev-dependency with tokio and http1 features instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants