xref: /dokuwiki/lib/exe/openapi.php (revision cd0c7c3ac30b7ba30de3230dcb8facddf029d5f3)
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    <title>DokuWiki API Explorer</title>
20    <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module"
21            defer=""></script>
22    <style>
23        body {
24            font-family: sans-serif;
25        }
26    </style>
27</head>
28<body>
29<openapi-explorer
30    spec-url="<?php echo DOKU_URL ?>lib/exe/openapi.php?spec=1"
31    hide-server-selection="true"
32    use-path-in-nav-bar="true"
33>
34    <div slot="overview-api-description">
35        <p>
36            This is an auto generated description and OpenAPI specification for the
37            <a href="https://www.dokuwiki.org/devel/jsonrpc">DokuWiki JSON-RPC API</a>.
38            It is generated from the source code and the inline documentation.
39        </p>
40
41        <p>
42            <a href="<?php echo DOKU_BASE ?>/lib/exe/openapi.php?spec=1" download="dokuwiki.json">Download
43                the API Spec</a>
44        </p>
45
46    </div>
47
48    <div slot="authentication-footer">
49        <p>
50            <?php
51            if ($INPUT->server->has('REMOTE_USER')) {
52                echo 'You are currently logged in as <strong>' . hsc($INPUT->server->str('REMOTE_USER')) . '</strong>.';
53                echo '<br>API calls in this tool will be automatically executed with your permissions.';
54            } else {
55                echo 'You are currently not logged in.<br>';
56                echo 'You can provide credentials above.';
57            }
58            ?>
59        </p>
60    </div>
61</openapi-explorer>
62</body>
63</html>
64
65
66