scribe.php 9.5 KB

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