scribe.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. use Knuckles\Scribe\Config;
  3. use Knuckles\Scribe\Config\{AuthIn,ExternalTheme};
  4. use Knuckles\Scribe\Extracting\Strategies;
  5. use function Knuckles\Scribe\Config\{removeStrategies, configureStrategy};
  6. /**
  7. * For documentation, use your IDE's autocomplete features, or see https://scribe.knuckles.wtf/laravel/reference/config
  8. */
  9. return Config\Factory::make(
  10. extracting: Config\Extracting::with(
  11. routes: Config\Routes::match(
  12. prefixes: ['api/*'],
  13. domains: ['*'],
  14. alwaysInclude: [],
  15. alwaysExclude: [],
  16. ),
  17. defaultGroup: 'Endpoints',
  18. databaseConnectionsToTransact: [config('database.default')],
  19. fakerSeedForExamples: 1234,
  20. dataSourcesForExampleModels: ['factoryCreate', 'factoryMake', 'databaseFirst'],
  21. auth: Config\Extracting::auth(
  22. enabled: false,
  23. default: false,
  24. in: AuthIn::BEARER,
  25. useValue: env('SCRIBE_AUTH_KEY'),
  26. placeholder: '{YOUR_AUTH_KEY}',
  27. extraInfo: <<<MARKDOWN
  28. You can retrieve your token by visiting your dashboard and clicking <b>Generate API token</b>.
  29. MARKDOWN
  30. ),
  31. strategies: Config\Extracting::strategies(
  32. // The strategies Scribe will use to extract information about your routes at each stage.
  33. // Use configureStrategy() to specify settings for a strategy in the list.
  34. // Use removeStrategies() to remove an included strategy.
  35. metadata: [...Config\Defaults::METADATA_STRATEGIES],
  36. urlParameters: [...Config\Defaults::URL_PARAMETERS_STRATEGIES],
  37. queryParameters: [...Config\Defaults::QUERY_PARAMETERS_STRATEGIES],
  38. headers: [
  39. ...Config\Defaults::HEADERS_STRATEGIES,
  40. Strategies\StaticData::withSettings(data: [
  41. 'Content-Type' => 'application/json',
  42. 'Accept' => 'application/json',
  43. ]),
  44. ],
  45. bodyParameters: [...Config\Defaults::BODY_PARAMETERS_STRATEGIES],
  46. responses: configureStrategy(
  47. Config\Defaults::RESPONSES_STRATEGIES,
  48. Strategies\Responses\ResponseCalls::withSettings(
  49. only: ['GET *'],
  50. config: [
  51. 'app.env' => 'documentation',
  52. // 'app.debug' => false,
  53. ],
  54. queryParams: [],
  55. bodyParams: [],
  56. fileParams: [],
  57. cookies: [],
  58. )),
  59. responseFields: [...Config\Defaults::RESPONSE_FIELDS_STRATEGIES],
  60. )
  61. ),
  62. output: Config\Output::with(
  63. type: Config\Output::externalLaravelType(
  64. theme: ExternalTheme::Scalar,
  65. docsUrl: '/docs',
  66. ),
  67. title: config('app.name').' API Documentation',
  68. description: '',
  69. baseUrls: [
  70. "production" => config("app.url"),
  71. ],
  72. exampleLanguages: ['bash', 'javascript'],
  73. logo: false,
  74. lastUpdated: 'Last updated: {date:F j, Y}',
  75. postman: Config\Output::postman(
  76. enabled: true,
  77. overrides: [
  78. // 'info.version' => '2.0.0',
  79. ]
  80. ),
  81. openApi: Config\Output::openApi(
  82. enabled: true,
  83. overrides: [
  84. // 'info.version' => '2.0.0',
  85. ],
  86. generators: [],
  87. ),
  88. tryItOut: Config\Output::tryItOut(
  89. enabled: true,
  90. ),
  91. groupsOrder: [
  92. // 'This group will come first',
  93. // 'This group will come next' => [
  94. // 'POST /this-endpoint-will-come-first',
  95. // 'GET /this-endpoint-will-come-next',
  96. // ],
  97. // 'This group will come third' => [
  98. // 'This subgroup will come first' => [
  99. // 'GET /this-other-endpoint-will-come-first',
  100. // ]
  101. // ]
  102. ],
  103. introText: <<<MARKDOWN
  104. This documentation aims to provide all the information you need to work with our API.
  105. <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).
  106. You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>
  107. MARKDOWN,
  108. )
  109. );