Files
supabase/apps/docs/components/ApiSchema.tsx
T
Charis 11e19ff29f refactor(docs): convert self-hosting to app router (#29268)
* chore(docs,refs): prebuild self-hosted ref data

Pregenerate self-hosted ref data files, in the style of the client lib,
Management API, and CLI references. Preparatory step for migrating the
self-hosted references to App Router.

* refactor(docs): convert self-hosting to app router

Convert self-hosting reference pages to App Router.

* fix(docs,sitemap)
2024-09-13 09:45:55 -04:00

42 lines
1.1 KiB
TypeScript

import { CodeBlock } from '@ui/components/CodeBlock'
import { sample } from '@har-sdk/openapi-sampler'
import { Tabs, TabPanel } from '~/features/ui/Tabs'
type IParamProps = any
const ApiSchema = ({ schema, id }: IParamProps) => {
let example: string
try {
example = sample(schema, { skipReadOnly: true, quiet: true })
} catch {
// ignore
}
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 language="bash" className="relative">
{JSON.stringify(example, null, 2)}
</CodeBlock>
</div>
</TabPanel>
)}
<TabPanel key={`${id ?? ''}-schema`} id="schema" label="schema">
<div className="mt-8">
<CodeBlock language="bash" className="relative">
{JSON.stringify(schema, null, 2)}
</CodeBlock>
</div>
</TabPanel>
</Tabs>
)
}
export default ApiSchema