Skip to content

docs: fix axum examples and doctests#286

Merged
jplatte merged 1 commit intotamasfe:mainfrom
kieled:fix/docs-doctests
Mar 17, 2026
Merged

docs: fix axum examples and doctests#286
jplatte merged 1 commit intotamasfe:mainfrom
kieled:fix/docs-doctests

Conversation

@kieled
Copy link
Contributor

@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
Contributor 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
Contributor Author

kieled commented Feb 8, 2026

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

@jplatte jplatte merged commit 96440ac into tamasfe:main Mar 17, 2026
2 checks passed
@jplatte
Copy link
Collaborator

jplatte commented Mar 17, 2026

Sorry about being so slow to get to PRs. This isn't my most fun project and I've got a lot of stuff going on irl at the moment.

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