Documentation
¶
Overview ¶
Package cache provides incremental build caching for OpenAPI spec generation. It stores parsed results in .openapi/ directory to speed up subsequent builds.
Index ¶
- Constants
- func CalculateChecksum(filePath string) (string, error)
- func CalculateContentChecksum(content []byte) string
- type CacheStats
- type FileEntry
- type Index
- func (idx *Index) GetEntry(relPath string) (*FileEntry, bool)
- func (idx *Index) Load(path string) error
- func (idx *Index) NeedsUpdate(relPath, checksum string) bool
- func (idx *Index) RemoveEntry(relPath string)
- func (idx *Index) Save(path string) error
- func (idx *Index) SetEntry(relPath string, entry *FileEntry)
- type Manager
- func (m *Manager) CachePath() string
- func (m *Manager) Clean() error
- func (m *Manager) DeleteRoute(operationID string) error
- func (m *Manager) DeleteSchema(name string) error
- func (m *Manager) GetEntry(filePath string) (*FileEntry, bool)
- func (m *Manager) IndexPath() string
- func (m *Manager) Init() error
- func (m *Manager) Load() error
- func (m *Manager) LoadAllRoutes() (map[string]*spec.Operation, error)
- func (m *Manager) LoadAllSchemas() (map[string]*spec.Schema, error)
- func (m *Manager) LoadRoute(operationID string) (*spec.Operation, error)
- func (m *Manager) LoadSchema(name string) (*spec.Schema, error)
- func (m *Manager) NeedsUpdate(filePath string) (bool, error)
- func (m *Manager) Save() error
- func (m *Manager) SaveRoute(operationID string, operation *spec.Operation) error
- func (m *Manager) SaveSchema(name string, schema *spec.Schema) error
- func (m *Manager) Stats() CacheStats
- func (m *Manager) UpdateEntry(filePath string, schemas, routes, parameters []string) error
Constants ¶
const ( // CacheDir is the directory where cache files are stored CacheDir = ".openapi" // IndexFile is the cache index file name IndexFile = "index.json" // SchemasDir stores cached schema definitions SchemasDir = "schemas" // RoutesDir stores cached route definitions RoutesDir = "routes" )
Variables ¶
This section is empty.
Functions ¶
func CalculateChecksum ¶
CalculateChecksum calculates SHA256 checksum of a file.
func CalculateContentChecksum ¶
CalculateContentChecksum calculates SHA256 checksum of content bytes.
Types ¶
type CacheStats ¶
CacheStats holds statistics about the cache.
type FileEntry ¶
type FileEntry struct {
// Checksum is the SHA256 hash of the source file
Checksum string `json:"checksum"`
// ParsedAt is when the file was last parsed
ParsedAt time.Time `json:"parsedAt"`
// Schemas exported by this file (schema names)
Schemas []string `json:"schemas,omitempty"`
// Routes exported by this file (operation IDs)
Routes []string `json:"routes,omitempty"`
// Parameters exported by this file
Parameters []string `json:"parameters,omitempty"`
}
FileEntry represents a cached entry for a single source file.
type Index ¶
type Index struct {
// Version of the cache format
Version string `json:"version"`
// CreatedAt is when the cache was first created
CreatedAt time.Time `json:"createdAt"`
// UpdatedAt is when the cache was last updated
UpdatedAt time.Time `json:"updatedAt"`
// Files maps source file paths to their cache entries
Files map[string]*FileEntry `json:"files"`
}
Index represents the cache index that tracks all cached files.
func (*Index) NeedsUpdate ¶
NeedsUpdate checks if a source file needs to be re-parsed.
func (*Index) RemoveEntry ¶
RemoveEntry removes a cache entry.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles all cache operations.
func NewManager ¶
NewManager creates a new cache manager for the given base directory.
func (*Manager) DeleteRoute ¶
DeleteRoute removes a route from cache.
func (*Manager) DeleteSchema ¶
DeleteSchema removes a schema from cache.
func (*Manager) LoadAllRoutes ¶
LoadAllRoutes loads all cached routes.
func (*Manager) LoadAllSchemas ¶
LoadAllSchemas loads all cached schemas.
func (*Manager) LoadSchema ¶
LoadSchema loads a schema from the cache.
func (*Manager) NeedsUpdate ¶
NeedsUpdate checks if a source file needs to be re-parsed.
func (*Manager) SaveSchema ¶
SaveSchema saves a schema to the cache. The schema is stored as JSON with unresolved $refs.
func (*Manager) Stats ¶
func (m *Manager) Stats() CacheStats
Stats returns statistics about the current cache state.