Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

revert openapi spec stuff

Kang Ming12321dfb58bc
diff --git a/apps/docs/lib/refGenerator/helpers.ts b/apps/docs/lib/refGenerator/helpers.ts
index 49439fe7e46..9adb3335ee6 100644
--- a/apps/docs/lib/refGenerator/helpers.ts
+++ b/apps/docs/lib/refGenerator/helpers.ts
@@ -1,6 +1,7 @@
import { TsDoc } from '~/generator/legacy/definitions'
import { uniqBy } from 'lodash'
+import { OpenAPIV3 } from 'openapi-types'
export function extractTsDocNode(nodeToFind: string, definition: any) {
const nodePath = nodeToFind.split('.')
@@ -163,34 +164,52 @@ ${commentObject?.text || ''}
// }
// OPENAPI-SPEC-VERSION: 3.0.0
-// type v3OperationWithPath = OpenAPIV3.OperationObject & {
-// path: string
-// }
-// type enrichedOperation = OpenAPIV3.OperationObject & {
-// path: string
-// fullPath: string
-// operationId: string
-// }
-// export function gen_v3(spec: OpenAPIV3.Document, dest: string, { apiUrl }: { apiUrl: string }) {
-// const specLayout = spec.tags || []
-// const operations: enrichedOperation[] = []
-// console.log('im v3ing')
-// Object.entries(spec.paths).forEach(([key, val]) => {
-// const fullPath = `${apiUrl}${key}`
-
-// toArrayWithKey(val!, 'operation').forEach((o) => {
-// const operation = o as v3OperationWithPath
-// const enriched = {
-// ...operation,
-// path: key,
-// fullPath,
-// operationId: slugify(operation.summary!),
-
-// responseList: toArrayWithKey(operation.responses!, 'responseCode') || [],
-// }
-// operations.push(enriched)
-// })
-// })
+type v3OperationWithPath = OpenAPIV3.OperationObject & {
+ path: string
+}
+type enrichedOperation = OpenAPIV3.OperationObject & {
+ path: string
+ fullPath: string
+ operationId: string
+}
+export function gen_v3(spec: OpenAPIV3.Document, dest: string, { apiUrl }: { apiUrl: string }) {
+ const specLayout = spec.tags || []
+ const operations: enrichedOperation[] = []
+ console.log('im v3ing')
+ Object.entries(spec.paths).forEach(([key, val]) => {
+ const fullPath = `${apiUrl}${key}`
+
+ toArrayWithKey(val!, 'operation').forEach((o) => {
+ const operation = o as v3OperationWithPath
+ const enriched = {
+ ...operation,
+ path: key,
+ fullPath,
+ operationId: slugify(operation.summary!),
+
+ responseList: toArrayWithKey(operation.responses!, 'responseCode') || [],
+ }
+ operations.push(enriched)
+ })
+ })
+
+ const sections = specLayout.map((section) => {
+ return {
+ ...section,
+ title: toTitle(section.name),
+ id: slugify(section.name),
+ operations: operations.filter((operation) => operation.tags?.includes(section.name)),
+ }
+ })
+
+ const content = {
+ info: spec.info,
+ sections,
+ operations,
+ }
+
+ return content
+}
const slugify = (text: string) => {
return text