Home / Class/ OpenApiReferenceLoader Class — supabase Architecture

OpenApiReferenceLoader Class — supabase Architecture

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

Entity Profile

Relationship Graph

Source Code

apps/docs/scripts/search/sources/reference-doc.ts lines 123–165

export class OpenApiReferenceLoader extends ReferenceLoader<Partial<enrichedOperation>> {
  constructor(
    source: string,
    path: string,
    meta: Record<string, unknown>,
    specFilePath: string,
    sectionsFilePath: string
  ) {
    super(source, path, meta, specFilePath, sectionsFilePath)
    this.sourceConstructor = (...args) => new OpenApiReferenceSource(...args)
  }

  getSpecSections(specContents: string): enrichedOperation[] {
    const spec: OpenAPIV3.Document<{}> = JSON.parse(specContents)

    const generatedSpec = gen_v3(spec, '', {
      apiUrl: 'apiv0',
    })

    return generatedSpec.operations
  }
  async matchSpecSection(
    _operations: enrichedOperation[],
    id: string
  ): Promise<Partial<enrichedOperation> | undefined> {
    const apiEndpoint = await getApiEndpointById(id)
    if (!apiEndpoint) return undefined

    const enrichedOp: Partial<enrichedOperation> = {
      operationId: apiEndpoint.id,
      operation: apiEndpoint.method,
      path: apiEndpoint.path,
      summary: apiEndpoint.summary,
      description: apiEndpoint.description,
      deprecated: apiEndpoint.deprecated,
      parameters: apiEndpoint.parameters as any,
      requestBody: apiEndpoint.requestBody as any,
      responses: apiEndpoint.responses as any,
    }

    return enrichedOp
  }
}

Analyze Your Own Codebase

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

Try Supermodel Free