Home / Function/ gen_v2() — supabase Function Reference

gen_v2() — supabase Function Reference

Architecture documentation for the gen_v2() function in api.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  167c5e66_f623_cbb8_77f7_298cdb145d98["gen_v2()"]
  4b0a8f5d_f814_02be_3a7d_84dc3fcc29f8["gen()"]
  4b0a8f5d_f814_02be_3a7d_84dc3fcc29f8 -->|calls| 167c5e66_f623_cbb8_77f7_298cdb145d98
  5d7f4cb4_0247_6736_6311_da72fe2e68fc["toArrayWithKey()"]
  167c5e66_f623_cbb8_77f7_298cdb145d98 -->|calls| 5d7f4cb4_0247_6736_6311_da72fe2e68fc
  088ba946_bf3a_b2cf_624f_c3480af29b59["slugify()"]
  167c5e66_f623_cbb8_77f7_298cdb145d98 -->|calls| 088ba946_bf3a_b2cf_624f_c3480af29b59
  79fbafa0_1237_b988_633e_7a9598f7110e["toTitle()"]
  167c5e66_f623_cbb8_77f7_298cdb145d98 -->|calls| 79fbafa0_1237_b988_633e_7a9598f7110e
  c3f63f97_1b0c_be51_f93b_a348e9e50e58["writeToDisk()"]
  167c5e66_f623_cbb8_77f7_298cdb145d98 -->|calls| c3f63f97_1b0c_be51_f93b_a348e9e50e58
  style 167c5e66_f623_cbb8_77f7_298cdb145d98 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/generator/api.ts lines 78–114

async function gen_v2(spec: OpenAPIV2.Document, dest: string, { apiUrl }: { apiUrl: string }) {
  const specLayout = spec.tags || []
  const operations: enrichedOperation[] = []
  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 = ejs.render(template, {
    info: spec.info,
    sections,
    operations,
  })
  // Write to disk
  await writeToDisk(dest, content)
  console.log('Saved: ', dest)
}

Subdomains

Called By

Frequently Asked Questions

What does gen_v2() do?
gen_v2() is a function in the supabase codebase.
What does gen_v2() call?
gen_v2() calls 4 function(s): slugify, toArrayWithKey, toTitle, writeToDisk.
What calls gen_v2()?
gen_v2() is called by 1 function(s): gen.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free