xref: /dokuwiki/lib/exe/openapi.php (revision cd0c7c3ac30b7ba30de3230dcb8facddf029d5f3)
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*cd0c7c3aSAndreas Gohr    <title>DokuWiki API Explorer</title>
200c6e9178SAndreas Gohr    <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module"
210c6e9178SAndreas Gohr            defer=""></script>
225ee96713SAndreas Gohr    <style>
235ee96713SAndreas Gohr        body {
245ee96713SAndreas Gohr            font-family: sans-serif;
255ee96713SAndreas Gohr        }
265ee96713SAndreas Gohr    </style>
275ee96713SAndreas Gohr</head>
285ee96713SAndreas Gohr<body>
295ee96713SAndreas Gohr<openapi-explorer
305ee96713SAndreas Gohr    spec-url="<?php echo DOKU_URL ?>lib/exe/openapi.php?spec=1"
315ee96713SAndreas Gohr    hide-server-selection="true"
325ee96713SAndreas Gohr    use-path-in-nav-bar="true"
330c6e9178SAndreas Gohr>
340c6e9178SAndreas Gohr    <div slot="overview-api-description">
350c6e9178SAndreas Gohr        <p>
360c6e9178SAndreas Gohr            This is an auto generated description and OpenAPI specification for the
370c6e9178SAndreas Gohr            <a href="https://www.dokuwiki.org/devel/jsonrpc">DokuWiki JSON-RPC API</a>.
380c6e9178SAndreas Gohr            It is generated from the source code and the inline documentation.
390c6e9178SAndreas Gohr        </p>
400c6e9178SAndreas Gohr
410c6e9178SAndreas Gohr        <p>
420c6e9178SAndreas Gohr            <a href="<?php echo DOKU_BASE ?>/lib/exe/openapi.php?spec=1" download="dokuwiki.json">Download
430c6e9178SAndreas Gohr                the API Spec</a>
440c6e9178SAndreas Gohr        </p>
450c6e9178SAndreas Gohr
460c6e9178SAndreas Gohr    </div>
470c6e9178SAndreas Gohr
480c6e9178SAndreas Gohr    <div slot="authentication-footer">
490c6e9178SAndreas Gohr        <p>
500c6e9178SAndreas Gohr            <?php
510c6e9178SAndreas Gohr            if ($INPUT->server->has('REMOTE_USER')) {
520c6e9178SAndreas Gohr                echo 'You are currently logged in as <strong>' . hsc($INPUT->server->str('REMOTE_USER')) . '</strong>.';
530c6e9178SAndreas Gohr                echo '<br>API calls in this tool will be automatically executed with your permissions.';
540c6e9178SAndreas Gohr            } else {
550c6e9178SAndreas Gohr                echo 'You are currently not logged in.<br>';
560c6e9178SAndreas Gohr                echo 'You can provide credentials above.';
570c6e9178SAndreas Gohr            }
580c6e9178SAndreas Gohr            ?>
590c6e9178SAndreas Gohr        </p>
600c6e9178SAndreas Gohr    </div>
610c6e9178SAndreas Gohr</openapi-explorer>
625ee96713SAndreas Gohr</body>
635ee96713SAndreas Gohr</html>
645ee96713SAndreas Gohr
655ee96713SAndreas Gohr
66