agentleFS
DarkaOnLineDarkaOnLine/L5-Swagger/CLAUDE.md

L5-Swagger

CLAUDE.md2.9k starsChanged 5 months agoMITView on GitHub

L5-Swagger is a Laravel package that integrates swagger-php and swagger-ui into Laravel. It does NOT implement the OpenAPI spec — it wraps swagger-php for annotation scanning and swagger-ui for the documentation frontend. Supports multiple independent documentation sets, each with its own routes, paths, and settings via a two-level config: defaults (shared) merged with documentations.{name} (per-doc overrides). ConfigFactory::mergeConfig() recursively merges associative arrays. GeneratorFactory::make(documentation) → creates Generator with merged config → Generator::generateDocs() chains: Custom processors can be positioned relative to any existing…

We split this CLAUDE.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test fixtures live in tests/storage/annotations/OpenApi/ with sample PHP attribute annotations.

    line 65

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

L5-Swagger is a Laravel package that integrates swagger-php and swagger-ui into Laravel. It does NOT implement the OpenAPI spec — it wraps swagger-php for annotation scanning and swagger-ui for the documentation frontend.

Supports multiple independent documentation sets, each with its own routes, paths, and settings via a two-level config: defaults (shared) merged with documentations.{name} (per-doc overrides). ConfigFactory::mergeConfig() recursively merges associative arrays.

Development Commands

# Run all tests
composer run-script phpunit

# Run a single test file
vendor/bin/phpunit tests/Unit/GeneratorTest.php

# Run a single test method
vendor/bin/phpunit --filter testCanGenerateApiJsonFile

# Static analysis (PHPStan level 8)
composer run-script analyse

Architecture

Generation Pipeline

GeneratorFactory::make(documentation) → creates Generator with merged config → Generator::generateDocs() chains:

  1. prepareDirectory() — ensure output dir exists/writable
  2. defineConstants() — define PHP constants from config (usable in annotations)
  3. scanFilesForDocumentation() — swagger-php scans PHP files using ReflectionAnalyser + AttributeAnnotationFactory
  4. populateServers() — injects base path as a Server URL
  5. saveJson() — writes JSON, then SecurityDefinitions::generate() injects security schemes
  6. makeYamlCopy() — optional YAML conversion via symfony/yaml

Custom processors can be positioned relative to any existing processor via scanOptions.processors using ['class' => ..., 'after' => ...] syntax. A CustomGeneratorInterface implementation can be provided via scanOptions.generator_factory to supply a pre-configured OpenApi\Generator.

Service Container Bindings

L5SwaggerServiceProvider binds Generator::class as a factory — each resolution creates a new Generator via GeneratorFactory::make() using the l5-swagger.default documentation name. The GenerateDocsCommand is registered as a singleton under command.l5-swagger.generate.

Routing

Routes are registered dynamically in src/routes.php by iterating all documentation sets. Each set gets up to 4 routes (api UI, docs JSON/YAML, assets, OAuth2 callback), all wrapped with the Config middleware that sets the active documentation context. Route names follow l5-swagger.{documentation}.{type}.

Helpers

swagger_ui_dist_path() resolves swagger-ui asset paths with an allowlist of permitted files. l5_swagger_asset() generates versioned (cache-busted) URLs for those assets.

Testing

Tests use Orchestra Testbench (Tests\Unit\TestCase extends OrchestraTestCase) for a full Laravel environment.

Key patterns:

  • $this->fileSystem is a PHPUnit mock of Filesystem, injected into Generator via reflection in makeGeneratorWithMockedFileSystem()
  • setAnnotationsPath() reconfigures the app to use tests/storage/annotations/OpenApi/ fixtures and rebuilds the generator
  • setCustomDocsFileName() overrides the output filename for JSON/YAML format tests
  • copyAssets() copies swagger-ui dist into testbench's vendor directory in setUp; tearDown cleans up generated docs
  • PHPUnit attributes: #[TestDox('...')], #[CoversClass(...)]

Test fixtures live in tests/storage/annotations/OpenApi/ with sample PHP attribute annotations.

Code Style

  • StyleCI: preset: laravel — enforced automatically
  • PHPStan: Level 8, analyzes src/ and tests/Unit/, ignores argument.templateType
  • PHP 8.2+ required; uses constructor property promotion, union types, named arguments
  • Supports Laravel 11.44+, 12.1+, and 13.0+

Environment Variables

VariablePurpose
L5_SWAGGER_GENERATE_ALWAYSRegenerate docs on every request (dev mode)
L5_SWAGGER_GENERATE_YAML_COPYAlso create YAML version
L5_SWAGGER_CONST_HOSTDefault host constant for annotations
L5_SWAGGER_OPEN_API_SPEC_VERSION3.0.0 (default) or 3.1.0
L5_SWAGGER_UI_DARK_MODEDark mode for Swagger UI
SWAGGER_VERSIONUsed in tests to set OpenAPI version

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about DarkaOnLine/L5-Swagger

The biggest 5 of 65 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 65

Talked about on GitHub and Stack Overflow (65 times).

On GitHub · 50

45 more on GitHub

On Stack Overflow · 15

10 more on Stack Overflow

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.