Ariadocs

Read the current spec, endpoint or schema in your own components.

Each OpenAPI component shares its data through React context. Hooks let your own components read it, so they fit between the built-in parts.

HookReturnsUse inside
useOpenAPI()The spec, plus getOperation and getSchemaOpenAPI.Root
useOperation()The endpointOpenAPI.Operation
useParameter()The parameterOpenAPI.Parameter
useResponse()The responseOpenAPI.Response
useSchema()The schema and its nameOpenAPI.Schema

A hook used outside its component throws an error that says where it belongs.

"use client";

import { useOperation } from "@ariadocs/components";

export function Tags() {
  const operation = useOperation();
  return <p>Tags: {operation.tags.join(", ")}</p>;
}
<OpenAPI.Operation id="emails-list">
  <OpenAPI.Operation.Header />
  <Tags />
</OpenAPI.Operation>