I am new to this stuff but I love it. I made a little REST Api using the Slim Framework. Now I would like to have an ongoing documentation about it. I think swagger is the right choice but I have not found out yet how to integrate it ?
Cheers & thanks for your patience :)
Head over to Swagger Inspector, and insert the end point of the resource you want to have documented. You can then navigate to the right panel from the History section of Swagger Inspector, and click "Create API definition" to create the OAS definition.
Note that Swagger not only helps us to design and document REST APIs, it also lets us build (Server Stub) and Consume (Rest Clients) REST APIs. The major Swagger tools include: Swagger Editor — browser-based editor where one can write OpenAPI specification.
Swagger™ is a project used to describe and document RESTful APIs. The Swagger specification defines a set of files required to describe such an API.
I think you are looking for this project: zircote/swagger-php
Here you'll find how to generate the doc on user request to a URL.
Basically you have to annotate your code with the Swagger Annotations, then create another route in Slim with a code similar to this:
<?php use Swagger\Swagger; $swagger = new Swagger('/project/root/top_level'); header("Content-Type: application/json") echo $swagger->getResource('/pet', array('output' => 'json'));
And it will generate the Swagger API docs on the fly for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With