You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

88 lines
2.6 KiB

  1. <?php
  2. use dokuwiki\Remote\OpenApiDoc\OpenAPIGenerator;
  3. if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
  4. require_once(DOKU_INC . 'inc/init.php');
  5. global $INPUT;
  6. if ($INPUT->has('spec')) {
  7. header('Content-Type: application/json');
  8. $apigen = new OpenAPIGenerator();
  9. echo $apigen->generate();
  10. exit();
  11. }
  12. ?>
  13. <!doctype html>
  14. <html lang="en">
  15. <head>
  16. <meta charset="utf-8">
  17. <title>DokuWiki API Explorer</title>
  18. <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module"
  19. defer=""></script>
  20. <style>
  21. body {
  22. font-family: sans-serif;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <openapi-explorer
  28. spec-url="<?php echo DOKU_URL ?>lib/exe/openapi.php?spec=1"
  29. hide-server-selection="true"
  30. use-path-in-nav-bar="true"
  31. >
  32. <div slot="overview-api-description">
  33. <p>
  34. This is an auto generated description and OpenAPI specification for the
  35. <a href="https://www.dokuwiki.org/devel/jsonrpc">DokuWiki JSON-RPC API</a>.
  36. It is generated from the source code and the inline documentation.
  37. </p>
  38. <p>
  39. <a href="<?php echo DOKU_BASE ?>/lib/exe/openapi.php?spec=1" download="dokuwiki.json">Download
  40. the API Spec</a>
  41. </p>
  42. <h3>Error Codes</h3>
  43. <p>
  44. The following error codes are currently used in the core methods. This list may be incomplete
  45. or change in the future.
  46. </p>
  47. <table>
  48. <tr><th>Code</th><th>Message</th></tr>
  49. <tr><td>0</td><td>Success</td></tr>
  50. <?php
  51. $apigen = new OpenAPIGenerator();
  52. $last = 0;
  53. foreach ($apigen->getErrorCodes() as $code) {
  54. // duplicate codes are only shown with debug
  55. if ($code['code'] === $last && !$INPUT->has('debug')) continue;
  56. $last = $code['code'];
  57. echo '<tr><td>' . $code['code'] . '</td><td>' . hsc($code['message']) . '</td></tr>';
  58. }
  59. ?>
  60. </table>
  61. </div>
  62. <div slot="authentication-footer">
  63. <p>
  64. <?php
  65. if ($INPUT->server->has('REMOTE_USER')) {
  66. echo 'You are currently logged in as <strong>' . hsc($INPUT->server->str('REMOTE_USER')) . '</strong>.';
  67. echo '<br>API calls in this tool will be automatically executed with your permissions.';
  68. } else {
  69. echo 'You are currently not logged in.<br>';
  70. echo 'You can provide credentials above.';
  71. }
  72. ?>
  73. </p>
  74. </div>
  75. </openapi-explorer>
  76. </body>
  77. </html>