mirror of
https://github.com/supabase/supabase.git
synced 2026-05-11 02:20:29 +08:00
strictNullChecks was off for docs, which lets errors slip through and leads to incorrect required/optional typing on Zod-inferred types. This PR enables strictNullChecks and fixes all the existing violations.
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { sample } from '@har-sdk/openapi-sampler'
|
|
|
|
import { CodeBlock } from '~/features/ui/CodeBlock/CodeBlock'
|
|
import { Tabs, TabPanel } from '~/features/ui/Tabs'
|
|
|
|
type IParamProps = any
|
|
|
|
const ApiSchema = ({ schema, id }: IParamProps) => {
|
|
let example: string | undefined
|
|
try {
|
|
example = sample(schema, { skipReadOnly: true, quiet: true })
|
|
} catch {
|
|
example = undefined
|
|
}
|
|
return (
|
|
<Tabs
|
|
scrollable
|
|
size="small"
|
|
type="underlined"
|
|
defaultActiveId={example ? 'example' : 'schema'}
|
|
>
|
|
{example && (
|
|
<TabPanel key={`${id ?? ''}-example`} id="example" label="example">
|
|
<div className="mt-8">
|
|
<CodeBlock lang="bash">{JSON.stringify(example, null, 2)}</CodeBlock>
|
|
</div>
|
|
</TabPanel>
|
|
)}
|
|
<TabPanel key={`${id ?? ''}-schema`} id="schema" label="schema">
|
|
<div className="mt-8">
|
|
<CodeBlock lang="bash">{JSON.stringify(schema, null, 2)}</CodeBlock>
|
|
</div>
|
|
</TabPanel>
|
|
</Tabs>
|
|
)
|
|
}
|
|
|
|
export default ApiSchema
|