pub fn record_required_permission(
op: &mut Operation,
scheme: &str,
scope: &str,
display: &str,
)Expand description
Record a per-operation permission requirement on op, emitting:
- A standard
SecurityRequirementreferencingschemewith the suppliedscope— so OpenAPI client codegen sees a required OAuth scope and threads it through to the token request. - An
x-required-permissionsvendor extension entry containingdisplay— a machine-readable list of the actions a request must satisfy, available to tooling that walks the spec. - An
x-badgesvendor extension entry shaped for Scalar’s native badge renderer ({name, color}) — surfaces the permission as a colored chip on each operation header, no markdown injection. Scalar accepts any CSS color value; we use the Scalar CSS custom propertyvar(--scalar-color-accent)so badges adopt whatever accent color the active theme defines.
All three writes are idempotent — repeated calls with the same
arguments don’t duplicate. The scope is the canonical machine
identifier (e.g. an OAuth2 scope string); display is the human
label rendered in badges and in x-required-permissions.