Skip to main content

API Reference

<OasDocument /> Props

PropTypeDefaultDescription
inputOpenApiInput | OpenApiDocument | nullrequiredThe OpenAPI/Swagger document (object, JSON string, or YAML string)
autoUpgradebooleantrueValidate and upgrade to OAS 3.2 via @powerduck/openapi-parser
defaultOperationIdstringOperation ID to select on initial render
onOperationChange(operation) => voidCallback on user-initiated selection changes
classNamestringAdditional CSS class for root
styleReact.CSSPropertiesInline styles for root
theme"light" | "dark""light"Initial theme. Persisted to localStorage.
headerOasDocumentHeaderConfigHeader configuration (logo, title, nav links)
showTreebooleantrueShow sidebar tree
treeWidthnumber340Sidebar width in pixels (range 240-480)

Header config

FieldTypeDefault
logostring | ReactNode
titlestring"API Documentation"
navItemsArray<{ label, href?, onClick? }>[]
showThemeTogglebooleantrue

useOasDocument(input, options?)

const {
document, // Oas32Document | null
loading, // boolean
error, // Error | null
operations, // OasOperation[]
navigationGroups, // OasNavigationGroup[]
tree, // TreeNode[]
selectedOperation, // OasOperation | undefined
setSelectedOperation,
theme, // "light" | "dark"
setTheme,
} = useOasDocument(spec, { autoUpgrade: true });

Core functions

FunctionDescription
loadOasDocument(input, options?)Load and upgrade a document. Returns { document, operations, navigationGroups, tree, warnings, error }
parseOperations(document)Extract operations from an OAS document
buildNavigationGroups(document)Build grouped navigation structure