xref: /dokuwiki/lib/exe/openapi.php (revision 0c6e917818109b1f50cd46754bb3bf353e36d889)
15ee96713SAndreas Gohr<?php
25ee96713SAndreas Gohr
35ee96713SAndreas Gohrif (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
45ee96713SAndreas Gohr
55ee96713SAndreas Gohrrequire_once(DOKU_INC . 'inc/init.php');
65ee96713SAndreas Gohrglobal $INPUT;
75ee96713SAndreas Gohr
85ee96713SAndreas Gohrif ($INPUT->has('spec')) {
95ee96713SAndreas Gohr    header('Content-Type: application/json');
105ee96713SAndreas Gohr    $apigen = new \dokuwiki\Remote\OpenAPIGenerator();
115ee96713SAndreas Gohr    echo $apigen->generate();
125ee96713SAndreas Gohr    exit();
135ee96713SAndreas Gohr}
145ee96713SAndreas Gohr?>
155ee96713SAndreas Gohr<!doctype html>
165ee96713SAndreas Gohr<html lang="en">
175ee96713SAndreas Gohr<head>
185ee96713SAndreas Gohr    <meta charset="utf-8">
19*0c6e9178SAndreas Gohr    <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module"
20*0c6e9178SAndreas Gohr            defer=""></script>
215ee96713SAndreas Gohr    <style>
225ee96713SAndreas Gohr        body {
235ee96713SAndreas Gohr            font-family: sans-serif;
245ee96713SAndreas Gohr        }
255ee96713SAndreas Gohr    </style>
265ee96713SAndreas Gohr</head>
275ee96713SAndreas Gohr<body>
285ee96713SAndreas Gohr<openapi-explorer
295ee96713SAndreas Gohr    spec-url="<?php echo DOKU_URL ?>lib/exe/openapi.php?spec=1"
305ee96713SAndreas Gohr    hide-server-selection="true"
315ee96713SAndreas Gohr    use-path-in-nav-bar="true"
32*0c6e9178SAndreas Gohr>
33*0c6e9178SAndreas Gohr    <div slot="overview-api-description">
34*0c6e9178SAndreas Gohr        <p>
35*0c6e9178SAndreas Gohr            This is an auto generated description and OpenAPI specification for the
36*0c6e9178SAndreas Gohr            <a href="https://www.dokuwiki.org/devel/jsonrpc">DokuWiki JSON-RPC API</a>.
37*0c6e9178SAndreas Gohr            It is generated from the source code and the inline documentation.
38*0c6e9178SAndreas Gohr        </p>
39*0c6e9178SAndreas Gohr
40*0c6e9178SAndreas Gohr        <p>
41*0c6e9178SAndreas Gohr            <a href="<?php echo DOKU_BASE ?>/lib/exe/openapi.php?spec=1" download="dokuwiki.json">Download
42*0c6e9178SAndreas Gohr                the API Spec</a>
43*0c6e9178SAndreas Gohr        </p>
44*0c6e9178SAndreas Gohr
45*0c6e9178SAndreas Gohr    </div>
46*0c6e9178SAndreas Gohr
47*0c6e9178SAndreas Gohr    <div slot="authentication-footer">
48*0c6e9178SAndreas Gohr        <p>
49*0c6e9178SAndreas Gohr            <?php
50*0c6e9178SAndreas Gohr            if ($INPUT->server->has('REMOTE_USER')) {
51*0c6e9178SAndreas Gohr                echo 'You are currently logged in as <strong>' . hsc($INPUT->server->str('REMOTE_USER')) . '</strong>.';
52*0c6e9178SAndreas Gohr                echo '<br>API calls in this tool will be automatically executed with your permissions.';
53*0c6e9178SAndreas Gohr            } else {
54*0c6e9178SAndreas Gohr                echo 'You are currently not logged in.<br>';
55*0c6e9178SAndreas Gohr                echo 'You can provide credentials above.';
56*0c6e9178SAndreas Gohr            }
57*0c6e9178SAndreas Gohr            ?>
58*0c6e9178SAndreas Gohr        </p>
59*0c6e9178SAndreas Gohr    </div>
60*0c6e9178SAndreas Gohr</openapi-explorer>
615ee96713SAndreas Gohr</body>
625ee96713SAndreas Gohr</html>
635ee96713SAndreas Gohr
645ee96713SAndreas Gohr
65