PHP code example of savionicodemos / laravel-auto-swagger
1. Go to this page and download the library: Download savionicodemos/laravel-auto-swagger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
savionicodemos / laravel-auto-swagger example snippets
/**
* @Request({
* "summary": "Title of the route",
* "description": "This is a longer description for the route which will be visible once the panel is expanded",
* "tags": ["Authentication","Users"]
* })
*/
/**
* You can also do this — the first line will be used as "summary"
*
* Anything after the first blank line counts as "description".
*
* @Request({
* "summary": "Title of the route", // <- Overwrites the summary above if provided
* "description": "A short description", // <- Overwrites description above if provided
* "tags": ["Authentication","Users"], // <- Associates this operation with these tag sections
* "pathParams": [{ // <- Overwrites auto-generated path parameter definitions
* "name": "user_id",
* "type": "string",
* "description": "User ID to fetch",
* }]
* })
*/
public function someMethod(Request $request, string $reference) {}
// app/Swagger/Schemas/Address.php
namespace App\Swagger\Schemas;
class Address
{
public string $street;
public string $city;
public ?string $state;
public string $zip_code;
public string $country;
}
class FlightSchedule
{
public \DateTime $scheduled_at; // → type: string, format: date-time
public \DateTimeImmutable $completed_at; // → type: string, format: date-time
public ?\DateTimeInterface $cancelled_at; // → type: string, format: date-time, nullable: true
public ?string $note; // → type: string, nullable: true
}