[英]How to use nelmio/api-doc-bundle without symfony?
My web application is not based on Symfony or any other open-source framework. 我的Web应用程序不基于Symfony或任何其他开源框架。
How can I still use the package nelmio/api-doc-bundle to generate my API documentation from class annotations? 我如何仍然使用nelmio / api-doc-bundle包从类注释生成API文档?
nelmio-api-doc bundle is made symfony platform only so you can not use it without symfony. nelmio-api-doc捆绑包仅由symfony平台制成,因此如果没有symfony,您将无法使用它。
if you want to use only API documentation then https://swagger.io/swagger-ui/ may help you. 如果您只想使用API文档,那么https://swagger.io/swagger-ui/可能会对您有所帮助。 swagger provides ymal and json (annotations is also part of symfony) based documentation and its implement most of popular work platform. swagger提供了基于ymal和json(注释也是symfony的一部分)的文档,并实现了大多数流行的工作平台。
actually nelmio-api-doc bundle is using swagger-ui as API documentation provider (in config setting https://github.com/nelmio/NelmioApiDocBundle ) 实际上nelmio-api-doc捆绑包使用swagger-ui作为API文档提供程序(在配置设置https://github.com/nelmio/NelmioApiDocBundle中 )
You can certainly require in the lib but since it's a Symfony bundle it will come with a lot of unnecessary bloat. 您当然可以在lib中要求,但是由于它是一个Symfony捆绑包,因此会带来很多不必要的膨胀。
Why not try PHP Swagger? 为什么不尝试PHP Swagger? https://github.com/zircote/swagger-php https://github.com/zircote/swagger-php
Here's the type of thing you can do with it: 这是您可以执行的操作类型:
/**
*
* @OA\Get(
* path="/oauth2/authorize",
* @OA\Response(response="200", description="An access token"),
* tags={"auth"},
* @OA\Parameter(
* name="response_type",
* in="query",
* type="string",
* description="the type of response",
* required=true,
* default="code"
* ),
* @OA\Parameter(
* name="client_id",
* in="query",
* type="string",
* description="the client identifier",
* required=true,
* default="testclient"
* ),
* @OA\Parameter(
* name="client_secret",
* in="query",
* type="string",
* description="the client identifier",
* required=false,
* default="testclient"
* ),
* @OA\Parameter(
* name="redirect_uri",
* in="query",
* type="string",
* description="where to send the response",
* required=false
* ),
* @OA\Parameter(
* name="state",
* in="query",
* type="string",
* description="with a CSRF token. This parameter is optional but highly recommended.",
* required=false,
* ),
* @OA\Parameter(
* name="scope",
* in="query",
* type="string",
* description="allowed scopes, space separated",
* required=false,
* )
* )
*/
public function authorizeAction()
{
// code
}
Here's a demo of what Swagger UI generates: https://petstore.swagger.io/ 这是Swagger UI生成的演示: https : //petstore.swagger.io/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.