目前对于一个项目,我需要使用 Swagger 为其创建文档。由于项目是用 php 完成的,所以我将使用 Swagger-Php 来注释代码并创建文档。现在我注意到,在所有示例项目中,它们都是面向对象的;换句话说,当发出请求时,会调用控制器,然后调用模型等。在我参与的项目中,项目不是这样组织的:每个页面都有自己的文件, 并负责该文件中的所有操作。我将如何使用 Swagger 以这种方式记录代码?
例如,下面的伪代码本质上就是每个文件的作用:
<?php
//get paramters
//query database
//return json file, either data or status of the operation
?>
我会做这样的事情吗?
<?php
/*
* @SWG\Resource(
* apiVersion="1.0",
* basePath="http://url.com/exampleFile"
* )
* */
/* @SWG\Api(
* @SWG\Operation(
* summary="Retreives data from database and prints out in json",
* method="GET",
* type="", // what would go here?
* @SWG\Parameter(name="param1",type="string"),
* @SWG\Parameter(name="param2",type="int")
* )
* )
* */
//How will I show example of json to be printed to the user?
//get paramters
//query database
//return json file, either data or status of the operation
?>
感谢您的任何帮助。