apidoc.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?php
  2. return [
  3. /*
  4. * The type of documentation output to generate.
  5. * - "static" will generate a static HTMl page in the /public/docs folder,
  6. * - "laravel" will generate the documentation as a Blade view,
  7. * so you can add routing and authentication.
  8. */
  9. 'type' => 'static',
  10. /*
  11. * Settings for `laravel` type output.
  12. */
  13. 'laravel' => [
  14. /*
  15. * Whether to automatically create a docs endpoint for you to view your generated docs.
  16. * If this is false, you can still set up routing manually.
  17. */
  18. 'autoload' => false,
  19. /*
  20. * URL path to use for the docs endpoint (if `autoload` is true).
  21. *
  22. * By default, `/doc` opens the HTML page, and `/doc.json` downloads the Postman collection.
  23. */
  24. 'docs_url' => '/doc',
  25. /*
  26. * Middleware to attach to the docs endpoint (if `autoload` is true).
  27. */
  28. 'middleware' => [],
  29. ],
  30. /*
  31. * The router to be used (Laravel or Dingo).
  32. */
  33. 'router' => 'laravel',
  34. /*
  35. * The base URL to be used in examples and the Postman collection.
  36. * By default, this will be the value of config('app.url').
  37. */
  38. 'base_url' => null,
  39. /*
  40. * Generate a Postman collection in addition to HTML docs.
  41. * For 'static' docs, the collection will be generated to public/docs/collection.json.
  42. * For 'laravel' docs, it will be generated to storage/app/apidoc/collection.json.
  43. * The `ApiDoc::routes()` helper will add routes for both the HTML and the Postman collection.
  44. */
  45. 'postman' => [
  46. /*
  47. * Specify whether the Postman collection should be generated.
  48. */
  49. 'enabled' => true,
  50. /*
  51. * The name for the exported Postman collection. Default: config('app.name')." API"
  52. */
  53. 'name' => null,
  54. /*
  55. * The description for the exported Postman collection.
  56. */
  57. 'description' => null,
  58. /*
  59. * The "Auth" section that should appear in the postman collection. See the schema docs for more information:
  60. * https://schema.getpostman.com/json/collection/v2.0.0/docs/index.html
  61. */
  62. 'auth' => null,
  63. ],
  64. /*
  65. * The routes for which documentation should be generated.
  66. * Each group contains rules defining which routes should be included ('match', 'include' and 'exclude' sections)
  67. * and rules which should be applied to them ('apply' section).
  68. */
  69. 'routes' => [
  70. [
  71. /*
  72. * Specify conditions to determine what routes will be parsed in this group.
  73. * A route must fulfill ALL conditions to pass.
  74. */
  75. 'match' => [
  76. /*
  77. * Match only routes whose domains match this pattern (use * as a wildcard to match any characters).
  78. */
  79. 'domains' => [
  80. '*',
  81. // 'domain1.*',
  82. ],
  83. /*
  84. * Match only routes whose paths match this pattern (use * as a wildcard to match any characters).
  85. */
  86. 'prefixes' => [
  87. '*',
  88. // 'users/*',
  89. ],
  90. /*
  91. * Match only routes registered under this version. This option is ignored for Laravel router.
  92. * Note that wildcards are not supported.
  93. */
  94. 'versions' => [
  95. 'v1',
  96. ],
  97. ],
  98. /*
  99. * Include these routes when generating documentation,
  100. * even if they did not match the rules above.
  101. * Note that the route must be referenced by name here (wildcards are supported).
  102. */
  103. 'include' => [
  104. // 'users.index', 'healthcheck*'
  105. ],
  106. /*
  107. * Exclude these routes when generating documentation,
  108. * even if they matched the rules above.
  109. * Note that the route must be referenced by name here (wildcards are supported).
  110. */
  111. 'exclude' => [
  112. // 'users.create', 'admin.*'
  113. ],
  114. /*
  115. * Specify rules to be applied to all the routes in this group when generating documentation
  116. */
  117. 'apply' => [
  118. /*
  119. * Specify headers to be added to the example requests
  120. */
  121. 'headers' => [
  122. 'Content-Type' => 'application/json',
  123. 'Accept' => 'application/json',
  124. // 'Authorization' => 'Bearer {token}',
  125. // 'Api-Version' => 'v2',
  126. ],
  127. /*
  128. * If no @response or @transformer declarations are found for the route,
  129. * we'll try to get a sample response by attempting an API call.
  130. * Configure the settings for the API call here.
  131. */
  132. 'response_calls' => [
  133. /*
  134. * API calls will be made only for routes in this group matching these HTTP methods (GET, POST, etc).
  135. * List the methods here or use '*' to mean all methods. Leave empty to disable API calls.
  136. */
  137. 'methods' => ['GET'],
  138. /*
  139. * Laravel config variables which should be set for the API call.
  140. * This is a good place to ensure that notifications, emails
  141. * and other external services are not triggered
  142. * during the documentation API calls
  143. */
  144. 'config' => [
  145. 'app.env' => 'documentation',
  146. 'app.debug' => false,
  147. // 'service.key' => 'value',
  148. ],
  149. /*
  150. * Cookies which should be sent with the API call.
  151. */
  152. 'cookies' => [
  153. // 'name' => 'value'
  154. ],
  155. /*
  156. * Query parameters which should be sent with the API call.
  157. */
  158. 'queryParams' => [
  159. // 'key' => 'value',
  160. ],
  161. /*
  162. * Body parameters which should be sent with the API call.
  163. */
  164. 'bodyParams' => [
  165. // 'key' => 'value',
  166. ],
  167. ],
  168. ],
  169. ],
  170. ],
  171. 'strategies' => [
  172. 'metadata' => [
  173. \Mpociot\ApiDoc\Extracting\Strategies\Metadata\GetFromDocBlocks::class,
  174. ],
  175. 'urlParameters' => [
  176. \Mpociot\ApiDoc\Extracting\Strategies\UrlParameters\GetFromUrlParamTag::class,
  177. ],
  178. 'queryParameters' => [
  179. \Mpociot\ApiDoc\Extracting\Strategies\QueryParameters\GetFromQueryParamTag::class,
  180. ],
  181. 'headers' => [
  182. \Mpociot\ApiDoc\Extracting\Strategies\RequestHeaders\GetFromRouteRules::class,
  183. ],
  184. 'bodyParameters' => [
  185. \Mpociot\ApiDoc\Extracting\Strategies\BodyParameters\GetFromBodyParamTag::class,
  186. ],
  187. 'responses' => [
  188. \Mpociot\ApiDoc\Extracting\Strategies\Responses\UseTransformerTags::class,
  189. \Mpociot\ApiDoc\Extracting\Strategies\Responses\UseResponseTag::class,
  190. \Mpociot\ApiDoc\Extracting\Strategies\Responses\UseResponseFileTag::class,
  191. \Mpociot\ApiDoc\Extracting\Strategies\Responses\UseApiResourceTags::class,
  192. \Mpociot\ApiDoc\Extracting\Strategies\Responses\ResponseCalls::class,
  193. ],
  194. ],
  195. /*
  196. * Custom logo path. The logo will be copied from this location
  197. * during the generate process. Set this to false to use the default logo.
  198. *
  199. * Change to an absolute path to use your custom logo. For example:
  200. * 'logo' => resource_path('views') . '/api/logo.png'
  201. *
  202. * If you want to use this, please be aware of the following rules:
  203. * - the image size must be 230 x 52
  204. */
  205. 'logo' => false,
  206. /*
  207. * Name for the group of routes which do not have a @group set.
  208. */
  209. 'default_group' => 'general',
  210. /*
  211. * Example requests for each endpoint will be shown in each of these languages.
  212. * Supported options are: bash, javascript, php, python
  213. * You can add a language of your own, but you must publish the package's views
  214. * and define a corresponding view for it in the partials/example-requests directory.
  215. * See https://laravel-apidoc-generator.readthedocs.io/en/latest/generating-documentation.html
  216. *
  217. */
  218. 'example_languages' => [
  219. 'bash',
  220. 'javascript',
  221. ],
  222. /*
  223. * Configure how responses are transformed using @transformer and @transformerCollection
  224. * Requires league/fractal package: composer require league/fractal
  225. *
  226. */
  227. 'fractal' => [
  228. /* If you are using a custom serializer with league/fractal,
  229. * you can specify it here.
  230. *
  231. * Serializers included with league/fractal:
  232. * - \League\Fractal\Serializer\ArraySerializer::class
  233. * - \League\Fractal\Serializer\DataArraySerializer::class
  234. * - \League\Fractal\Serializer\JsonApiSerializer::class
  235. *
  236. * Leave as null to use no serializer or return a simple JSON.
  237. */
  238. 'serializer' => null,
  239. ],
  240. /*
  241. * If you would like the package to generate the same example values for parameters on each run,
  242. * set this to any number (eg. 1234)
  243. *
  244. */
  245. 'faker_seed' => null,
  246. /*
  247. * If you would like to customize how routes are matched beyond the route configuration you may
  248. * declare your own implementation of RouteMatcherInterface
  249. *
  250. */
  251. 'routeMatcher' => \Mpociot\ApiDoc\Matching\RouteMatcher::class,
  252. ];