<?php
/**
* @SWG\Resource(
* basePath="http://dizplayzone.com/api",
* resourcePath="/account",
* description="Read information on a company dashboard",
* swaggerVersion="1.2",
* apiVersion="1.1",
* )
*/
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
$account = $app['controllers_factory'];
/**
* /account/{id}
* ------------------------------------------------------------------------
*
* @SWG\Api(
* path="/account/{id}",
* @SWG\Operation(
* method="GET",
* summary="Returns info from a company dashboard",
* notes="Returns info from a company dashboard",
* type="account",
* nickname="view_account",
* @SWG\Parameter(
* name="id",
* description="Company ID",
* required=true,
* type="integer",
* paramType="path"
* ),
* @SWG\ResponseMessage(code=404, message="Bad, really bad name.")
* ),
* )
*
*
* @trans foo,bar
*
*/
$account->get('/account/{id}', function ($id) use ($app) {
...
return "Welcome {$user['username']}!";
});
/**
* /account/{id}
* ------------------------------------------------------------------------
*
* @SWG\Api(
* path="/account/{id}",
* @SWG\Operation(
* method="POST",
* summary="Add info to a company dashboard",
* notes="Add info to a company dashboard",
* type="account",
* nickname="post_to_account",
* @SWG\Parameter(
* name="id",
* description="Company ID",
* required=true,
* type="integer",
* paramType="path"
* ),
* @SWG\ResponseMessage(code=404, message="Bad, really bad name.")
* )
* )
*
*
*/
$account->post('/account/{id}', function ($id) use ($app) {
....
});
return $account;
However, swagger-php returns this JSON response:
{
"basePath":"http://dizplayzone.com/api",
"swaggerVersion":"1.2",
"apiVersion":"1.1",
"resourcePath":"/account",
"apis":[
{
"path":"/account/{id}",
"operations":[
{
"method":"POST",
"summary":"Add info to a company dashboard",
"nickname":"post_to_account",
"type":"account",
"parameters":[
{
"paramType":"path",
"name":"id",
"type":"integer",
"required":true,
"description":"Company ID"
}
],
"responseMessages":[
{
"code":404,
"message":"Bad, really bad name."
}
],
"notes":"Add info to a company dashboard"
}
]
}
]
}
Note that it ignores the GET method HTTP operation ?? I think this exact syntax for the annotations worked fine a couple of hours ago, but I must have changed something because now it no longer works.... Any ideas ?