Skip to content

OpenAPI publisher: point 404s to the /api-docs overview - #3591

Merged
rrayst merged 2 commits into
masterfrom
fix/3145-api-docs-not-found-hint
Oct 27, 2026
Merged

rrayst merged 2 commits into
masterfrom
fix/3145-api-docs-not-found-hint

Conversation

@predic8

@predic8 predic8 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

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

  • Unknown id (/api-docs/<id>, /api-docs/ui/<id>): the detail now ends with "See /api-docs for the available documents."
  • Swagger UI without an id (/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.
  • Browsers (Accept: text/html) get the existing ProblemDetails HTML error page with this text.

Tests

  • New OpenAPIPublisherTest.notFoundRefersToOverviewInProduction covers all three cases in production mode.
  • Adjusted the exact-detail assertions in OpenAPIPublisherTest and OpenAPIPublisherInterceptorTest.

Summary by CodeRabbit

  • Bug Fixes
    • When an API documentation page cannot be found—including requests with an unknown document ID or a missing ID—the 404 response now points to the API documentation overview. This applies to both standard and UI routes, giving you a direct way to return to the list of available documents.

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
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f626246 and 3f4e1ad.

Files selected for processing: 3
  • 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

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

OpenAPI 404 details for missing document IDs and requests to the Swagger UI route without an ID now refer to /api-docs. Tests verify the updated detail for these routes and for unknown document IDs.

Changes: OpenAPI 404 guidance

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: Low

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: updating OpenAPI publisher 404 responses to direct users to the /api-docs overview.
Linked Issues check Passed Issue [#3145] requires an error response for an invalid OpenAPI request that refers the user to /api-docs. OpenAPIPublisher adds See /api-docs for the available documents. to missing-ID and unkn…
Out of Scope Changes check Passed 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…
Full details: Linked Issues check

Explanation

Issue [#3145] requires an error response for an invalid OpenAPI request that refers the user to /api-docs. OpenAPIPublisher adds See /api-docs for the available documents. to missing-ID and unknown-ID details. The unknown-ID path covers /api-docs/ui/wrong. The detail(..., true) calls preserve the existing ProblemDetails error-page behavior. OpenAPIPublisherTest covers 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.

❤️ Share

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.

@predic8

predic8 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

/ok-to-test

@membrane-ci-server

Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

@predic8
predic8 requested a review from rrayst October 26, 2026 18:19
@rrayst
rrayst merged commit 3ec9515 into master Oct 27, 2026
6 checks passed
@rrayst
rrayst deleted the fix/3145-api-docs-not-found-hint branch October 27, 2026 08:14
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.

Answer to a invalid OpenAPI Request

2 participants