apidoc.php 9.4 KB

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