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
- Very specific: line 65
Test fixtures live in tests/storage/annotations/OpenApi/ with sample PHP attribute annotations.
≈ “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.
Files
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 analyseArchitecture
Generation Pipeline
GeneratorFactory::make(documentation) → creates Generator with merged config → Generator::generateDocs() chains:
prepareDirectory()— ensure output dir exists/writabledefineConstants()— define PHP constants from config (usable in annotations)scanFilesForDocumentation()— swagger-php scans PHP files usingReflectionAnalyser+AttributeAnnotationFactorypopulateServers()— injects base path as a Server URLsaveJson()— writes JSON, thenSecurityDefinitions::generate()injects security schemesmakeYamlCopy()— optional YAML conversion viasymfony/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->fileSystemis a PHPUnit mock ofFilesystem, injected intoGeneratorvia reflection inmakeGeneratorWithMockedFileSystem()setAnnotationsPath()reconfigures the app to usetests/storage/annotations/OpenApi/fixtures and rebuilds the generatorsetCustomDocsFileName()overrides the output filename for JSON/YAML format testscopyAssets()copies swagger-ui dist into testbench's vendor directory in setUp;tearDowncleans 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/andtests/Unit/, ignoresargument.templateType - PHP 8.2+ required; uses constructor property promotion, union types, named arguments
- Supports Laravel 11.44+, 12.1+, and 13.0+
Environment Variables
| Variable | Purpose |
L5_SWAGGER_GENERATE_ALWAYS | Regenerate docs on every request (dev mode) |
L5_SWAGGER_GENERATE_YAML_COPY | Also create YAML version |
L5_SWAGGER_CONST_HOST | Default host constant for annotations |
L5_SWAGGER_OPEN_API_SPEC_VERSION | 3.0.0 (default) or 3.1.0 |
L5_SWAGGER_UI_DARK_MODE | Dark mode for Swagger UI |
SWAGGER_VERSION | Used in tests to set OpenAPI version |
Trending
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about DarkaOnLine/L5-Swagger
- Stack Overflow“Swagger - "Required @OA\Info() not found"”Stack Overflow · Nov 21, 2022 · 13 votes
- InfyOmLabs/laravel-generator“Swagger package is archived ”GitHub · Mar 20, 2020 · 5 reactions
- Stack Overflow“Required @OA\Info() not found exception in is not working in laravel 8.x”Stack Overflow · Mar 14, 2022 · 3 votes
- swagger-api/swagger-ui“How to add textarea in swagger ? ”GitHub · Apr 5, 2023 · 2 reactions
- Stack Overflow“Laravel eloquent models with swagger openApi annotations problem”Stack Overflow · Dec 8, 2022 · 2 votes
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
- Mar 20, 2020Swagger package is archived — InfyOmLabs/laravel-generator5 reactions · 9 comments
- Apr 5, 2023How to add textarea in swagger ? — swagger-api/swagger-ui2 reactions · 5 comments
- Jan 28, 2021Many issues with the generator — InfyOmLabs/laravel-generator2 reactions · 10 comments
- Nov 24, 2025[優先度:低] OpenAPI(Swagger)ドキュメントの導入 — 128na/simutrans-portal1 reaction
- Oct 29, 2026chore(deps): bump darkaonline/l5-swagger from 11.2.0 to 11.2.1 — aboelresh/riwaq0 reactions · 1 comment
45 more on GitHub
- Oct 27, 2026Bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 — salman-mustafa1230/key-value-store0 reactions
- Oct 26, 2026Bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 — marcth2/sprig-api-platform0 reactions
- Oct 26, 2026build(deps): bump darkaonline/l5-swagger from 11.2.0 to 11.2.1 — N3XT0R/dashclip-delivery0 reactions · 1 comment
- Oct 26, 2026build(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 — NyaPuma/SIGMA0 reactions · 1 comment
- Oct 26, 2026chore(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 — lunasans/MovieShelf0 reactions
- Oct 26, 2026build(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 — prep-your-meal/backend0 reactions
- Oct 25, 2026build(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.1 in /apps/identity-server — talredservices/identity0 reactions
- Oct 23, 2026Bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 — ThreeLeaf-com/ValidationEngine0 reactions · 1 comment
- Oct 20, 2026Bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 — salman-mustafa1230/key-value-store0 reactions · 1 comment
- Oct 19, 2026build(deps): bump the php-minor-and-patch group with 4 updates — VendoraPH/lendyph-backend0 reactions
- Oct 19, 2026Bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 — marcth2/sprig-api-platform0 reactions · 1 comment
- Oct 19, 2026chore(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 — lunasans/MovieShelf0 reactions · 1 comment
- Oct 19, 2026Bump the composer-minor-and-patch group across 1 directory with 9 updates — soerennb/version-tracker0 reactions
- Oct 19, 2026build(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 — prep-your-meal/backend0 reactions · 1 comment
- Oct 18, 2026build(deps): bump darkaonline/l5-swagger from 11.1.0 to 11.2.0 in /apps/identity-server — talredservices/identity0 reactions · 1 comment
- Oct 17, 2026chore(deps): bump darkaonline/l5-swagger from 10.1.0 to 11.2.0 — dacrab/beauty-salon-scheduling-api0 reactions · 4 comments
- Oct 17, 2026chore(deps): bump the composer group across 1 directory with 2 updates — 128na/simutrans-portal0 reactions · 1 comment
- Oct 16, 2026chore(deps): bump the composer group across 1 directory with 3 updates — 128na/simutrans-portal0 reactions · 1 comment
- Oct 12, 2026chore(deps): update dependency darkaonline/l5-swagger to v11 — RasimAghayev/blockchain-monitoring-api0 reactions · 2 comments
- Oct 8, 2026chore(deps): bump darkaonline/l5-swagger from 10.1.0 to 11.1.0 — dacrab/beauty-salon-scheduling-api0 reactions · 4 comments
- Oct 5, 2026chore(deps): Bump the minor-and-patch group across 1 directory with 32 updates — vtomasi/core-banking-prototype-laravel0 reactions · 1 comment
- Aug 3, 2026build(deps): Bump the backend-deps group across 1 directory with 13 updates — kimerran/fishbook0 reactions
- Jul 30, 2026Bump darkaonline/l5-swagger from 10.1.0 to 11.1.0 — solyto/api0 reactions
- Jun 18, 2026chore(deps): bump darkaonline/l5-swagger from 9.0.1 to 11.1.0 in /Template — edouard-mangel/laravel-template0 reactions
- Jun 15, 2026chore(deps): bump darkaonline/l5-swagger from 11.0.1 to 11.1.0 — lunasans/MovieShelf0 reactions · 2 comments
- Jun 15, 2026chore(deps): update darkaonline/l5-swagger requirement from ^10.1 to ^11.1 — couchbase-examples/php-laravel-quickstart0 reactions · 2 comments
- Jun 15, 2026chore(deps): bump darkaonline/l5-swagger from 9.0.1 to 11.1.0 in /backend — will383842/axion-crm-pro0 reactions · 1 comment
- Jun 8, 2026Update darkaonline/l5-swagger requirement from ^8.6 to ^11.0 in /services/23-laravel — yarova-ca/pipeline-studio0 reactions · 1 comment
- May 26, 2026chore(api)(deps): bump darkaonline/l5-swagger from 9.0.1 to 11.0.1 in /Qwizzy_API — L1nkiZ/Qwizzy0 reactions · 2 comments
- May 1, 2026build(deps): Bump darkaonline/l5-swagger from 10.1.0 to 11.0.1 in /signrhflow-api — MatheusWastchukk/SignRhFlow0 reactions
- Apr 10, 2026chore(deps): bump darkaonline/l5-swagger from 10.1.0 to 11.0.1 — NeftaliYagua/reservas0 reactions · 1 comment
- Mar 31, 2026Update dependency darkaonline/l5-swagger to v11 - autoclosed — RasimAghayev/blockchain-monitoring-api0 reactions · 1 comment
- Mar 23, 2026Bump the production-dependencies group across 1 directory with 4 updates — cult1St/podcats_test0 reactions
- Mar 18, 2026Update dependency darkaonline/l5-swagger to v11 — rxcod9/joy-voyager-api0 reactions
- Mar 18, 2026Update dependency darkaonline/l5-swagger to v11 — rxcod9/joy-nova-api0 reactions
- Jan 19, 2026php: bump darkaonline/l5-swagger from 9.0.1 to 10.1.0 in /zoo-php-laravel — intelligent002/micro-service-zoo0 reactions · 1 comment
- Sep 17, 2025TASK: Documentation API OpenAPI pour les endpoints d'authentification — Ousmanou-Nana/test0 reactions
- Sep 17, 2025TASK: Documentation API avec OpenAPI/Swagger — Ousmanou-Nana/test0 reactions
- Sep 17, 2025TASK: Documentation API avec OpenAPI/Swagger — Ousmanou-Nana/test0 reactions
- Aug 28, 2025Bump darkaonline/l5-swagger from 8.6.3 to 9.0.1 — abdorrahmani/anophel-api0 reactions
- Jul 19, 2025Add API documentation — aung-zan/Verifi-T0 reactions · 1 comment
- Jun 5, 2025Update darkaonline/l5-swagger requirement from ^8.5 to ^8.5 || ^9.0 — hatmeoNew/Apis0 reactions
- May 19, 2025Update dependency darkaonline/l5-swagger to v9 - abandoned — TanNhatCMS/laravel-quan-ly-diem-ren-luyen0 reactions · 3 comments
- Apr 20, 2025Add Swagger for API documentation — EdsonJunior29/inventory-control-backend0 reactions · 1 comment
- Mar 1, 2025Update darkaonline/l5-swagger requirement from ^8.6 to ^9.0 — TanNhatCMS/laravel-quan-ly-diem-ren-luyen0 reactions · 1 comment
On Stack Overflow · 15
- Nov 21, 2022Swagger - "Required @OA\Info() not found"13 votes
- Mar 14, 2022Required @OA\Info() not found exception in is not working in laravel 8.x3 votes · 2 answers
- Dec 8, 2022Laravel eloquent models with swagger openApi annotations problem2 votes
- May 6, 2021Origin header is not working in L5 Swagger - Laravel2 votes
- Dec 17, 2019DarkaOnline Swagger-php generates incorrect interface2 votes · 2 answers
10 more on Stack Overflow
- Nov 5, 2019Laravel Swagger best practice1 vote
- Feb 21, 2018Connect swagger to Laravel passport1 vote
- Apr 5, 2023Reset L5-swagger API Documentation in Laravel0 votes
- Jun 30, 2022Add Description to Route in Laravel0 votes
- Mar 12, 2022"Swagger: skipping unknown type" messages when using Composer REST Server0 votes
- Feb 15, 2020Why error installing L5-Swagger in laravel 6 app?0 votes · 1 answer
- Oct 18, 2019How to Install Swagger-UI to Laravel 6 API for doumentation?0 votes · 1 answer
- Oct 4, 2019Google Endpoints with Laravel API project0 votes
- Feb 21, 2018Swagger.php : how to change POST request header Content-type0 votes
- Jan 6, 2021Avoid writing swagger annotation in controller-1 votes
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
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.

