Repository navigation
refactor(openapi)!: make documentation endpoints explicit - #115
Merged
Merged
Conversation
This was referenced Sep 14, 2026
This was referenced Sep 14, 2026
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.
Enabling the
openapifeature previously mounted/openapi.json,/redoc, and/scalarafter business middleware, so those endpoints could bypass authentication.with_openapi()had no effect, and exporting the assembled document required an HTTP request.Documentation endpoints are now disabled by default.
with_openapi()explicitly enables the standard paths;OpenApiEndpointsconfigures the JSON path and optional UI paths through the builder orGotchaApp::openapi_endpoints. Endpoint settings belong to the application, and both UIs load the configured JSON URL. Invalid or duplicate endpoint paths fail assembly; conflicts with business routes follow Axum's existing behavior.Both APIs use one assembly pipeline: business routes, optional documentation, then application middleware. Builder
app_layerand traitfinish_routercover documentation and fallback routes as well as business routes. Existinglayerbehavior remains scoped to routes already registered. Application layers are installed once, in Axum order, with the last registered layer receiving requests first.Gotcha::into_openapi,GotchaRouter::into_openapi, andGotchaApp::openapi_documentexpose the complete document without loading configuration, initializing state, binding a listener, or registering tasks. Export and HTTP serving share schema generation and the existingFnOncetransform pipeline. When neither export nor HTTP documentation is requested, no document is generated and transforms do not run.Migration: applications that previously relied on the feature alone must explicitly enable endpoints. Existing
with_openapi()calls now do so. Move authentication toapp_layer/finish_routerwhen it must also protect documentation. The migration guide covers custom paths, disabled UIs, middleware order, and custombuild_routeroverrides. Existing documentation tests and examples now opt in; the OpenAPI example adds--export-openapi. Remove the now-unused directcfg-ifdependency.Validation:
cargo test -p gotchaandcargo test -p gotcha --all-features, including existing schema, response-contract, transform, startup, and doctest coverage.-D warnings; formatting and diff checks.RUSTDOCFLAGS='-D warnings' cargo doc -p gotcha --all-features --no-deps.All 11 GitHub CI checks passed for
4b25e914e3abba446bd6dcd77898e9c757570c5c.Closes #88.
Closes #77.