CUI

Components / Developer tools

API explorer

The endpoints of an API grouped by tag, each opening to show its parameters.

Functions: cui_api_explorer

API explorer

Usage

static const cui_api_param user_params[] = { { "id", "path", "string", true, "The user's id" } };
static const cui_api_endpoint endpoints[] = {
    { "GET", "/users", "List users", "Users" },
    { "GET", "/users/{id}", "Get a user", "Users", false, user_params, 1 },
};
cui_api_explorer_result r = cui_api_explorer(ui, "api", endpoints, 2);
if (r.try_it >= 0) open_request(&endpoints[r.try_it]);

Endpoints grouped by tag, in the order the tags first appear; a tag's header folds its group. Each endpoint shows its method in its color (GET blue, POST green, PUT amber, PATCH teal, DELETE red), its path with the {parameters} marked, and its summary. A deprecated endpoint is struck through and badged. A click opens an endpoint's parameters (name, required mark, type, where it goes, description) and a Try it button. A field filters by path or summary. Up and Down move, and Enter or Space opens. With height the list scrolls and keeps the selection in view.

Keyboard

  • Up and Down move, and Enter or Space opens.

Options of cui_api_explorer

OptionTypeDefaultDescription
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.heightfloatHeight in points; 0 uses the component's own.
.selectedint *the selected endpoint or -1, kept by you; NULL keeps it in the component

cui_api_endpoint

FieldTypeDescription
methodconst char *"GET"
pathconst char *"/users/{id}"
summaryconst char *one line after the path; the filter field searches it
tagconst char *groups the list; NULL groups as "Other"
deprecatedboolstruck through and muted, with a "Deprecated" badge
paramsconst cui_api_param *the parameters listed when the endpoint is opened; may be NULL
param_countintnumber of params

cui_api_param

FieldTypeDescription
nameconst char *the parameter's name, in the code font
inconst char *where it goes: "path", "query", "header" or "body"
typeconst char *e.g. "string"; shown before where it goes
requiredboola red asterisk after the name
descriptionconst char *what the parameter is for, shown after its type and place; may be NULL

cui_api_explorer_result

FieldTypeDescription
selectedintthe selected endpoint, or -1
try_itintendpoint, or -1

Related

  • Feature flags: Flags against environments, edited in place.
  • Blame: Source with who last changed each line.
  • Coverage: Test coverage as a tree built from the files' paths.
  • Time histogram: Event counts over time, stacked by series, as above a log search, with a legend that shows each series' total.