scribe.php 11 KB

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