scribe.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. use Knuckles\Scribe\Extracting\Strategies;
  3. return [
  4. 'title' => 'Owl Admin API Documentation',
  5. 'description' => 'Owl Admin API 接口文档',
  6. 'base_url' => null,
  7. 'routes' => [
  8. [
  9. 'match' => [
  10. 'prefixes' => ['api/*', 'admin/*'],
  11. 'domains' => ['*'],
  12. 'versions' => ['v1'],
  13. ],
  14. 'include' => [],
  15. 'exclude' => [],
  16. ],
  17. ],
  18. 'type' => 'static',
  19. 'theme' => 'default',
  20. 'static' => [
  21. 'output_path' => 'public/docs',
  22. ],
  23. 'laravel' => [
  24. 'add_routes' => true,
  25. 'docs_url' => '/docs',
  26. 'middleware' => [],
  27. // Directory within `public` in which to store CSS and JS assets.
  28. // By default, assets are stored in `public/vendor/scribe`.
  29. // If set, assets will be stored in `public/{{assets_directory}}`
  30. 'assets_directory' => null,
  31. ],
  32. 'try_it_out' => [
  33. 'enabled' => true,
  34. 'base_url' => null,
  35. 'use_csrf' => false,
  36. 'csrf_url' => '/sanctum/csrf-cookie',
  37. ],
  38. 'auth' => [
  39. 'enabled' => true,
  40. 'default' => true,
  41. 'in' => 'bearer',
  42. 'name' => 'token',
  43. 'use_value' => env('SCRIBE_AUTH_KEY'),
  44. 'placeholder' => env('YOUR_AUTH_KEY'),
  45. 'extra_info' => 'You can retrieve your token by visiting your dashboard and clicking <b>Generate API token</b>.',
  46. ],
  47. 'intro_text' => <<<'INTRO'
  48. 欢迎使用 Owl Admin API 接口文档。
  49. 该文档提供了所有可用的API接口信息。
  50. INTRO,
  51. 'example_languages' => [
  52. 'javascript',
  53. 'bash',
  54. ],
  55. 'examples' => [
  56. 'faker_seed' => null,
  57. 'models_source' => ['factoryCreate', 'factoryMake', 'databaseFirst'],
  58. ],
  59. 'strategies' => [
  60. 'metadata' => [
  61. Strategies\Metadata\GetFromDocBlocks::class,
  62. Strategies\Metadata\GetFromMetadataAttributes::class,
  63. ],
  64. 'urlParameters' => [
  65. Strategies\UrlParameters\GetFromLaravelAPI::class,
  66. Strategies\UrlParameters\GetFromUrlParamAttribute::class,
  67. Strategies\UrlParameters\GetFromUrlParamTag::class,
  68. ],
  69. 'queryParameters' => [
  70. Strategies\QueryParameters\GetFromFormRequest::class,
  71. Strategies\QueryParameters\GetFromInlineValidator::class,
  72. Strategies\QueryParameters\GetFromQueryParamAttribute::class,
  73. Strategies\QueryParameters\GetFromQueryParamTag::class,
  74. ],
  75. 'headers' => [
  76. Strategies\Headers\GetFromRouteRules::class,
  77. Strategies\Headers\GetFromHeaderAttribute::class,
  78. Strategies\Headers\GetFromHeaderTag::class,
  79. ],
  80. 'bodyParameters' => [
  81. Strategies\BodyParameters\GetFromFormRequest::class,
  82. Strategies\BodyParameters\GetFromInlineValidator::class,
  83. Strategies\BodyParameters\GetFromBodyParamAttribute::class,
  84. Strategies\BodyParameters\GetFromBodyParamTag::class,
  85. ],
  86. 'responses' => [
  87. Strategies\Responses\UseResponseAttributes::class,
  88. Strategies\Responses\UseTransformerTags::class,
  89. Strategies\Responses\UseResponseTag::class,
  90. Strategies\Responses\UseResponseFileTag::class,
  91. Strategies\Responses\UseApiResourceTags::class,
  92. Strategies\Responses\ResponseCalls::class,
  93. ],
  94. 'responseFields' => [
  95. Strategies\ResponseFields\GetFromResponseFieldAttribute::class,
  96. Strategies\ResponseFields\GetFromResponseFieldTag::class,
  97. ],
  98. ],
  99. 'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
  100. 'database_connections_to_transact' => [config('database.default')],
  101. 'external' => ['html_attributes' => []],
  102. // Generate a Postman collection (v2.1.0) in addition to HTML docs.
  103. // For 'static' docs, the collection will be generated to public/docs/collection.json.
  104. // For 'laravel' docs, it will be generated to storage/app/scribe/collection.json.
  105. // Setting `laravel.add_routes` to true (above) will also add a route for the collection.
  106. 'postman' => ['enabled' => true, 'overrides' => [
  107. 'info.version' => '2.0.0',
  108. ]],
  109. // Generate an OpenAPI spec (v3.0.1) in addition to docs webpage.
  110. // For 'static' docs, the collection will be generated to public/docs/openapi.yaml.
  111. // For 'laravel' docs, it will be generated to storage/app/scribe/openapi.yaml.
  112. // Setting `laravel.add_routes` to true (above) will also add a route for the spec.
  113. 'openapi' => ['enabled' => true, 'overrides' => []],
  114. // Custom logo path. This will be used as the value of the src attribute for the <img> tag,
  115. // so make sure it points to an accessible URL or path. Set to false to not use a logo.
  116. // For example, if your logo is in public/img:
  117. // - 'logo' => '../img/logo.png' // for `static` type (output folder is public/docs)
  118. // - 'logo' => 'img/logo.png' // for `laravel` type
  119. 'logo' => false,
  120. // Customize the "Last updated" value displayed in the docs by specifying tokens and formats.
  121. // Examples:
  122. // - {date:F j Y} => March 28, 2022
  123. // - {git:short} => Short hash of the last Git commit
  124. // Available tokens are `{date:<format>}` and `{git:<format>}`.
  125. // The format you pass to `date` will be passed to PHP's `date()` function.
  126. // The format you pass to `git` can be either "short" or "long".
  127. 'last_updated' => '{date:F j Y}',
  128. 'fractal' => [
  129. // If you are using a custom serializer with league/fractal, you can specify it here.
  130. 'serializer' => null,
  131. ],
  132. // 添加以下配置以确保目录树可以展开
  133. 'groups' => [
  134. 'enabled' => true,
  135. 'sort' => 'asc',
  136. ],
  137. 'external' => [
  138. 'html_attributes' => [
  139. 'dark-mode' => false,
  140. ],
  141. ],
  142. ];