aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/exe/openapi.php
blob: db12bf589ad24817d219c26cac0979297a5aa872 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');

require_once(DOKU_INC . 'inc/init.php');
global $INPUT;

if ($INPUT->has('spec')) {
    header('Content-Type: application/json');
    $apigen = new \dokuwiki\Remote\OpenAPIGenerator();
    echo $apigen->generate();
    exit();
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>DokuWiki API Explorer</title>
    <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module"
            defer=""></script>
    <style>
        body {
            font-family: sans-serif;
        }
    </style>
</head>
<body>
<openapi-explorer
    spec-url="<?php echo DOKU_URL ?>lib/exe/openapi.php?spec=1"
    hide-server-selection="true"
    use-path-in-nav-bar="true"
>
    <div slot="overview-api-description">
        <p>
            This is an auto generated description and OpenAPI specification for the
            <a href="https://www.dokuwiki.org/devel/jsonrpc">DokuWiki JSON-RPC API</a>.
            It is generated from the source code and the inline documentation.
        </p>

        <p>
            <a href="<?php echo DOKU_BASE ?>/lib/exe/openapi.php?spec=1" download="dokuwiki.json">Download
                the API Spec</a>
        </p>

    </div>

    <div slot="authentication-footer">
        <p>
            <?php
            if ($INPUT->server->has('REMOTE_USER')) {
                echo 'You are currently logged in as <strong>' . hsc($INPUT->server->str('REMOTE_USER')) . '</strong>.';
                echo '<br>API calls in this tool will be automatically executed with your permissions.';
            } else {
                echo 'You are currently not logged in.<br>';
                echo 'You can provide credentials above.';
            }
            ?>
        </p>
    </div>
</openapi-explorer>
</body>
</html>