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