swagger-php: Warning: Skipping unknown \Controller Warning: Required @OA\PathItem() not found Warning: Required @OA\Info() not found
install :
composer require zircote/swagger-php composer require doctrine/annotations
ENV:
`a@debian:/var/www$ uname -a Linux debian 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64 GNU/Linux
a@debian:/var/www$ php -v PHP 7.4.30 (cli) (built: Jul 7 2022 15:51:43) ( NTS ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies with Zend OPcache v7.4.30, Copyright ©, by Zend Technologies `
swagger-php version (maybe) 4.8.1 ?
a@debian:/var/www$ ./vendor/bin/openapi --version
Error: Specify at least one path.
Usage: openapi [–option value] [/path/to/project …]
Options: –config (-c) Generator config ex: -c operationId.hash=false –legacy (-l) Use legacy TokenAnalyser; default is the new ReflectionAnalyser –output (-o) Path to store the generated documentation. ex: --output openapi.yaml –exclude (-e) Exclude path(s). ex: --exclude vendor,library/Zend –pattern (-n) Pattern of files to scan. ex: --pattern “*.php” or --pattern “/.(phps|php)$/” –bootstrap (-b) Bootstrap php file(s) for defining constants, etc. ex: --bootstrap config/constants.php –processor (-p) Register an additional processor. –format (-f) Force yaml or json. –debug (-d) Show additional error information. –version The OpenAPI version; defaults to 3.0.0. –help (-h) Display this help message.
try :
a@debian:/var/www$ ./vendor/bin/openapi -b ./vendor/autoload.php api Warning: Skipping unknown \Controller Warning: Required @OA\PathItem() not found Warning: Required @OA\Info() not found openapi: 3.0.0
try again:
a@debian:/var/www$ ./vendor/bin/openapi api Warning: Skipping unknown \Controller Warning: Required @OA\PathItem() not found Warning: Required @OA\Info() not found openapi: 3.0.0
demo…:
a@debian:/var/www$ cat api/doc.php
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 1
- Comments: 20
it’s ok now.
after composer require zircote/swagger-php doctrine/annotations, update version. it’s ok now.
composer.json
Add autoload config to
composer.json
composer.jsonYou might be missing this step:
see: https://getcomposer.org/doc/01-basic-usage.md#autoloading
api/OpenApi.php
api/MyController.php
For autoloading each file must contain only a single class/interface/… and the filename must match the classname.
Finally, using ``` to wrap code makes your post a lot more readable… see: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks