メインコンテンツまでスキップ

API リファレンス

<OasDocument /> — プロパティ​

プロパティ型既定値説明
inputOpenApiInput | OpenApiDocument | null必須OpenAPI/Swagger ドキュメント(オブジェクト、JSON 文字列、YAML 文字列)
autoUpgradebooleantrue@powerduck/openapi-parser で検証して OAS 3.2 に変換
defaultOperationIdstring—初期描画時に選択する操作 ID
onOperationChange(operation) => void—ユーザーによる選択変更時のコールバック
classNamestring—ルート要素に追加する CSS クラス
styleReact.CSSProperties—ルート要素のインラインスタイル
theme"light" | "dark""light"初期テーマ。localStorage に保存されます。
headerOasDocumentHeaderConfig—ヘッダー設定(ロゴ、タイトル、ナビゲーションリンク)
showTreebooleantrueサイドバーツリーを表示
treeWidthnumber340サイドバーの幅(ピクセル単位、240~480)

ヘッダー設定​

フィールド型既定値
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 });

コア関数​

関数説明
loadOasDocument(input, options?)ドキュメントを読み込んで変換し、{ document, operations, navigationGroups, tree, warnings, error } を返す
parseOperations(document)OAS ドキュメントから操作を抽出
buildNavigationGroups(document)グループ化したナビゲーション構造を構築