scribe.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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, withConfiguredStrategy};
  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. // Use removeStrategies() to remove an included strategy.
  33. // Use withConfiguredStrategy() to configure a strategy which supports it.
  34. metadata: [...Config\Defaults::METADATA_STRATEGIES],
  35. urlParameters: [...Config\Defaults::URL_PARAMETERS_STRATEGIES],
  36. queryParameters: [...Config\Defaults::QUERY_PARAMETERS_STRATEGIES],
  37. headers: [
  38. ...Config\Defaults::HEADERS_STRATEGIES,
  39. Strategies\StaticData::withSettings(data: [
  40. 'Content-Type' => 'application/json',
  41. 'Accept' => 'application/json',
  42. ]),
  43. ],
  44. bodyParameters: [...Config\Defaults::BODY_PARAMETERS_STRATEGIES],
  45. responses: withConfiguredStrategy(
  46. Config\Defaults::RESPONSES_STRATEGIES,
  47. Strategies\Responses\ResponseCalls::withSettings(
  48. only: ['GET *'],
  49. config: [
  50. 'app.env' => 'documentation',
  51. // 'app.debug' => false,
  52. ],
  53. queryParams: [],
  54. bodyParams: [],
  55. fileParams: [],
  56. cookies: [],
  57. )),
  58. responseFields: [...Config\Defaults::RESPONSE_FIELDS_STRATEGIES],
  59. )
  60. ),
  61. output: Config\Output::with(
  62. type: Config\Output::externalLaravelType(
  63. theme: ExternalTheme::Scalar,
  64. docsUrl: '/docs',
  65. ),
  66. title: config('app.name').' API Documentation',
  67. description: '',
  68. baseUrls: [
  69. "production" => config("app.url"),
  70. ],
  71. exampleLanguages: ['bash', 'javascript'],
  72. logo: false,
  73. lastUpdated: 'Last updated: {date:F j, Y}',
  74. postman: Config\Output::postman(
  75. enabled: true,
  76. overrides: [
  77. // 'info.version' => '2.0.0',
  78. ]
  79. ),
  80. openApi: Config\Output::openApi(
  81. enabled: true,
  82. overrides: [
  83. // 'info.version' => '2.0.0',
  84. ],
  85. generators: [],
  86. ),
  87. tryItOut: Config\Output::tryItOut(
  88. enabled: true,
  89. ),
  90. groupsOrder: [
  91. // 'This group will come first',
  92. // 'This group will come next' => [
  93. // 'POST /this-endpoint-will-come-first',
  94. // 'GET /this-endpoint-will-come-next',
  95. // ],
  96. // 'This group will come third' => [
  97. // 'This subgroup will come first' => [
  98. // 'GET /this-other-endpoint-will-come-first',
  99. // ]
  100. // ]
  101. ],
  102. introText: <<<MARKDOWN
  103. This documentation aims to provide all the information you need to work with our API.
  104. <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).
  105. 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>
  106. MARKDOWN,
  107. )
  108. );