Raw
1 "use client"
2
3 import { useMemo } from "react"
4 import generateSchemaExamples, {
5 GenerateSchemaExamplesOptions,
6 } from "@/utils/generate-schema-examples"
7
8 const useSchemaExample = ({
9 schema,
10 schemaExamples,
11 schemaExample,
12 options = {},
13 }: GenerateSchemaExamplesOptions) => {
14 const { skipNonRequired = true } = options
15 const examples = useMemo(
16 () =>
17 generateSchemaExamples({
18 schema,
19 schemaExamples,
20 schemaExample,
21 options: { skipNonRequired },
22 }),
23 [schema, schemaExample, schemaExamples, skipNonRequired]
24 )
25
26 return {
27 examples,
28 }
29 }
30
31 export default useSchemaExample