Forum Discussion

chrisajokinen's avatar
2 months ago

swagger.json is not populating

I am hitting a wall getting swagger to generate the swagger.json with a basic contoller and index.php file

api/generate_swagger.php
api/public/index.php // main entry
api/public/swagger/swagger.json
api/public/swagger/index.html

the generate_swagger.php returns

Including file: /var/www/techryche/api/src/classes/Dtos/ComponentContactDto.php
Including file: /var/www/techryche/api/src/classes/Dtos/TaskTypeDto.php
PHP Warning:  Required @OA\PathItem() not found in /var/www/techryche/api/vendor/zircote/swagger-php/src/Loggers/DefaultLogger.php on line 31
PHP Warning:  Required @OA\Info() not found in /var/www/techryche/api/vendor/zircote/swagger-php/src/Loggers/DefaultLogger.php on line 31
swagger.json generated successfully at /var/www/techryche/api/public/swagger/swagger.json

I can delete the swagger.json file and it is recreated with

{
    "openapi": "3.0.0"
}

and my index.php includes

<?php
/**
 * @OA\Info(
 *     title="TechRyche API",
 *     version="1.0.0",
 *     description="API for TechRyche"
 * )
 */

require __DIR__ . '/../vendor/autoload.php';

use Techryche\Api\Container\ApiContainer;
use Slim\Factory\AppFactory;
use Techryche\Api\Utility\RouteFactory;


$config = require __DIR__ . '/../config/config.php';
$container = new ApiContainer($config);

AppFactory::setContainer($container);
$app = AppFactory::create();

$app->addBodyParsingMiddleware();
require __DIR__ . '/../config/middleware.php';

$routes = require __DIR__ . '/../config/routes.php';

(new RouteFactory())->mapRoutes($app, $container, $routes);

$app->run();

what is blocking me?

No RepliesBe the first to reply