mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 17:00:27 -04:00
c5a88a9fc4
* feat: render body parameters * feat: api parameters render * fix: update mgmt api spec to latest * fix: body param format and support content type selection * fix: prettier errors * fix: use Options to render accepted enum values * fix: prettier again * fix: merge conflict * fix: expose new api routes * fix: prettier again * refactor: ApiBodyParam * fix: add missing apis * chore: tidy up * feat: improve api response with sample + schema tabs * fix: support show/hide object param schema * fix: show no content text * refactor: use collapsible for hidden content * Update apps/docs/components/reference/ApiOperationSection.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Update apps/docs/components/ApiSchemaOption.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * fix: resolve comments --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import Options from '~/components/Options'
|
|
import Param from '~/components/Params'
|
|
import ApiSchema from '~/components/ApiSchema'
|
|
import ApiSchemaOptions from '~/components/ApiSchemaOption'
|
|
|
|
type IParamProps = any
|
|
|
|
const ApiBodyParam = ({ name, value, isOptional }: IParamProps) => {
|
|
return (
|
|
<Param
|
|
key={name}
|
|
name={name}
|
|
type={
|
|
(value as any).type === 'array'
|
|
? `array[${(value as any).items?.type}]`
|
|
: (value as any).type
|
|
}
|
|
description={value.description}
|
|
isOptional={isOptional}
|
|
>
|
|
{(value as any).enum && (
|
|
<Options>
|
|
{(value as any).enum.map((value) => {
|
|
return <Options.Option key={value} name={value} isEnum={true} />
|
|
})}
|
|
</Options>
|
|
)}
|
|
{(value as any).type === 'object' && (
|
|
<ApiSchemaOptions>
|
|
<div
|
|
className="
|
|
px-5 py-3 first:border-t border-b border-l border-r
|
|
border-default
|
|
last:rounded-bl-lg last:rounded-br-lg
|
|
flex flex-col gap-3
|
|
"
|
|
>
|
|
<ApiSchema id={name} schema={value}></ApiSchema>
|
|
</div>
|
|
</ApiSchemaOptions>
|
|
)}
|
|
</Param>
|
|
)
|
|
}
|
|
|
|
export default ApiBodyParam
|