Я использую Symfony Flex и Composer с Symfony 4 и установленным серверным компонентом API Platform в моем приложении.
Как добавить конечную точку в Swagger (OpenAPI) для настраиваемого контроллера?
<?php
/**
* Application features
*/
namespace App\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
/**
* Checks if the service is alive.
*
* @package Behat\Behat\Context\Context
*/
class HealthcheckController
{
/**
* @Route(
* name="api_healthcheck_entrypoint",
* path="/api/ping",
* methods={"GET"},
* )
*/
public function __invoke()
{
return new JsonResponse(array('ping' => 'pong'));
}
}
docker-compose exec php bin / console api: swagger: export
{
"swagger": "2.0",
"basePath": "\/",
"info": {
"title": "FastTony.es",
"version": "0.0.1"
},
"paths": {},
"securityDefinitions": {
"apiKey": {
"type": "apiKey",
"in": "header",
"description": "Value for the Authorization header",
"name": "Authorization"
}
},
"security": [
{
"apiKey": []
}
]
}