This small application allows you to connect to your another existing application in which you use OpenApi 3.0 markup and generate Swagger documentation on the fly.
Yii2 is used as a microframework.
genxoft/yii2-oas3 package is used as a yii2-wrapper for php-swagger.
git clone https://github.com/pantera-digital/yii2-swagger-your-app.git
composer install
In config.php
your should specify paths to parse your code:
'params' => [
'apiPathsToParse' => [
// 'C:/xampp/htdocs/your-project/controllers',
// 'C:/xampp/htdocs/your-project/models',
// or
// '/var/www/your-project/controllers',
// '/var/www/your-project/models',
// etc.
]
]
If you use swagger on a domain other than your API, you must allow access based on Cross-origin resource sharing (CORS):
Access-Control-Allow-Origin: "*"
Access-Control-Expose-Headers: ""
Navigate your browser to path like http://localhost/yii2-swagger-your-app/web
You will see similar: