Class: DocsUI::ErrorTable
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- DocsUI::ErrorTable
- Defined in:
- app/components/docs_ui/error_table.rb
Overview
An error reference table for an API endpoint — a keyword-schema preset over DocsUI::Table. Each error is a Hash:
render DocsUI::ErrorTable.new(
[
{ scenario: "Missing or invalid API key", status: "401", type: "authentication_error" },
{ scenario: "Non-HTTPS URL", status: "422", type: "validation_error", param: "url" },
]
)
Columns: Scenario / Status / Type (auto code-styled) / Param (auto code-styled).
The Param column is shown only when at least one error names a param — an
endpoint whose errors are all param-free renders a clean three-column table.
When the column IS shown, a param-free row gets the canonical em-dash —.
type: is optional — OpenAPI has no canonical error-type field, so an
OpenAPI-derived error may carry none. A row without a (present) type gets the
em-dash — in the Type column, not an empty ; a row with type:
renders it code-styled exactly as before.
Constant Summary collapse
- BASE_HEADERS =
%w[Scenario Status Type].freeze
- PARAM_HEADER =
"Param"- NO_PARAM =
Shared with FieldTable's canonical "no value" placeholder.
"—"
Instance Method Summary collapse
-
#initialize(errors) ⇒ ErrorTable
constructor
A new instance of ErrorTable.
- #view_template ⇒ Object
Constructor Details
#initialize(errors) ⇒ ErrorTable
Returns a new instance of ErrorTable.
30 31 32 33 |
# File 'app/components/docs_ui/error_table.rb', line 30 def initialize(errors) @errors = errors @with_param = errors.any? { |error| present_param?(error[:param]) } end |