Performance optimizations:
- Lazy loading of ruleset: Implement caching layer for Spectral ruleset to avoid reloading on each validation request. Currently the entire ruleset is reloaded per request - consider using an in-memory cache with TTL or file-watch invalidation strategy. This will scale better as the number of custom rules and functions grows.
- Spec caching: Cache validation results for identical OpenAPI specs to avoid redundant Spectral computation. Use MD5 hash of the entire spec as cache key - when users modify the spec, the hash changes and automatically invalidates the previous cache entry, preventing stale results. Provides immediate benefits when validating the same spec multiple times (e.g., during development iterations).
Developer experience:
- Split rule tests: Refactor monolithic rule.test.js into context-specific test files organized by validation domain (e.g., request-body.test.js, examples.test.js, etc.). Current file will become unwieldy as new rules are added - splitting now improves discoverability and reduces merge conflicts.