$assetUrlRoot = $app->config("SelfUrl") . "/doc"; $docTpl = $app->config("AppRootDir") . "/assets/doc/viewer.tpl"; $smarty = new Smarty(); $smarty->setCompileDir($app->config("Cache.RootDir") . "/templates_c"); $smarty->assign("title", $app->localizer->getText("L_PRODUCT_API_REFERENCE", "mapguide-rest")); $smarty->assign("docUrl", $docUrl); $smarty->assign("docAssetRoot", $assetUrlRoot); $output = $smarty->fetch($docTpl); $app->response->header("Content-Type", "text/html"); $app->response->setBody($output); }); $app->get("/apidoc/:file", function ($file) use($app) { if (MgUtils::StringEndsWith($file, ".json")) { $file = str_replace(".json", "", $file); } $prefix = MgUtils::GetApiVersionNamespace($app, "/apidoc"); if (strlen($prefix) > 0) { $path = $app->config("AppRootDir") . "/doc/data/{$prefix}/{$file}.json"; } else { $path = $app->config("AppRootDir") . "/doc/data/{$file}.json"; } $doc = json_decode(file_get_contents($path)); if (strlen($prefix) > 0) { $doc->basePath = $app->config("SelfUrl") . "/{$prefix}"; } else { $doc->basePath = $app->config("SelfUrl"); } $doc->swaggerVersion = SWAGGER_API_VERSION; $doc->apiVersion = MG_REST_API_VERSION; $app->response->header("Content-Type", "application/json"); $app->response->setBody(json_encode($doc));