Help us shape the future of Go! Take the 2026 Go Developer Survey

fastapi

package
v0.0.0-...-762485d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fastapi parses FastAPI decorated route functions using tree-sitter-python. It walks Python source files for @app.get, @app.post, @router.get, etc. decorators and extracts endpoint metadata including path, HTTP method, function parameters, docstrings, and structured request/response type schemas resolved from Pydantic BaseModel definitions and Python type annotations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPydanticModels

func ExtractPydanticModels(rootNode *tree_sitter.Node, source []byte) map[string]PydanticModel

func ExtractPydanticModelsFromFile

func ExtractPydanticModelsFromFile(filePath string) (map[string]PydanticModel, error)

func IsPydanticModelType

func IsPydanticModelType(typeText string) bool

func Parse

func Parse(sourceDir string) ([]collector.ApiEndpoint, error)

func ParsePythonGenericType

func ParsePythonGenericType(typeText string) (string, []string)

func ParseWithUnresolved

func ParseWithUnresolved(sourceDir string, depResolver collector.DependencyResolver, unresolved *collector.UnresolvedSet) ([]collector.ApiEndpoint, error)

ParseWithUnresolved is Parse plus an optional dependency resolver that expands types declared by pip dependencies, and an optional sink that records type names the resolver could not expand. Both may be nil.

Types

type PydanticField

type PydanticField struct {
	Name        string
	Type        string
	Required    bool
	Default     string
	Description string
	Example     string
	// Unannotated marks a field declared with a pydantic descriptor and no
	// type annotation, e.g. `name = Field(description=...)`. The type is
	// genuinely absent, so the resolver reports it instead of letting the
	// field pass for a resolved string.
	Unannotated bool
}

type PydanticModel

type PydanticModel struct {
	Name          string
	Fields        []PydanticField
	EmbeddedTypes []string
}

type PythonTypeResolver

type PythonTypeResolver struct {
	// contains filtered or unexported fields
}

func NewPythonTypeResolver

func NewPythonTypeResolver(models map[string]PydanticModel) *PythonTypeResolver

func (*PythonTypeResolver) Resolve

func (r *PythonTypeResolver) Resolve(typeText string) *model.ObjectModel

func (*PythonTypeResolver) SetDependencyResolver

func (r *PythonTypeResolver) SetDependencyResolver(dr collector.DependencyResolver)

func (*PythonTypeResolver) SetUnresolved

func (r *PythonTypeResolver) SetUnresolved(u *collector.UnresolvedSet)

SetUnresolved attaches a shared sink that records type names this resolver could not expand. It is optional; without it Resolve behaves as before.

func (*PythonTypeResolver) Unresolved

func (r *PythonTypeResolver) Unresolved() map[string]int

Unresolved returns the type names this resolver failed to resolve, mapped to their occurrence counts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL