mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Start Storage api file
This commit is contained in:
1 parent
65f2feb59e
commit
aff740b08a
4 files changed
+161
-15
No files matched your search
@@ -33,7 +33,7 @@ export default async function gen(inputFileName: string, outputDir: string, apiU
|
||||
type v3OperationWithPath = OpenAPIV3.OperationObject & {
|
||||
path: string
|
||||
}
|
||||
type enrichedOperation = OpenAPIV3.OperationObject & {
|
||||
export type enrichedOperation = OpenAPIV3.OperationObject & {
|
||||
path: string
|
||||
fullPath: string
|
||||
operationId: string
|
||||
|
||||
@@ -43,7 +43,7 @@ const Section: FC<ISectionContainer> = (props) => {
|
||||
|
||||
interface ISectionDetails extends FC {}
|
||||
|
||||
const Details: FC<ISectionDetails> = (props) => {
|
||||
const Details: FC<ISectionDetails> = (props: any) => {
|
||||
return <div className="">{props.children}</div>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TsDoc } from '~/generator/legacy/definitions'
|
||||
|
||||
import { uniqBy } from 'lodash'
|
||||
import { uniqBy, values, mapValues } from 'lodash'
|
||||
import { OpenAPIV3 } from 'openapi-types'
|
||||
|
||||
export function extractTsDocNode(nodeToFind: string, definition: any) {
|
||||
@@ -231,8 +231,8 @@ const toTitle = (text: string) => {
|
||||
* Convert Object to Array of values
|
||||
*/
|
||||
export const toArrayWithKey = (obj: object, keyAs: string) =>
|
||||
_.values(
|
||||
_.mapValues(obj, (value: any, key: string) => {
|
||||
values(
|
||||
mapValues(obj, (value: any, key: string) => {
|
||||
value[keyAs] = key
|
||||
return value
|
||||
})
|
||||
|
||||
@@ -1,16 +1,162 @@
|
||||
import specFile from '~/../../spec/storage_v0_openapi.json' assert { type: 'json' }
|
||||
import { gen_v3 } from '~/lib/refGenerator/helpers'
|
||||
import { gen_v3, enrichedOperation } from '~/lib/refGenerator/helpers'
|
||||
import { Tabs } from '~/../../packages/ui'
|
||||
// @ts-ignore
|
||||
import CodeBlock from '~/components/CodeBlock/CodeBlock'
|
||||
import Options from '~/components/Options'
|
||||
import Param from '~/components/Params'
|
||||
import RefSubLayout from '~/layouts/ref/RefSubLayout'
|
||||
|
||||
export type AcceptedValue = {
|
||||
id: string
|
||||
name: string
|
||||
type: 'string' | 'boolean' | 'object'
|
||||
description?: string
|
||||
}
|
||||
|
||||
export type Flag = {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
default_value: string
|
||||
accepted_values: AcceptedValue[]
|
||||
}
|
||||
|
||||
export type ApiParameter = {
|
||||
example: string
|
||||
in: string
|
||||
name: string
|
||||
required: boolean
|
||||
schema: {
|
||||
type: string
|
||||
example: string
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const specGen = gen_v3(specFile, 'wat', { apiUrl: 'apiv0' })
|
||||
|
||||
console.log({ specGen })
|
||||
|
||||
export default function Ref(props) {
|
||||
console.log({ specFile })
|
||||
const generatedSpec = gen_v3(specFile, 'wat', { apiUrl: 'apiv0' })
|
||||
console.log('zans', generatedSpec)
|
||||
export default function Config() {
|
||||
return (
|
||||
<div>
|
||||
<div className="flex my-16">hay?</div>
|
||||
</div>
|
||||
<RefSubLayout>
|
||||
<div className="flex my-16">
|
||||
<div className="w-full">
|
||||
<div className="grid gap-16">
|
||||
<h1 className="text-4xl">{generatedSpec.info.title}</h1>
|
||||
<p>{generatedSpec.info.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-32 mx-auto max-w-5xl mt-24">
|
||||
{generatedSpec.sections.map((section) => {
|
||||
return (
|
||||
<RefSubLayout.Section title={section.title} id={section.id} monoFont={false}>
|
||||
<RefSubLayout.Details>
|
||||
<div className="grid ref-container" id={section.id}>
|
||||
<div className="border-b pb-8" key={section.id}>
|
||||
<p>{section.description}</p>
|
||||
<div>
|
||||
{section.operations.map((operation: enrichedOperation) => (
|
||||
<>
|
||||
<div className="my-8">
|
||||
<p className="text-xl">{operation.summary}</p>
|
||||
<div className="mt-4">
|
||||
<code className="text-md flex gap-4 text-md text-scale-900">
|
||||
<span className="uppercase">{operation.operation}</span>
|
||||
{operation.fullPath}
|
||||
</code>
|
||||
</div>
|
||||
<div className="mt-12">
|
||||
<h2 className="border-b pb-2 text-xl">Path parameters</h2>
|
||||
<ul className="mt-4">
|
||||
{operation.parameters &&
|
||||
operation.parameters
|
||||
.filter((parameter) => parameter.in === 'path')
|
||||
.map((parameter: ApiParameter) => (
|
||||
<li className="mt-8 border-b pb-6">
|
||||
<div className="flex gap-4 items-center">
|
||||
<span className="font-bold">{parameter.name}</span>
|
||||
<span className="font-mono text-xs">
|
||||
{parameter.required && 'required'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-4 flex gap-4 items-center">
|
||||
<span>Example:</span>
|
||||
<span className="font-mono text-xs">
|
||||
{parameter.example}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="mt-12">
|
||||
<h2 className="border-b pb-2 text-xl">Header parameters</h2>
|
||||
<ul className="mt-4">
|
||||
{operation.parameters &&
|
||||
operation.parameters
|
||||
.filter((parameter) => parameter.in === 'header')
|
||||
.map((parameter: ApiParameter) => (
|
||||
<li className="mt-8 border-b pb-6">
|
||||
<div className="flex gap-4 items-center">
|
||||
<span className="font-bold">{parameter.name}</span>
|
||||
<span className="font-mono text-xs">
|
||||
{parameter.required && 'required'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-4 flex gap-4 items-center">
|
||||
<span>Example:</span>
|
||||
<span className="font-mono text-xs">
|
||||
{parameter.example}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 className="text-xl">Responses</h2>
|
||||
<Tabs
|
||||
scrollable
|
||||
size="small"
|
||||
type="underlined"
|
||||
defaultActiveId={operation.responseList[0].responseCode}
|
||||
>
|
||||
{operation.responseList.map((response) => (
|
||||
<Tabs.Panel
|
||||
id={response.responseCode}
|
||||
label={response.responseCode}
|
||||
>
|
||||
<p>{response.description}</p>
|
||||
{response?.content && response?.content['application/json'] && (
|
||||
<div className="mt-8">
|
||||
<CodeBlock language="bash" className="relative">
|
||||
{JSON.stringify(
|
||||
response.content['application/json'],
|
||||
null,
|
||||
2
|
||||
)}
|
||||
</CodeBlock>
|
||||
</div>
|
||||
)}
|
||||
</Tabs.Panel>
|
||||
))}
|
||||
</Tabs>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</RefSubLayout.Details>
|
||||
|
||||
<RefSubLayout.Examples>right side</RefSubLayout.Examples>
|
||||
</RefSubLayout.Section>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</RefSubLayout>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user