Repository navigation
OpenAPI publisher: point 404s to the /api-docs overview - #3591
Conversation
Requests for an unknown OpenAPI id (/api-docs/<id>, /api-docs/ui/<id>) or for the Swagger UI without an id (/api-docs/ui) returned a 404 without saying where to find the valid documents. The detail now ends with "See /api-docs for the available documents.". The no-id detail is also returned in production mode, so the hint is not lost there. Closes #3145
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
404 details and tests core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPIPublisher.java, core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPIPublisherInterceptorTest.java, core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/OpenAPIPublisherTest.java |
404 details for missing IDs and unknown documents now point to /api-docs. Tests check the updated detail for document and Swagger UI paths. The test imports name assertEquals and assertTrue explicitly. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Feature · Severity of issue fixed: Low
Suggested reviewers: christiangoerdes
Merge Risk: 
Minimal · up to 3f4e1
-
The 404 guidance change is ready to merge with no identified user-facing or operational risk.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue [
#3145] requires an error response for an invalid OpenAPI request that refers the user to/api-docs.OpenAPIPublisheraddsSee /api-docs for the available documents.to missing-ID and unknown-ID details. The unknown-ID path covers/api-docs/ui/wrong. Thedetail(..., true)calls preserve the existing ProblemDetails error-page behavior.OpenAPIPublisherTestcovers the three relevant production routes, and existing exact-detail tests were updated.
Full details: Out of Scope Changes check
-
Explanation
The production change is limited to shared 404 detail text in
OpenAPIPublisher. The test changes verify the new text and update affected exact assertions. The explicit JUnit imports are limited test cleanup. No unrelated product behavior or unrelated tests are changed.
-
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit found a missing page,
And pointed out the docs’ front stage.
“Try /api-docs,” the message read,
Then off the rabbit softly sped.
The paths now guide the search ahead.
Comment @coderabbitai help to get the list of available commands.
|
/ok-to-test |
|
This pull request needs "/ok-to-test" from an authorized committer. |
Closes #3145
Requesting an OpenAPI document or Swagger UI that does not exist returned a 404 without telling the user where to find the valid documents.
Changes
/api-docs/<id>,/api-docs/ui/<id>): the detail now ends with "See /api-docs for the available documents."/api-docs/ui,/api-docs/ui/): same hint. This detail is now also returned in production mode, where it used to be hidden. It contains no internal information.Accept: text/html) get the existing ProblemDetails HTML error page with this text.Tests
OpenAPIPublisherTest.notFoundRefersToOverviewInProductioncovers all three cases in production mode.OpenAPIPublisherTestandOpenAPIPublisherInterceptorTest.Summary by CodeRabbit