당신은 당신의 코드에서 모델 예를 주석 일명 의견을 넣어 :
/**
* @SWG\Model(
* id="vps",
* required="['type', 'hostname']",
* @SWG\Property(name="hostname", type="string"),
* @SWG\Property(name="label", type="string"),
* @SWG\Property(name="type", type="string", enum="['vps', 'dedicated']")
*)
*/
class HostVps extends Host implements ResourceInterface
{
// ...
}
컨트롤러 예 :
콘솔에서 다음
/**
* @SWG\Resource(
* basePath="http://skyapi.dev",
* resourcePath="/vps",
* @SWG\Api(
* path="/vps",
* @SWG\Operation(
* method="GET",
* type="array",
* summary="Fetch vps lists",
* nickname="vps/index",
* @SWG\Parameter(
* name="expand",
* description="Models to expand",
* paramType="query",
* type="string",
* defaultValue="vps,os_template"
* )
* )
* )
*)
*/
class VpsController extends Controller
{
// ...
}
: 다음 링크에서 파일을 생성
php swagger.phar ./your-code-source/ -o ./directory-for-output-files
Swagger UI. 이 정보가 도움이 되었습니까?
실제로,이 설명서는 http://zircote.com/swagger-php/annotations.html이 불완전합니다.
php swagger.phar ./skynode-api/api/ -o ./foo
Swagger-PHP 0.9.0
-----------------
[INFO] Skipping unsupported property: "foo" for @Swagger\Annotations\Property, expecting "name", "description", "type", "format", "items", "uniqueItems", "required", "minimum", "maximum", "enum", "defaultValue", "_partialId", "_partials" in HostVps in /home/kane/some-dir/some-file.php on line 3
편집 : 그것은 파서 오류에 의존하는 예를 더 나은 자신감 2.0 꽤 좋은 사양을 가지고 on GitHub
BTW, 사용하는 API 사양 파일 (JSON/YAML)을 만들 Swagger Editor를 사용하는 것을 고려 Swagger UI에서. PHP 파일에서 인라인 SWG 문서가 잘못 되었기 때문에 IDE에서 자동 완성 기능을 지원하지 않습니다.
안녕하세요, 자세한 내용을 알려주세요. 당신이 겪고있는 오류와 마찬가지. 도움이 될 것입니다. –