Skip to content

Add OpenAPIOptions controls to hide routes and suppress default error responses#55

Merged
moutonjeremy merged 3 commits into
mainfrom
feat-suppress-default-error-responses
Jun 2, 2026
Merged

Add OpenAPIOptions controls to hide routes and suppress default error responses#55
moutonjeremy merged 3 commits into
mainfrom
feat-suppress-default-error-responses

Conversation

@moutonjeremy
Copy link
Copy Markdown
Member

@moutonjeremy moutonjeremy commented Jun 2, 2026

Adds two new OpenAPIOptions fields:

  • Hidden: skip an operation from the generated spec while still serving traffic
  • Errors: []any{} (explicit empty slice): suppress the framework's default 400/422/404/4XX entries

Copilot AI review requested due to automatic review settings June 2, 2026 20:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an explicit opt-out mechanism for framework-generated default error responses in the generated OpenAPI spec, allowing “no error contract” endpoints (e.g., health checks) to document only their success response.

Changes:

  • Treat OpenAPIOptions.Errors: []any{} (non-nil, length 0) as a signal to suppress all default error responses in the OpenAPI spec.
  • Update OpenAPI generation to honor this opt-out for the legacy 4XX catch-all and default 400/422/404 responses.
  • Document the behavior in the README and add regression tests covering nil vs empty vs nil-only Errors slices.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
README.md Documents the new “explicit empty Errors slice” opt-out behavior and clarifies nil vs empty semantics.
fiberoapi.go Implements suppression of default OpenAPI error responses when Errors is explicitly empty.
custom_errors_test.go Adds tests validating suppression behavior and preserving backward compatibility for nil and nil-only slices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread types.go
Comment thread hidden_path_test.go Outdated
Comment thread hidden_path_test.go Outdated
@moutonjeremy moutonjeremy changed the title Add support for suppressing default error responses in OpenAPI spec Add OpenAPIOptions controls to hide routes and suppress default error responses Jun 2, 2026
@moutonjeremy moutonjeremy merged commit 12a771e into main Jun 2, 2026
4 checks passed
@moutonjeremy moutonjeremy deleted the feat-suppress-default-error-responses branch June 2, 2026 20:39
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