Home / Class/ OpenApiReferenceSource Class — supabase Architecture

OpenApiReferenceSource Class — supabase Architecture

Architecture documentation for the OpenApiReferenceSource class in reference-doc.ts from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/docs/scripts/search/sources/reference-doc.ts lines 167–247

export class OpenApiReferenceSource extends ReferenceSource<Partial<enrichedOperation>> {
  formatSection(specOperation: enrichedOperation, _: ICommonItem) {
    const { summary, description, operation, path, tags, parameters, responses, operationId } =
      specOperation
    return JSON.stringify({
      summary,
      description,
      operation,
      path,
      tags,
      parameters,
      responses,
      operationId,
    })
  }

  extractSubtitle() {
    return `${this.meta.title}: ${this.specSection.description || this.specSection.operationId || ''}`
  }

  extractTitle() {
    return (
      this.specSection.summary ||
      (typeof this.meta.title === 'string' ? this.meta.title : this.specSection.operation) ||
      ''
    )
  }

  extractIndexedContent(): string {
    const { summary, description, operation, tags, path, parameters, responses } = this.specSection

    const sections: string[] = []

    // Title
    sections.push(`# ${this.meta.title ?? ''}`)

    // Summary
    if (summary) {
      sections.push(summary)
    }

    // Description
    if (description) {
      sections.push(`Description: ${description}`)
    }

    // Path and Method
    if (path) {
      sections.push(`Path: ${operation?.toUpperCase() || 'GET'} ${path}`)
    }

    // Parameters
    if (parameters && parameters.length > 0) {
      const paramList = parameters
        .map((param: any) => {
          const required = param.required ? 'required' : 'optional'
          return `- ${param.name} (${param.schema?.type || 'string'}, ${required}): ${param.description || ''}`
        })
        .join('\n')
      sections.push(`Parameters:\n${paramList}`)
    }

    // Response Types
    if (responses) {
      const responseList = Object.entries(responses)
        .map(([code, response]: [string, any]) => {
          const desc = response.description || 'No description'
          return `- ${code}: ${desc}`
        })
        .join('\n')
      sections.push(`Responses:\n${responseList}`)
    }

    // Tags
    if (tags && tags.length > 0) {
      sections.push(`Tags: ${tags.join(', ')}`)
    }

    return sections.filter(Boolean).join('\n\n')
  }
}

Analyze Your Own Codebase

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

Try Supermodel Free