PHP code example of genai / openapi

1. Go to this page and download the library: Download genai/openapi 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/ */

    

genai / openapi example snippets


#[RestController(path: '/api', tag: 'KidSafe API', description: 'Public JSON endpoints.')]
class ApiController
{
    #[GetMapping('/games', summary: 'List the published games')]
    public function games() { return $this->games->all(); }       // RestController -> JSON

    #[PostMapping('/feedback', summary: 'Send feedback')]
    public function feedback(FeedbackForm $form) { ... }           // body schema from FeedbackForm
}

  #[PostMapping('/feedback', summary: 'Send feedback', response: FeedbackResult::class, errorCodes: [422, 500])]
  public function feedback(FeedbackForm $form) { ... }