Swagger UI / Open API

As mentioned on the Basic API, Tina uses Swagger & OpenAPI UI. It is highly recommended to annotate your code for flexibility. As an example, if someone else were to look and your code, would they be able to read it and add/make changes?

A simple way to annotate routers:


<?php
/**
* @description A description for your end point
* @summary group1,group2
* @tags 
*/

//Standard
\Tina4\Get::add("/hello/world", function(\Tina4\Response $response, \Tina4\Request $request){  
    return $response("Hello World", HTTP_OK, TEXT_HTML);
});

//Inline Params
\Tina4\Get::add("/hello/world/{id}", function($id, \Tina4\Response $response, \Tina4\Request $request){
    return $response("Hello World {$id}", HTTP_OK, TEXT_HTML);
});

//Other methods you can test
\Tina4\Post::add(...);

\Tina4\Patch::add(...);

\Tina4\Put::add(...);

\Tina4\Delete::add(...);

//You guessed it - It takes every method - GET, POST, DELETE, PUT, PATCH, OPTIONS
\Tina4\Any::add(...);

Next spin up a Web-Server and go to this address in your browsers URL bar to bring up the Swagger UI:


 http://localhost:7145/swagger  

Powered by ComboStrap