Skip to content

Make build-time warming of the OpenAPI documents opt-in - #58

Merged
stixx merged 4 commits into
mainfrom
feat/optional-warm-up
Oct 3, 2026
Merged

stixx merged 4 commits into
mainfrom
feat/optional-warm-up

Conversation

@stixx

@stixx stixx commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Since 0.14.1, cache:warmup and cache:clear generate each Nelmio area's OpenAPI document and the route-to-area map through two optional cache warmers. Generating a document describes every route and model in the area, which in a large application takes seconds and over 100 MB per area, inside a command that already carries the container build and Symfony's own warmers. It also resolves %env()% values at build time.

Both caches already fill themselves on first use, so the warmers only move that cost from the first request to build time. That is now a choice per project:

stixx_openapi_command:
    openapi:
        warm_up: false # default
  • Default (false): the warmers are not registered. The first API request that needs an area's document or the area map generates and caches it, using the runtime env values.
  • true: both are tagged kernel.cache_warmer and warmed as in 0.14.1 and 0.14.2, including the warm-up warning and the fallback to the warmed document.
  • Area map on a read-only build dir: like the document, the map is now cached in kernel.cache_dir when the build dir can't be written. Without warm-up it would otherwise be rebuilt, loading Nelmio's route collections, in every request. The map is built once and then written to the first writable directory.
  • Cache-dir copies are scoped to the container build (container.build_id, as Symfony's system cache pool is). The cache dir can outlive a deploy, and outside debug mode a cached file counts as fresh as long as it exists, so a later deploy would otherwise reuse the previous deploy's area map or document.

This changes the default; see Upgrading in the changelog: set openapi.warm_up: true to keep warming.

Tests

  • Config and extension: warm_up defaults to false; by default neither service is a cache warmer, with warm_up: true both are.
  • Functional:
    • by default, warming with optional warmers enabled writes nothing to the build or cache dir;
    • with warm_up: true, warming writes every area's document and the area map;
    • the existing warm-cache tests (no route loads on a warm cache, runtime env values) run with warm_up: true.
  • Unit:
    • the area map is cached in the cache dir when the build dir is read-only, and a later instance reads it without loading routes;
    • neither the area map nor the document reuses a cache-dir copy from another build;
    • the area map is written only to the build dir when it's writable, and warm-up of both the map and the document writes only to the build dir it's given.
  • The tests for the new default, the option, the read-only fallback and the build scoping fail on the previous code; the write-target tests guard against mutations that send the map to the cache dir. 309 tests pass; cs-fixer and phpstan (max) are clean; the changelog check passes.

Generate them on the first API request by default, and cache the area map in the cache dir when the build dir is read-only.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: stixx/openapi-command-bundle/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 093efae2-7d43-4f40-8b80-7a0d1459fb9b
📥 Commits

Reviewing files that changed from the base of the PR and between 2c2b75c and 15662d2.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • README.md
  • config/routing.php
  • config/validators.php
  • docs/validation.md
  • src/DependencyInjection/Configuration.php
  • src/DependencyInjection/StixxOpenApiCommandExtension.php
  • src/Routing/NelmioAreaRouteMap.php
  • src/Validator/OpenApiSpecCache.php
  • tests/Functional/ApiRequestTest.php
  • tests/Functional/AreaLookupTest.php
  • tests/Functional/Resources/config/warm_up.php
  • tests/Functional/RuntimeEnvironmentTest.php
  • tests/Unit/DependencyInjection/ConfigurationTest.php
  • tests/Unit/DependencyInjection/StixxOpenApiCommandExtensionTest.php
  • tests/Unit/Routing/NelmioAreaRouteMapTest.php
  • tests/Unit/Validator/OpenApiSpecCacheTest.php
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@stixx
stixx merged commit 42e073c into main Oct 3, 2026
10 checks passed
@stixx
stixx deleted the feat/optional-warm-up branch October 3, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant