apidoc.php 9.4 KB

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