swagger-php says the OpenAPI Info is missing
Required @OA\Info() not foundShort answer
swagger-php reads annotations or attributes only through PHP reflection. The Info block is global, so it is easily placed where nothing reads it. Put it on a dedicated class, install doctrine/annotations if you use docblocks, and make sure the scan path you pass to the generator includes that file.
Fix it fast
1Find out which cause you have
Run the generator on the folder that holds your annotated classes and read the first message. This also shows which scan path you are really using.
./vendor/bin/openapi app -o openapi.yaml2Match what you see, then jump to its fix
- 1
Annotations on your controllers work, but Info is reported missingThe Info annotation sits where reflection never looksFix - 2
No annotations are found at all, and the same Info message appearsYou use docblock annotations but doctrine/annotations is not installedFix - 3
The Info class exists, but the generator never loads itThe scan path does not include the file with the InfoFix
- 1
What does the error look like?
Required @OA\Info() not foundDocument is missing info
Cause 1 of 3
The Info annotation sits where reflection never looks
1Check
swagger-php finds annotations on a class, interface, trait, method, property or class constant. A docblock on its own, or one in a plain file, is ignored. OA\Info belongs to the whole document, so it has no natural home.
grep -rn "OA\\\\Info" app/2Fix
Create a dummy class and put the global annotations on it.
<?php
use OpenApi\Attributes as OA;
#[OA\Info(title: 'My API', version: '1.0.0')]
class OpenApiSpec
{
}3Verify
Run the generator again; the Info message is gone.
./vendor/bin/openapi app -o openapi.yamlConfirmed by zircote.com
Cause 2 of 3
You use docblock annotations but doctrine/annotations is not installed
1Check
The FAQ says docblock annotations need doctrine/annotations, and that swagger-php does not install it for you. Without it, annotations are not read.
composer show doctrine/annotations2Fix
Install the package, or move to PHP attributes, which need no extra package.
composer require doctrine/annotations3Verify
Generate the document again.
./vendor/bin/openapi app -o openapi.yamlConfirmed by zircote.com
Cause 3 of 3
The scan path does not include the file with the Info
1Check
The generator scans only the source paths you give it. If the dummy class lives in another folder, it is not read.
./vendor/bin/openapi --help2Fix
Pass every folder involved, or move the Info class under the scanned folder. Several paths are allowed.
./vendor/bin/openapi app src -o openapi.yaml3Verify
Open the output file and look for the info section.
head -n 8 openapi.yamlConfirmed by zircote.com
How do I stop it coming back?
- Keep one OpenApiSpec class for Info, Server and Tag, in a folder that is always scanned.
- Prefer PHP attributes over docblocks so no extra package is needed.
- Run the generator in CI so a missing Info fails the build.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix