scribe.php 11 KB

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