I am trying to use Swagger-PHP for generating JSON files , so that I can use it with Swagger-UI for auto documentation.
I tried the link :- https://github.com/zircote/swagger-php
Also I tried to work around with there documentation at http://zircote.com/swagger-php/installation.html
But my hard luck , I am unable to implement it.
I am able to install composer correctly. Also the bundle of Swagger-PHP is installed correctly.
But the problem is that I am unable to use/understand the test examples provided by them.
So if anyone has worked it around please help !!
Thanks in advance !!
I've struggled on this one lately and see some differences and managed to get it working and wanted to perhaps shortcut someone else:
I had previous gotten this working with enum in the model and a @SWG\Items reference to it, but didn't save that code (I was just messing around), and I can't get it back. I even see I previously upvoted the question and accepted answer! But the above is the only way I can get it to work right now and is better than nothing.
You just put comments aka annotations in your code, model example:
Controller example:
Then in console:
Then link generated files in Swagger UI. Is this help?
BTW, this documentation: http://zircote.com/swagger-php/annotations.html is incomplete. It's better to rely on parser errors, example:
EDIT: Swagger 2.0 has pretty good specification on GitHub
BTW, consider to use Swagger Editor to create api specification file (json/yaml) to use in Swagger UI. Cause inline SWG documentation in php files is just ugly and you don't have autocomplete support in IDE.